ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/lib/AnyEvent/Handle.pm
(Generate patch)

Comparing AnyEvent/lib/AnyEvent/Handle.pm (file contents):
Revision 1.36 by root, Mon May 26 18:26:52 2008 UTC vs.
Revision 1.37 by root, Mon May 26 20:02:22 2008 UTC

93called. 93called.
94 94
95On callback entrance, the value of C<$!> contains the operating system 95On callback entrance, the value of C<$!> contains the operating system
96error (or C<ENOSPC>, C<EPIPE> or C<EBADMSG>). 96error (or C<ENOSPC>, C<EPIPE> or C<EBADMSG>).
97 97
98The callbakc should throw an exception. If it returns, then
99AnyEvent::Handle will C<croak> for you.
100
98While not mandatory, it is I<highly> recommended to set this callback, as 101While not mandatory, it is I<highly> recommended to set this callback, as
99you will not be notified of errors otherwise. The default simply calls 102you will not be notified of errors otherwise. The default simply calls
100die. 103die.
101 104
102=item on_read => $cb->($self) 105=item on_read => $cb->($self)
209 { 212 {
210 local $!; 213 local $!;
211 $self->_shutdown; 214 $self->_shutdown;
212 } 215 }
213 216
214 if ($self->{on_error}) {
215 $self->{on_error}($self); 217 $self->{on_error}($self)
216 } else { 218 if $self->{on_error};
219
217 Carp::croak "AnyEvent::Handle uncaught fatal error: $!"; 220 Carp::croak "AnyEvent::Handle uncaught fatal error: $!";
218 }
219} 221}
220 222
221=item $fh = $handle->fh 223=item $fh = $handle->fh
222 224
223This method returns the file handle of the L<AnyEvent::Handle> object. 225This method returns the file handle of the L<AnyEvent::Handle> object.
469 471
470 if ( 472 if (
471 defined $self->{rbuf_max} 473 defined $self->{rbuf_max}
472 && $self->{rbuf_max} < length $self->{rbuf} 474 && $self->{rbuf_max} < length $self->{rbuf}
473 ) { 475 ) {
474 $! = &Errno::ENOSPC; return $self->error; 476 $! = &Errno::ENOSPC;
477 $self->error;
475 } 478 }
476 479
477 return if $self->{in_drain}; 480 return if $self->{in_drain};
478 local $self->{in_drain} = 1; 481 local $self->{in_drain} = 1;
479 482
481 no strict 'refs'; 484 no strict 'refs';
482 if (my $cb = shift @{ $self->{queue} }) { 485 if (my $cb = shift @{ $self->{queue} }) {
483 unless ($cb->($self)) { 486 unless ($cb->($self)) {
484 if ($self->{eof}) { 487 if ($self->{eof}) {
485 # no progress can be made (not enough data and no data forthcoming) 488 # no progress can be made (not enough data and no data forthcoming)
486 $! = &Errno::EPIPE; return $self->error; 489 $! = &Errno::EPIPE;
490 $self->error;
487 } 491 }
488 492
489 unshift @{ $self->{queue} }, $cb; 493 unshift @{ $self->{queue} }, $cb;
490 return; 494 return;
491 } 495 }
497 && $len == length $self->{rbuf} # and no data has been consumed 501 && $len == length $self->{rbuf} # and no data has been consumed
498 && !@{ $self->{queue} } # and the queue is still empty 502 && !@{ $self->{queue} } # and the queue is still empty
499 && $self->{on_read} # and we still want to read data 503 && $self->{on_read} # and we still want to read data
500 ) { 504 ) {
501 # then no progress can be made 505 # then no progress can be made
502 $! = &Errno::EPIPE; return $self->error; 506 $! = &Errno::EPIPE;
507 $self->error;
503 } 508 }
504 } else { 509 } else {
505 # read side becomes idle 510 # read side becomes idle
506 delete $self->{rw}; 511 delete $self->{rw};
507 return; 512 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines