X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXCommandmode.pm;h=967cc022d10cbefb04fb0dcf68902c6ee5ffeeb3;hb=edf02a551526d4d70dc70c300421c754f84d46e8;hp=6e7a0944f5461c109d9b4a5d6a5106ba2092515b;hpb=ff03e18639d468fc7f5a9c958b16ab45406fb5d2;p=spider.git diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 6e7a0944..967cc022 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -32,13 +32,14 @@ use Sun; use Internet; 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 @@ -351,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); }