From: minima Date: Wed, 2 May 2001 13:01:23 +0000 (+0000) Subject: add an error counter to stop runaway spot suckers X-Git-Tag: R_1_47~3 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=edf02a551526d4d70dc70c300421c754f84d46e8;p=spider.git add an error counter to stop runaway spot suckers --- diff --git a/Changes b/Changes index a32d1bed..77493fda 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,6 @@ +02May01======================================================================= +1. put an upper limit on the number of concurrent errors allowed in command +mode (20). This should disconnect runaway spot suckers.... 28Apr01======================================================================= 1. fix an occasional problem with 'sorry connected to' messages 23Apr01======================================================================= diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 6afd97e9..7602283f 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -91,6 +91,7 @@ $count = 0; talklist => '0,Talk List,parray', cluster => '5,Cluster data', isbasic => '9,Internal Connection', + errors => '9,Errors', ); # object destruction 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); }