X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FMsg.pm;h=8be2fc1bf071d39dd464907de8397da7fdd27891;hb=d7a259b56406b17ce5179aac85a3b1f07664147d;hp=3b96c812e502b51b16f5b6a493cbae14aa3e4822;hpb=6374fb31da62987e676244c38eb6cf73c81bf891;p=spider.git diff --git a/perl/Msg.pm b/perl/Msg.pm index 3b96c812..8be2fc1b 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -287,13 +287,11 @@ sub _send { delete $conn->{send_offset}; $offset = 0; shift @$rq; - last unless $flush; # Go back to select and wait + #last unless $flush; # Go back to select and wait # for it to fire again. } # Call me back if queue has not been drained. - if (@$rq) { - set_event_handler ($sock, write => sub {$conn->_send(0)}); - } else { + unless (@$rq) { set_event_handler ($sock, write => undef); if (exists $conn->{close_on_empty}) { &{$conn->{eproc}}($conn, undef) if exists $conn->{eproc}; @@ -400,7 +398,9 @@ FINISH: &{$conn->{eproc}}($conn, $!) if exists $conn->{eproc}; $conn->disconnect; } else { - $conn->dequeue if exists $conn->{msg}; + unless ($conn->{disable_read}) { + $conn->dequeue if exists $conn->{msg}; + } } } @@ -446,6 +446,13 @@ sub close_all_clients } } +sub disable_read +{ + my $conn = shift; + set_event_handler ($conn->{sock}, read => undef); + return $_[0] ? $conn->{disable_read} = $_[0] : $_[0]; +} + # #---------------------------------------------------- # Event loop routines used by both client and server