projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Retry connection to AGW to every 30 seconds on fail
[spider.git]
/
perl
/
AGWMsg.pm
diff --git
a/perl/AGWMsg.pm
b/perl/AGWMsg.pm
index f6fc50747f9a5fa005099630777770e4cdec2986..6a36453517f048f4b187f04a6dd774bb4152d402 100644
(file)
--- a/
perl/AGWMsg.pm
+++ b/
perl/AGWMsg.pm
@@
-16,7
+16,7
@@
# because I have the 'power of perl' available that avoids me getting
# terminally bored sorting out other people's sloppyness.
#
# because I have the 'power of perl' available that avoids me getting
# terminally bored sorting out other people's sloppyness.
#
-#
$Id$
+#
#
# Copyright (c) 2001 - Dirk Koopman G1TLH
#
#
# Copyright (c) 2001 - Dirk Koopman G1TLH
#
@@
-30,7
+30,8
@@
use AGWConnect;
use DXDebug;
use vars qw(@ISA $sock @outqueue $send_offset $inmsg $rproc $noports $lastytime
use DXDebug;
use vars qw(@ISA $sock @outqueue $send_offset $inmsg $rproc $noports $lastytime
- $lasthtime $ypolltime $hpolltime %circuit $total_in $total_out);
+ $lasthtime $ypolltime $hpolltime %circuit $total_in $total_out
+ $lastconnect $connectinterval);
@ISA = qw(Msg ExtMsg);
$sock = undef;
@ISA = qw(Msg ExtMsg);
$sock = undef;
@@
-44,12
+45,8
@@
$ypolltime = 10 unless defined $ypolltime;
$hpolltime = 300 unless defined $hpolltime;
%circuit = ();
$total_in = $total_out = 0;
$hpolltime = 300 unless defined $hpolltime;
%circuit = ();
$total_in = $total_out = 0;
-
-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;
+$lastconnect = 0;
+$connectinterval = 30;
sub init
{
sub init
{
@@
-57,8
+54,10
@@
sub init
$rproc = shift;
finish();
$rproc = shift;
finish();
+
dbg("AGW initialising and connecting to $addr/$port ...");
$sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout=>15);
dbg("AGW initialising and connecting to $addr/$port ...");
$sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout=>15);
+ $lastconnect = $main::systime;
unless ($sock) {
dbg("Cannot connect to AGW Engine at $addr/$port $!");
return;
unless ($sock) {
dbg("Cannot connect to AGW Engine at $addr/$port $!");
return;
@@
-101,9
+100,15
@@
sub finish
Msg->sleep(2);
Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef);
$sock->close;
Msg->sleep(2);
Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef);
$sock->close;
+ $lastconnect = $main::systime;
}
}
}
}
+sub login
+{
+ goto &main::login; # save some writing, this was the default
+}
+
sub active
{
return $sock;
sub active
{
return $sock;
@@
-229,6
+234,7
@@
sub _error
&{$_->{eproc}}() if $_->{eproc};
$_->disconnect;
}
&{$_->{eproc}}() if $_->{eproc};
$_->disconnect;
}
+ $lastconnect = $main::systime;
}
sub _decode
}
sub _decode
@@
-444,7
+450,12
@@
sub enqueue
sub process
{
sub process
{
+ # try to reconnect to AGW if we could not previously or there was an error
+ if ($enable && !$sock && ($lastconnect + $connectinterval) >= $main::systime) {
+ init();
+ }
return unless $sock;
return unless $sock;
+
if ($ypolltime && $main::systime - $lastytime >= $ypolltime) {
for (my $i = 0; $i < $noports; $i++) {
_sendf('y', undef, undef, $i );
if ($ypolltime && $main::systime - $lastytime >= $ypolltime) {
for (my $i = 0; $i < $noports; $i++) {
_sendf('y', undef, undef, $i );