X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FDXChannel.pm;h=fcc230aa324b25238535084697d473b1cfdf60a1;hb=82aac01bdf511916e98a71873950fb98a54440a0;hp=7d340a6165f5cfde293b725b28efea2edf9c95b7;hpb=2f2314177644005283f6750f40b38233303446b8;p=spider.git diff --git a/perl/DXChannel.pm b/perl/DXChannel.pm index 7d340a61..fcc230aa 100644 --- a/perl/DXChannel.pm +++ b/perl/DXChannel.pm @@ -35,7 +35,7 @@ use Prefix; use Route; use strict; -use vars qw(%channels %valid @ISA $count); +use vars qw(%channels %valid @ISA $count $maxerrors); %channels = (); $count = 0; @@ -125,6 +125,8 @@ $count = 0; next_pc92_keepalive => '9,Next PC92 KeepAlive,atime', ); +$maxerrors = 20; # the maximum number of concurrent errors allowed before disconnection + # object destruction sub DESTROY { @@ -177,6 +179,22 @@ sub alloc return $channels{$call} = $self; } +# count errors and disconnect if too many +# this has to be here because it can come from rcmd (DXProt) as +# well as DXCommandmode. +sub _error_out +{ + my $self = shift; + my $e = shift; + if (++$self->{errors} > $maxerrors) { + $self->send($self->msg('e26')); + $self->disconnect; + return (); + } else { + return ($self->msg($e)); + } +} + # rebless this channel as something else sub rebless {