Better RPC error detection
authorJamie Cameron <jcameron@webmin.com>
Sat, 25 Dec 2010 06:37:25 +0000 (22:37 -0800)
committerJamie Cameron <jcameron@webmin.com>
Sat, 25 Dec 2010 06:37:25 +0000 (22:37 -0800)
web-lib-funcs.pl

index 1ca121b..7ffb60c 100755 (executable)
@@ -6215,10 +6215,16 @@ if ($serv->{'fast'} || !$sn) {
        my $tostr = &serialise_variable($_[1]);
        print $fh length($tostr)," $fh\n";
        print $fh $tostr;
-       my $rlen = int(<$fh>);
+       my $rstr = <$fh>;
+       if ($rstr eq '') {
+               return &$main::remote_error_handler(
+                       "Error reading response length from fastrpc.cgi : $!")
+               }
+       my $rlen = int($rstr);
        my ($fromstr, $got);
        while(length($fromstr) < $rlen) {
-               return &$main::remote_error_handler("Failed to read from fastrpc.cgi")
+               return &$main::remote_error_handler(
+                       "Failed to read from fastrpc.cgi : $!")
                        if (read($fh, $got, $rlen - length($fromstr)) <= 0);
                $fromstr .= $got;
                }