X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=3d5ce0c9f6fb5fa9744939c7e121b8429b06b706;hb=9e8b70da52136e061fee9f8a219c713cc1d7df4d;hp=1b08b36e6a149d4a9c82070a47e8b3f328e09c04;hpb=5fc4f15ca36b6926fac4a8b33b3944cc1f7cef49;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 1b08b36e..3d5ce0c9 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -1265,22 +1265,6 @@ sub send_motd $self->send_file($motd) if -e $motd; } -sub _diffms -{ - return unless isdbg('chan'); - my $call = shift; - my $line = shift; - my $ta = shift; - my $tb = shift || [gettimeofday]; - - my $a = int($ta->[0] * 1000) + int($ta->[1] / 1000); - my $b = int($tb->[0] * 1000) + int($tb->[1] / 1000); - my $msecs = $b - $a; - - my $s = "forkcall stats: $call '$line' "; - $s .= "${msecs}mS"; - dbg($s); -} # Punt off a long running command into a separate process # @@ -1309,18 +1293,22 @@ sub spawn_cmd my $t0 = [gettimeofday]; no strict 'refs'; - + + # just behave normally if something has set the "one-shot" _nospawn in the channel + return ($cmdref->(@$args)) if $self->{_nospawn}; + my $fc = Mojo::IOLoop::Subprocess->new; # $fc->serializer(\&encode_json); # $fc->deserializer(\&decode_json); $fc->run( sub { my $subpro = shift; - if (isdbg('chan')) { + if (isdbg('spawn_cmd')) { my $s = "line: $line"; $s .= ", args: " . join(', ', @$args) if $args && @$args; } my @res = $cmdref->(@$args); +# diffms("rcmd from $call 1", $line, $t0, scalar @res) if isdbg('chan'); return @res; }, # $args, @@ -1330,7 +1318,7 @@ sub spawn_cmd return unless $dxchan; if ($err) { - my $s = "DXCommand::spawn_cmd: call $call error $err"; + my $s = "DXProt::spawn_cmd: call $call error $err"; dbg($s) if isdbg('chan'); $dxchan->send($s); return; @@ -1346,7 +1334,7 @@ sub spawn_cmd $dxchan->send(@res); } } - _diffms($call, $line, $t0); + diffms("by $call", $line, $t0, scalar @res) if isdbg('chan'); }); return @out;