#
# Copyright (c) 1998-2000 - Dirk Koopman G1TLH
#
-# $Id$
+#
#
package DXChannel;
use Route;
use strict;
-use vars qw(%channels %valid @ISA $count);
+use vars qw(%channels %valid @ISA $count $maxerrors);
%channels = ();
$count = 0;
lastmsgpoll => '0,Last Msg Poll,atime',
inscript => '9,In a script,yesno',
handle_xml => '9,Handles XML,yesno',
+ do_pc9x => '9,Handles PC9x,yesno',
inqueue => '9,Input Queue,parray',
+ next_pc92_update => '9,Next PC92 Update,atime',
+ next_pc92_keepalive => '9,Next PC92 KeepAlive,atime',
);
-use vars qw($VERSION $BRANCH);
-$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
-$BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/ || (0,0));
-$main::build += $VERSION;
-$main::branch += $BRANCH;
+$maxerrors = 20; # the maximum number of concurrent errors allowed before disconnection
# object destruction
sub DESTROY
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
{
my @lines = split /\n/;
for (@lines) {
$conn->send_now("$sort$call|$_");
- dbg("-> $sort $call $_") if isdbg('chan');
+ # debug log it, but not if it is a log message
+ dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
}
}
$self->{t} = time;
my @lines = split /\n/;
for (@lines) {
$conn->send_later("$sort$call|$_");
- dbg("-> $sort $call $_") if isdbg('chan');
+ # debug log it, but not if it is a log message
+ dbg("-> $sort $call $_") if $sort ne 'L' && isdbg('chan');
}
}
$self->{t} = time;
my $user = $self->{user};
$user->close() if defined $user;
- $self->{conn}->disconnect;
+ $self->{conn}->disconnect if $self->{conn};
$self->del();
}
return ($sort, $call, $line);
}
-sub rspfcheck
-{
- my ($self, $flag, $node, $user) = @_;
- my $nref = Route::Node::get($node);
- my $dxchan = $nref->dxchan if $nref;
- if ($nref && $dxchan) {
- if ($dxchan == $self) {
- return 1 unless $user;
- return 1 if $user eq $node;
- my @users = $nref->users;
- return 1 if @users == 0 || grep $user eq $_, @users;
- dbg("RSPF: $user not on $node") if isdbg('chanerr');
- } else {
- dbg("RSPF: Shortest path for $node is " . $nref->dxchan->{call}) if isdbg('chanerr');
- }
- } else {
- return 1 if $flag;
- dbg("RSPF: required $node not found" ) if isdbg('chanerr');
- }
- return 0;
-}
-
# broadcast a message to all clusters taking into account isolation
# [except those mentioned after buffer]
sub broadcast_nodes