X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FMsg.pm;h=4bc31faddfcf92546427549c4a0f81d5e39f45c8;hb=bbc51ffb416a39a421b6054d1cb57af330ab68f1;hp=ea2747dc1f158de86ca15512eb8506814495ea0e;hpb=38aa5af305ed46fcf56f4624eb6bac29afaccda5;p=spider.git diff --git a/perl/Msg.pm b/perl/Msg.pm index ea2747dc..4bc31fad 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -123,7 +123,9 @@ sub connect { # Create a connection end-point object my $conn = $pkg; - $conn = $pkg->new($rproc); + unless (ref $pkg) { + $conn = $pkg->new($rproc); + } $conn->{peerhost} = $to_host; $conn->{peerport} = $to_port; $conn->{sort} = 'Outgoing'; @@ -225,6 +227,7 @@ sub disconnect } if (defined($sock)) { + shutdown($sock->{fh}, 2); $sock->destroy; } @@ -242,14 +245,18 @@ sub _send_stuff while (@$rq) { my $data = shift @$rq; my $lth = length $data; + my $call = $conn->{call} || 'none'; if (isdbg('raw')) { - my $call = $conn->{call} || 'none'; if (isdbg('raw')) { dbgdump('raw', "$call send $lth: ", $lth); } } - $sock->push_write($data); - $total_out = $lth; + if (defined $sock && !$sock->destroyed) { + $sock->push_write($data); + $total_out = $lth; + } else { + dbg("_send_stuff $call ending data ignored: $data"); + } } } @@ -285,7 +292,7 @@ sub _err_will_block { sub close_on_empty { my $conn = shift; - $conn->{sock}->push_shutdown; + $conn->{sock}->on_drain(sub {$conn->disconnect;}); } #-----------------------------------------------------------------