add an error counter to stop runaway spot suckers
authorminima <minima>
Wed, 2 May 2001 13:01:23 +0000 (13:01 +0000)
committerminima <minima>
Wed, 2 May 2001 13:01:23 +0000 (13:01 +0000)
Changes
perl/DXChannel.pm
perl/DXCommandmode.pm

diff --git a/Changes b/Changes
index a32d1bedb4426871ee9e8491505cbeaf15cbbb70..77493fda2bf38fd0850aafb1c2f0f785f9bf2bc3 100644 (file)
--- 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=======================================================================
index 6afd97e9dcf06a001eb235dc85df3a6bf02d610c..7602283fc367b0d8784f80e0ec8dc4ce56bcfa71 100644 (file)
@@ -91,6 +91,7 @@ $count = 0;
                  talklist => '0,Talk List,parray',
                  cluster => '5,Cluster data',
                  isbasic => '9,Internal Connection', 
+                 errors => '9,Errors',
                 );
 
 # object destruction
index 6e7a0944f5461c109d9b4a5d6a5106ba2092515b..967cc022d10cbefb04fb0dcf68902c6ee5ffeeb3 100644 (file)
@@ -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);
 }