From 91caa451fce8c98f119be9ac21960c6f7dfd1393 Mon Sep 17 00:00:00 2001 From: waynieack Date: Sat, 26 Aug 2017 23:07:49 -0500 Subject: [PATCH] More HTTP performance updates in json_server --- bin/mh | 4 ++-- lib/json_server.pl | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/bin/mh b/bin/mh index 060a57e07..e653c7c1c 100755 --- a/bin/mh +++ b/bin/mh @@ -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'); } } @@ -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; diff --git a/lib/json_server.pl b/lib/json_server.pl index b04266d89..79015b8c0 100755 --- a/lib/json_server.pl +++ b/lib/json_server.pl @@ -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; } @@ -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); @@ -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; } @@ -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 { @@ -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; }