--- loncom/lonnet/perl/lonnet.pm 2011/08/02 03:11:42 1.1124 +++ loncom/lonnet/perl/lonnet.pm 2011/08/05 04:35:50 1.1125 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1124 2011/08/02 03:11:42 raeburn Exp $ +# $Id: lonnet.pm,v 1.1125 2011/08/05 04:35:50 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -308,40 +308,42 @@ sub get_server_homeID { sub get_remote_globals { my ($lonhost,$whathash,$ignore_cache) = @_; - my (%returnhash,%whatneeded); - if (ref($whathash) eq 'ARRAY') { + my ($result,%returnhash,%whatneeded); + if (ref($whathash) eq 'HASH') { foreach my $what (sort(keys(%{$whathash}))) { - my $type = $whathash->{$what}; my $hashid = $lonhost.'-'.$what; - my ($result,$cached); + my ($response,$cached); unless ($ignore_cache) { - ($result,$cached)=&is_cached_new('lonnetglobal',$hashid); - $returnhash{$what} = $result; + ($response,$cached)=&is_cached_new('lonnetglobal',$hashid); } if (defined($cached)) { - $returnhash{$what} = $result; + $returnhash{$what} = $response; } else { - $whatneeded{$what} = $type; + $whatneeded{$what} = 1; } } - if (keys(%whatneeded) > 0) { + if (keys(%whatneeded) == 0) { + $result = 'ok'; + } else { my $requested = &freeze_escape(\%whatneeded); my $rep=&reply('readlonnetglobal:'.$requested,$lonhost); - unless (($rep=~/^refused/) || ($rep=~/^rejected/) || ($rep eq 'con_lost')) { + if (($rep=~/^(refused|rejected|error)/) || ($rep eq 'con_lost') || + ($rep eq 'unknown_cmd')) { + $result = $rep; + } else { + $result = 'ok'; my @pairs=split(/\&/,$rep); - if ($rep !~ /^error/) { - foreach my $item (@pairs) { - my ($key,$value)=split(/=/,$item,2); - my $what = &unescape($key); - my $hashid = $lonhost.'-'.$what; - $returnhash{$what}=&thaw_unescape($value); - &do_cache_new('lonnetglobal',$hashid,$returnhash{$what},600); - } + foreach my $item (@pairs) { + my ($key,$value)=split(/=/,$item,2); + my $what = &unescape($key); + my $hashid = $lonhost.'-'.$what; + $returnhash{$what}=&thaw_unescape($value); + &do_cache_new('lonnetglobal',$hashid,$returnhash{$what},600); } } } } - return %returnhash; + return ($result,\%returnhash); } sub remote_devalidate_cache {