elsif ($arg->{'action'} eq 'require') {
# require a library
print STDERR "fastrpc: require $arg->{'module'}/$arg->{'file'}\n" if ($gconfig{'rpcdebug'});
- &foreign_require($arg->{'module'},
- $arg->{'file'});
- $rawrv = &serialise_variable( { 'status' => 1 });
+ eval {
+ &foreign_require($arg->{'module'},
+ $arg->{'file'});
+ };
+ if ($@) {
+ print STDERR "fastrpc: require error $@\n" if ($gconfig{'rpcdebug'});
+ $rawrv = &serialise_variable( { 'status' => 0,
+ 'rv' => $@ });
+ }
+ else {
+ print STDERR "fastrpc: require done\n" if ($gconfig{'rpcdebug'});
+ $rawrv = &serialise_variable( { 'status' => 1 });
+ }
}
elsif ($arg->{'action'} eq 'call') {
# execute a function
print STDERR "fastrpc: call $arg->{'module'}::$arg->{'func'}(",join(",", @{$arg->{'args'}}),")\n" if ($gconfig{'rpcdebug'});
- local @rv = &foreign_call($arg->{'module'},
- $arg->{'func'},
- @{$arg->{'args'}});
- if (@rv == 1) {
+ local @rv;
+ eval {
+ @rv = &foreign_call($arg->{'module'},
+ $arg->{'func'},
+ @{$arg->{'args'}});
+ };
+ if ($@) {
+ print STDERR "fastrpc: call error $@\n" if ($gconfig{'rpcdebug'});
+ $rawrv = &serialise_variable(
+ { 'status' => 0, 'rv' => $@ } );
+ }
+ elsif (@rv == 1) {
$rawrv = &serialise_variable(
{ 'status' => 1, 'rv' => $rv[0] } );
}
$main::file_cache{$realfile} = \@lines;
$main::file_cache_noflush{$realfile} = $_[1];
}
+else {
+ # Make read-write if currently readonly
+ if (!$_[1]) {
+ $main::file_cache_noflush{$realfile} = 0;
+ }
+ }
return $main::file_cache{$realfile};
}
}
# remote_session_name(host|&server)
+# Generates a unix session ID for some server
sub remote_session_name
{
return ref($_[0]) && $_[0]->{'host'} && $_[0]->{'port'} ?
- "$_[0]->{'host'}:$_[0]->{'port'}" :
- ref($_[0]) ? "" : $_[0];
+ "$_[0]->{'host'}:$_[0]->{'port'}.$$" :
+ ref($_[0]) ? "" : "$_[0].$$";
}
# remote_foreign_require(server, module, file)