From: Dirk Koopman Date: Tue, 26 Feb 2008 13:12:43 +0000 (+0000) Subject: Fix some problems (on testing) with AGW restarts X-Git-Tag: 1.55~12 X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?p=spider.git;a=commitdiff_plain;h=8655b1a19d9458c7e0d185859a876740e3cda6ad Fix some problems (on testing) with AGW restarts I have got a copy of AGW Packet Engine Pro on windows and tested the code with that. I have also added some commands to enable/disable the AGW connection on the fly. --- diff --git a/cmd/Commands_en.hlp b/cmd/Commands_en.hlp index 4382ba75..fd27ae40 100644 --- a/cmd/Commands_en.hlp +++ b/cmd/Commands_en.hlp @@ -1375,6 +1375,15 @@ message. You can carry on with the message until you are ready to send it. === 0^SET/ADDRESS ^Record your postal address +=== 9^SET/AGWENGINE^Enable the AGW Engine +=== 9^UNSET/AGWENGINE^Disable the AGW Engine +These commands assume that /spider/local/AGWConnect.pm has been setup +correctly and you wish to do some testing or otherwise want to alter +the default state of your connection to the AGW Engine. + +=== 9^SET/AGWMONITOR^Enable Monitoring on the AGW Engine +=== 9^UNSET/AGWMONITOR^Disable Monitoring on the AGW Engine + === 0^SET/ANNOUNCE^Allow announce messages to come out on your terminal === 0^UNSET/ANNOUNCE^Stop announce messages coming out on your terminal diff --git a/cmd/set/agwengine.pl b/cmd/set/agwengine.pl new file mode 100644 index 00000000..6d0fa864 --- /dev/null +++ b/cmd/set/agwengine.pl @@ -0,0 +1,14 @@ +# +# set AGW engine on +# +# +# + +my $self = shift; +return (1, $self->msg('e5')) if $self->priv < 9; +unless ($AGWMsg::enable) { + $AGWMsg::enable = 1; + return (1, $self->msg('agwe')); +} +return (1); + diff --git a/cmd/unset/agwengine.pl b/cmd/unset/agwengine.pl new file mode 100644 index 00000000..1c9e7d71 --- /dev/null +++ b/cmd/unset/agwengine.pl @@ -0,0 +1,14 @@ +# +# set AGW engine off +# +# +# + +my $self = shift; +return (1, $self->msg('e5')) if $self->priv < 9; +if ($AGWMsg::enable) { + AGWMsg::finish() if $AGWMsg::sock; + $AGWMsg::enable = 0; + return (1, $self->msg('agwu')); +} +return (1); diff --git a/perl/AGWMsg.pm b/perl/AGWMsg.pm index 6a364535..c167d994 100644 --- a/perl/AGWMsg.pm +++ b/perl/AGWMsg.pm @@ -46,7 +46,7 @@ $hpolltime = 300 unless defined $hpolltime; %circuit = (); $total_in = $total_out = 0; $lastconnect = 0; -$connectinterval = 30; +$connectinterval = 60; sub init { @@ -56,7 +56,7 @@ sub init finish(); dbg("AGW initialising and connecting to $addr/$port ..."); - $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout=>15); + $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout=>3); $lastconnect = $main::systime; unless ($sock) { dbg("Cannot connect to AGW Engine at $addr/$port $!"); @@ -101,7 +101,9 @@ sub finish Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef); $sock->close; $lastconnect = $main::systime; + $sock = undef; } + $finishing = 0; } sub login @@ -211,9 +213,10 @@ sub _rcv { # Complement to _send } } else { if (Msg::_err_will_block($!)) { - return; + return; } else { - $bytes_read = 0; + _error(); + return; } } @@ -227,14 +230,17 @@ FINISH: sub _error { - dbg("error on AGW connection $addr/$port $!"); + return if $finishing; + $finishing++; + dbg("AGW connection error on $addr/$port $!"); Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef); - $sock = undef; for (%circuit) { &{$_->{eproc}}() if $_->{eproc}; $_->disconnect; } + $sock = undef; $lastconnect = $main::systime; + $finishing = 0; } sub _decode @@ -451,7 +457,7 @@ sub enqueue sub process { # try to reconnect to AGW if we could not previously or there was an error - if ($enable && !$sock && ($lastconnect + $connectinterval) >= $main::systime) { + if ($enable && !$sock && $main::systime >= $lastconnect + $connectinterval) { init(); } return unless $sock; diff --git a/perl/Messages b/perl/Messages index 3b0db325..11c70d52 100644 --- a/perl/Messages +++ b/perl/Messages @@ -10,7 +10,9 @@ package DXM; %msgs = ( en => { addr => 'Address set to: $_[0]', - already => '$_[0] already connected', + agwe => 'AGW Engine enabled', + agwu => 'AGW Engine disabled', + already => '$_[0] already connected', anns => 'Announces enabled for $_[0]', annu => 'Announces disabled for $_[0]', annts => 'AnnTalk enabled for $_[0]', diff --git a/perl/Version.pm b/perl/Version.pm index 1c42dfb0..d179c7ce 100644 --- a/perl/Version.pm +++ b/perl/Version.pm @@ -11,6 +11,6 @@ use vars qw($version $subversion $build); $version = '1.54'; $subversion = '0'; -$build = '207'; +$build = '208'; 1;