X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=de59160663c080356a11a354c5a52b098f0f3ea1;hb=bd67cc5f4c14f9bb80e609bb971f0a4dd7c44197;hp=0f802d89f6396a8fd031ea2323a8d41666c3131c;hpb=8195bc13ac14b8fbf13d804186680653b5fd8564;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 0f802d89..de591606 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -199,20 +199,25 @@ sub run_cmd ($path, $fcmd) = search($main::localcmd, $cmd, "pl"); ($path, $fcmd) = search($main::cmd, $cmd, "pl") if !$path || !$fcmd; - dbg('command', "path: $cmd cmd: $fcmd"); + if ($path && $cmd) { + dbg('command', "path: $cmd cmd: $fcmd"); - my $package = find_cmd_name($path, $fcmd); - @ans = (0) if !$package ; - - if ($package) { - dbg('command', "package: $package"); + my $package = find_cmd_name($path, $fcmd); + @ans = (0) if !$package ; - my $c = qq{ \@ans = $package(\$self, \$args) }; - dbg('eval', "cluster cmd = $c\n"); - eval $c; - if ($@) { - @ans = (0, "Syserr: Eval err cached $package\n$@"); + if ($package) { + dbg('command', "package: $package"); + + my $c = qq{ \@ans = $package(\$self, \$args) }; + dbg('eval', "cluster cmd = $c\n"); + eval $c; + if ($@) { + @ans = (0, "Syserr: Eval err cached $package\n$@"); + } } + } else { + dbg('command', "cmd: $cmd not found"); + @ans = (0); } } } @@ -467,7 +472,7 @@ sub find_cmd_name { # return if we can't find it $errstr = undef; - if (undef $mtime) { + unless (defined $mtime) { $errstr = DXM::msg('e1'); return undef; } @@ -478,6 +483,8 @@ sub find_cmd_name { #print STDERR "already compiled $package->handler\n"; ; } else { + delete_package($package) if defined $Cache{$package}{mtime}; + my $fh = new FileHandle; if (!open $fh, $filename) { $errstr = "Syserr: can't open '$filename' $!"; @@ -510,7 +517,7 @@ sub find_cmd_name { delete_package($package); } else { #cache it unless we're cleaning out each time - $Cache{$package}{mtime} = $mtime; + $Cache{$package}{'mtime'} = $mtime; } }