Skip to content

Commit

Permalink
More HTTP performance updates in json_server
Browse files Browse the repository at this point in the history
  • Loading branch information
waynieack committed Aug 27, 2017
1 parent 8ee4840 commit 91caa45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions bin/mh
Original file line number Diff line number Diff line change
Expand Up @@ -2584,7 +2584,7 @@ sub check_for_socket_data_http {
# We must sleep here for a bit, or else Netscape sometimes
# says 'Document contains no data'. Guess we don't need this anymore :)
# select undef, undef, undef, .010;
print "http: closing socket - ". $Info{'http_socket'}->peer ." ....\n" if $Debug{http};
#print "http: closing socket - ". $Info{'http_socket'}->peer ." ....\n" if $Debug{http};
&socket_close('http');
}
}
Expand Down Expand Up @@ -6700,7 +6700,7 @@ sub sig_handler_pipe {
sub sig_child_death {

# my $pid = wait;
# print "reaped $pid" . ($? ? " with exit $?" : '');
# print "reaped $pid" . ($? ? " with exit $?" : '');
# Harvest potentially more than one dead child
use POSIX ":sys_wait_h";
my $pid;
Expand Down
18 changes: 8 additions & 10 deletions lib/json_server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,12 @@ sub json_get {
# is time consuming, particularly when called numerous times. Instead,
# we create a lookup table one time, saving a lot of processing time.
$json_cache{parent_table} = build_parent_table() if ( !($json_cache{parent_table}) || $Reload );

if ( $args{items} && $args{items}[0] ne "" ) {
foreach my $name ( @{ $args{items} } ) {

#$name =~ s/\$|\%|\&|\@//g;
my $o = &get_object_by_name($name);
print_log "json: object name=$name ref=" . ref $o
if $Debug{json};
print_log "json: object name=$name ref=" . ref $o if $Debug{json};
if ( my $data = &json_object_detail( $o, \%args, \%fields, $json_cache{parent_table} ) ) {
$json_data{objects}{$name} = $data;
}
Expand All @@ -522,6 +520,11 @@ sub json_get {
push @objects, &list_objects_by_type($_);
}
}
elsif ( $args{parents} ) {
for ( @{ $args{parents} } ) {
push @objects, &list_objects_by_group( $_, 1 )
}
}
else {
foreach my $object_type ( list_object_types() ) {
push @objects, &list_objects_by_type($object_type);
Expand All @@ -534,8 +537,7 @@ sub json_get {
my $name = $o;
$name = $o->{object_name};
$name =~ s/\$|\%|\&|\@//g;
print_log "json: object name=$name ref=" . ref $o
if $Debug{json};
print_log "json: (map) object name=$name ref=" . ref $o if $Debug{json};
if ( my $data = &json_object_detail( $o, \%args, \%fields, $json_cache{parent_table} ) ) {
$json_data{objects}{$name} = $data;
}
Expand Down Expand Up @@ -1030,16 +1032,13 @@ sub json_walk_var {
}

sub build_parent_table {
print_log "json: build_parent_table running";
my @groups;
my %parent_table;
for my $group_name ( &list_objects_by_type('Group') ) {
my $group = &get_object_by_name($group_name);
$group_name =~ s/\$|\%|\&|\@//g;
print_log "json: build_parent_table group: $group_name";
unless ( defined $group ) {
print_log "json: build_parent_table, group_name $group_name doesn't have an object?"
if $Debug{json};
print_log "json: build_parent_table, group_name $group_name doesn't have an object?" if $Debug{json};
next;
}
else {
Expand Down Expand Up @@ -1386,7 +1385,6 @@ sub json_table_push {
return 0 if ( !defined $json_table{$key} );

$json_table{$key}{time} = &get_tickcount;
&::set_waiter_flags('push_flag',1);
return 1;
}

Expand Down

0 comments on commit 91caa45

Please sign in to comment.