Increase slow RPC timeout
authorJamie Cameron <jcameron@webmin.com>
Tue, 16 Nov 2010 00:36:54 +0000 (16:36 -0800)
committerJamie Cameron <jcameron@webmin.com>
Tue, 16 Nov 2010 00:36:54 +0000 (16:36 -0800)
rpc.cgi
web-lib-funcs.pl

diff --git a/rpc.cgi b/rpc.cgi
index 275caa2..daed9c3 100755 (executable)
--- a/rpc.cgi
+++ b/rpc.cgi
@@ -13,8 +13,9 @@ use POSIX;
 &init_config();
 if ($ENV{'REQUEST_METHOD'} eq 'POST') {
        local $got;
-       while(length($rawarg) < $ENV{'CONTENT_LENGTH'}) {
-               read(STDIN, $got, $ENV{'CONTENT_LENGTH'}) > 0 || last;
+       local $left = $ENV{'CONTENT_LENGTH'} - length($rawarg);
+       while($left > 0) {
+               read(STDIN, $got, $left) > 0 || last;
                $rawarg .= $got;
                }
        }
@@ -49,9 +50,10 @@ if ($arg->{'newsession'}) {
                close(STDOUT);
                close(miniserv::SOCK);
                local $stime = time();
+               local $rcount = 0;
                while(1) {
                        local ($rawcmd, $cmd, @rv);
-                       alarm(10);
+                       alarm($rcount ? 360 : 60);
                        open(FIFO, $fifo1) || last;
                        while(<FIFO>) {
                                $rawcmd .= $_;
@@ -98,6 +100,7 @@ EOF
                                }
                        close(FIFO);
                        last if ($cmd->{'action'} eq 'quit');
+                       $rcount++;
                        }
                unlink($fifo1);
                unlink($fifo2);
index bca753d..33db76c 100755 (executable)
@@ -5998,7 +5998,7 @@ foreach my $sn (keys %remote_session) {
        delete($remote_session{$sn});
        delete($remote_session_server{$sn});
        }
-foreach $fh (keys %fast_fh_cache) {
+foreach my $fh (keys %fast_fh_cache) {
        close($fh);
        delete($fast_fh_cache{$fh});
        }
@@ -6015,7 +6015,7 @@ sub remote_error_setup
 $main::remote_error_handler = $_[0] || \&error;
 }
 
-=head2 remote_rpc_call(server, structure)
+=head2 remote_rpc_call(server, &structure)
 
 Calls rpc.cgi on some server and passes it a perl structure (hash,array,etc)
 and then reads back a reply structure. This is mainly for internal use only,