X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=967cc022d10cbefb04fb0dcf68902c6ee5ffeeb3;hb=28830bd907c3f7192605ad4aa6c818feb2394e70;hp=197288d5249d84cf957f65b0dce901e11b11d164;hpb=fc56438e42beefbae283ef208f9e3959deddb2bf;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 197288d5..967cc022 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -30,16 +30,16 @@ use AnnTalk; use WCY; use Sun; use Internet; -use IO::File; use strict; -use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase); +use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase $maxerrors); %Cache = (); # cache of dynamically loaded routine's mod times %cmd_cache = (); # cache of short names $errstr = (); # error string from eval %aliases = (); # aliases for (parts of) commands $scriptbase = "$main::root/scripts"; # the place where all users start scripts go +$maxerrors = 20; # the maximum number of concurrent errors allowed before disconnection # # obtain a new connection this is derived from dxchannel @@ -352,12 +352,27 @@ sub run_cmd } } else { dbg('command', "cmd: $cmd not found"); - return ($self->msg('e1')); + if (++$self->{errors} > $maxerrors) { + $self->send($self->msg('e26')); + $self->disconnect; + return (); + } else { + return ($self->msg('e1')); + } } } } - shift @ans; + my $ok = shift @ans; + if ($ok) { + delete $self->{errors}; + } else { + if (++$self->{errors} > $maxerrors) { + $self->send($self->msg('e26')); + $self->disconnect; + return (); + } + } return (@ans); }