… | |
… | |
155 | isn't finished). |
155 | isn't finished). |
156 | |
156 | |
157 | =item read_size => <bytes> |
157 | =item read_size => <bytes> |
158 | |
158 | |
159 | The default read block size (the amount of bytes this module will try to read |
159 | The default read block size (the amount of bytes this module will try to read |
160 | on each [loop iteration). Default: C<4096>. |
160 | during each (loop iteration). Default: C<8192>. |
161 | |
161 | |
162 | =item low_water_mark => <bytes> |
162 | =item low_water_mark => <bytes> |
163 | |
163 | |
164 | Sets the amount of bytes (default: C<0>) that make up an "empty" write |
164 | Sets the amount of bytes (default: C<0>) that make up an "empty" write |
165 | buffer: If the write reaches this size or gets even samller it is |
165 | buffer: If the write reaches this size or gets even samller it is |
… | |
… | |
238 | } |
238 | } |
239 | |
239 | |
240 | sub _shutdown { |
240 | sub _shutdown { |
241 | my ($self) = @_; |
241 | my ($self) = @_; |
242 | |
242 | |
|
|
243 | delete $self->{_tw}; |
243 | delete $self->{_rw}; |
244 | delete $self->{_rw}; |
244 | delete $self->{_ww}; |
245 | delete $self->{_ww}; |
245 | delete $self->{fh}; |
246 | delete $self->{fh}; |
246 | } |
247 | } |
247 | |
248 | |
… | |
… | |
328 | # now or in the past already? |
329 | # now or in the past already? |
329 | if ($after <= 0) { |
330 | if ($after <= 0) { |
330 | $self->{_activity} = $NOW; |
331 | $self->{_activity} = $NOW; |
331 | |
332 | |
332 | if ($self->{on_timeout}) { |
333 | if ($self->{on_timeout}) { |
333 | $self->{on_timeout}->($self); |
334 | $self->{on_timeout}($self); |
334 | } else { |
335 | } else { |
335 | $! = Errno::ETIMEDOUT; |
336 | $! = Errno::ETIMEDOUT; |
336 | $self->error; |
337 | $self->error; |
337 | } |
338 | } |
338 | |
339 | |
… | |
… | |
444 | @_ = ($WH{$type} or Carp::croak "unsupported type passed to AnyEvent::Handle::push_write") |
445 | @_ = ($WH{$type} or Carp::croak "unsupported type passed to AnyEvent::Handle::push_write") |
445 | ->($self, @_); |
446 | ->($self, @_); |
446 | } |
447 | } |
447 | |
448 | |
448 | if ($self->{filter_w}) { |
449 | if ($self->{filter_w}) { |
449 | $self->{filter_w}->($self, \$_[0]); |
450 | $self->{filter_w}($self, \$_[0]); |
450 | } else { |
451 | } else { |
451 | $self->{wbuf} .= $_[0]; |
452 | $self->{wbuf} .= $_[0]; |
452 | $self->_drain_wbuf; |
453 | $self->_drain_wbuf; |
453 | } |
454 | } |
454 | } |
455 | } |
… | |
… | |
660 | delete $self->{_rw}; |
661 | delete $self->{_rw}; |
661 | return; |
662 | return; |
662 | } |
663 | } |
663 | } |
664 | } |
664 | |
665 | |
665 | if ($self->{_eof}) { |
|
|
666 | $self->_shutdown; |
|
|
667 | $self->{on_eof}($self) |
666 | $self->{on_eof}($self) |
668 | if $self->{on_eof}; |
667 | if $self->{_eof} && $self->{on_eof}; |
669 | } |
|
|
670 | } |
668 | } |
671 | |
669 | |
672 | =item $handle->on_read ($cb) |
670 | =item $handle->on_read ($cb) |
673 | |
671 | |
674 | This replaces the currently set C<on_read> callback, or clears it (when |
672 | This replaces the currently set C<on_read> callback, or clears it (when |
… | |
… | |
1055 | |
1053 | |
1056 | if ($len > 0) { |
1054 | if ($len > 0) { |
1057 | $self->{_activity} = AnyEvent->now; |
1055 | $self->{_activity} = AnyEvent->now; |
1058 | |
1056 | |
1059 | $self->{filter_r} |
1057 | $self->{filter_r} |
1060 | ? $self->{filter_r}->($self, $rbuf) |
1058 | ? $self->{filter_r}($self, $rbuf) |
1061 | : $self->_drain_rbuf; |
1059 | : $self->_drain_rbuf; |
1062 | |
1060 | |
1063 | } elsif (defined $len) { |
1061 | } elsif (defined $len) { |
1064 | delete $self->{_rw}; |
1062 | delete $self->{_rw}; |
1065 | delete $self->{_ww}; |
|
|
1066 | delete $self->{_tw}; |
|
|
1067 | $self->{_eof} = 1; |
1063 | $self->{_eof} = 1; |
1068 | $self->_drain_rbuf; |
1064 | $self->_drain_rbuf; |
1069 | |
1065 | |
1070 | } elsif ($! != EAGAIN && $! != EINTR && $! != WSAEWOULDBLOCK) { |
1066 | } elsif ($! != EAGAIN && $! != EINTR && $! != WSAEWOULDBLOCK) { |
1071 | return $self->error; |
1067 | return $self->error; |