X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FAGWMsg.pm;h=41f23702abd7ab5b79ea6fcd1fa82012867c89ca;hb=59e9f019432790d60afcbc96e490375e6a544dbc;hp=faa280dc7f9d2cbd2b741d47394a07009b80de36;hpb=10b36ab14f4ecabed9137b190274e3e3f7fb0212;p=spider.git diff --git a/perl/AGWMsg.pm b/perl/AGWMsg.pm index faa280dc..41f23702 100644 --- a/perl/AGWMsg.pm +++ b/perl/AGWMsg.pm @@ -51,7 +51,7 @@ sub init finish(); dbg('err', "AGW initialising and connecting to $addr/$port ..."); - $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout => 30); + $sock = IO::Socket::INET->new(PeerAddr => $addr, PeerPort => $port, Proto=>'tcp', Timeout=>15); unless ($sock) { dbg('err', "Cannot connect to AGW Engine at $addr/$port $!"); return; @@ -85,6 +85,7 @@ sub finish $finishing = 1; dbg('err', "AGW ending..."); for (values %circuit) { + &{$_->{eproc}}() if $_->{eproc}; $_->disconnect; } # say we are going @@ -156,6 +157,9 @@ sub _send return 0; # fail. Message remains in queue .. } } + if (isdbg('raw')) { + dbgdump('raw', "send $bytes_written: ", $msg); + } $offset += $bytes_written; $bytes_to_write -= $bytes_written; } @@ -182,6 +186,9 @@ sub _rcv { # Complement to _send if (defined ($bytes_read)) { if ($bytes_read > 0) { $inmsg .= $msg; + if (isdbg('raw')) { + dbgdump('raw', "read $bytes_read: ", $msg); + } } } else { if (Msg::_err_will_block($!)) { @@ -195,7 +202,7 @@ FINISH: if (defined $bytes_read && $bytes_read == 0) { finish(); } else { - _decode() if length $inmsg > 36; + _decode() if length $inmsg >= 36; } } @@ -205,7 +212,7 @@ sub _error Msg::set_event_handler($sock, read=>undef, write=>undef, error=>undef); $sock = undef; for (%circuit) { - next unless $_->isa('AGWMsg'); + &{$_->{eproc}}() if $_->{eproc}; $_->disconnect; } } @@ -319,7 +326,10 @@ sub _decode } elsif ($sort eq 'd') { dbg('agw', "AGW '$from'->'$to' port: $port Disconnected"); my $conn = _find($from eq $main::mycall ? $to : $from); - $conn->in_disconnect if $conn; + if ($conn) { + &{$conn->{eproc}}() if $conn->{eproc}; + $conn->in_disconnect; + } } elsif ($sort eq 'y') { my ($frames) = unpack "V", $data; dbg('agwpollans', "AGW Frames Outstanding on port $port = $frames"); @@ -354,7 +364,8 @@ sub _decode dbg('agw', "AGW Port: $_"); } for (my $i = 0; $i < $noports; $i++) { - _sendf('y', undef, undef, $i ); + _sendf('y', undef, undef, $i); + _sendf('g', undef, undef, $i); } } else { my $d = unpack "Z*", $data; @@ -391,7 +402,6 @@ sub in_disconnect { my $conn = shift; delete $circuit{$conn->{agwcall}}; - _sendf('d', $conn->{agwcall}, $main::mycall, $conn->{agwport}, $conn->{agwpid}); $conn->SUPER::disconnect; } @@ -414,6 +424,8 @@ sub enqueue $msg =~ s/^[-\w]+\|//; # _sendf('Y', $main::mycall, $conn->{call}, $conn->{agwport}, $conn->{agwpid}); _sendf('D', $main::mycall, $conn->{agwcall}, $conn->{agwport}, $conn->{agwpid}, $msg . $conn->{lineend}); + my $len = length($msg) + 1; + dbg('agw', "AGW Data Out port: $conn->{agwport} pid: $conn->{agwpid} '$main::mycall'->'$conn->{agwcall}' length: $len \"$msg\""); } }