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.54 by root, Tue Jun 3 09:02:46 2008 UTC vs.
Revision 1.55 by root, Tue Jun 3 16:15:30 2008 UTC

639 # no progress can be made (not enough data and no data forthcoming) 639 # no progress can be made (not enough data and no data forthcoming)
640 return $self->_error (&Errno::EPIPE, 1); 640 return $self->_error (&Errno::EPIPE, 1);
641 } 641 }
642 642
643 unshift @{ $self->{_queue} }, $cb; 643 unshift @{ $self->{_queue} }, $cb;
644 return; 644 last;
645 } 645 }
646 } elsif ($self->{on_read}) { 646 } elsif ($self->{on_read}) {
647 $self->{on_read}($self); 647 $self->{on_read}($self);
648 648
649 if ( 649 if (
650 $self->{_eof} # if no further data will arrive
651 && $len == length $self->{rbuf} # and no data has been consumed 650 $len == length $self->{rbuf} # if no data has been consumed
652 && !@{ $self->{_queue} } # and the queue is still empty 651 && !@{ $self->{_queue} } # and the queue is still empty
653 && $self->{on_read} # and we still want to read data 652 && $self->{on_read} # but we still have on_read
654 ) { 653 ) {
654 # no further data will arrive
655 # then no progress can be made 655 # so no progress can be made
656 return $self->_error (&Errno::EPIPE, 1); 656 return $self->_error (&Errno::EPIPE, 1)
657 if $self->{_eof};
658
659 last; # more data might arrive
657 } 660 }
658 } else { 661 } else {
659 # read side becomes idle 662 # read side becomes idle
660 delete $self->{_rw}; 663 delete $self->{_rw};
661 return; 664 last;
662 } 665 }
663 } 666 }
664 667
665 $self->{on_eof}($self) 668 $self->{on_eof}($self)
666 if $self->{_eof} && $self->{on_eof}; 669 if $self->{_eof} && $self->{on_eof};
670
671 # may need to restart read watcher
672 unless ($self->{_rw}) {
673 $self->start_read
674 if $self->{on_read} || @{ $self->{_queue} };
675 }
667} 676}
668 677
669=item $handle->on_read ($cb) 678=item $handle->on_read ($cb)
670 679
671This replaces the currently set C<on_read> callback, or clears it (when 680This replaces the currently set C<on_read> callback, or clears it (when

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines