Hi,
I traced this to lines 782-785 of AnyEvent::Handle 4.34
if ($self->{_eof}) {
# no progress can be made (not enough data and no data
forthcoming)
$self->_error (&Errno::EPIPE, 1), return;
}
I went back to the documentation and found this on the on_read callback:
When an EOF condition is detected then AnyEvent::Handle will first try
to feed all the remaining data to the queued callbacks and on_read
before calling the on_eof callback. If no progress can be made, then a
fatal error will be raised (with $! set to EPIPE).
It explains the behavior I'm seeing. Maybe the synopsis should include
an on_error also?
Best regards,
On Mar 7, 2009, at 6:26 PM, Pedro Melo wrote:
Hi,
Sorry to reply to myself, forgot to mention that if we replace
on_eof with on_error it works fine.
Best regards,
On Mar 7, 2009, at 6:25 PM, Pedro Melo wrote:
Hi,
I'm trying to understand how on_eof works in AnyEvent::Handle. I
copied the example in the synopsis and added a couple or print
statements. The code I'm using to test this is at the end of the
message.
On both Linux (CentOS 4.6 Final) and Mac OS X 10.5.6, I get a
strange behaviour. If I do this:
touch aa
./ae_handle_example.pl < a
the script never ends. I assumed that the on_eof would be triggered
and the $cv->send executed, but it never is.
What am I missing? The MODEL I'm using is AnyEvent::Impl::EV.
Thanks in advance,
---- 8< ----
use AnyEvent;
use AnyEvent::Handle;
my $cv = AnyEvent->condvar;
print "Using $AnyEvent::MODEL\n";
my $handle =
AnyEvent::Handle->new (
fh => \*STDIN,
on_eof => sub {
print "!! EOF\n";
$cv->send;
},
);
# send some request line
$handle->push_write ("getinfo\015\012");
# read the response line
$handle->push_read (line => sub {
my ($handle, $line) = @_;
warn "read line <$line>\n";
$cv->send;
});
$cv->recv;
---- 8< ----
--
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: [email protected]
Use XMPP!
--
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: [email protected]
Use XMPP!
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
--
Pedro Melo
Blog: http://www.simplicidade.org/notes/
XMPP ID: [email protected]
Use XMPP!
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev