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.242 by root, Wed Dec 10 04:29:33 2014 UTC vs.
Revision 1.244 by root, Wed Apr 1 19:59:01 2015 UTC

53package AnyEvent::Handle; 53package AnyEvent::Handle;
54 54
55use Scalar::Util (); 55use Scalar::Util ();
56use List::Util (); 56use List::Util ();
57use Carp (); 57use Carp ();
58use Errno qw(EAGAIN EINTR); 58use Errno qw(EAGAIN EWOULDBLOCK EINTR);
59 59
60use AnyEvent (); BEGIN { AnyEvent::common_sense } 60use AnyEvent (); BEGIN { AnyEvent::common_sense }
61use AnyEvent::Util qw(WSAEWOULDBLOCK); 61use AnyEvent::Util qw(WSAEWOULDBLOCK);
62 62
63our $VERSION = $AnyEvent::VERSION; 63our $VERSION = $AnyEvent::VERSION;
971 $self->{on_drain}($self) 971 $self->{on_drain}($self)
972 if $self->{low_water_mark} >= (length $self->{wbuf}) + (length $self->{_tls_wbuf}) 972 if $self->{low_water_mark} >= (length $self->{wbuf}) + (length $self->{_tls_wbuf})
973 && $self->{on_drain}; 973 && $self->{on_drain};
974 974
975 delete $self->{_ww} unless length $self->{wbuf}; 975 delete $self->{_ww} unless length $self->{wbuf};
976 } elsif ($! != EAGAIN && $! != EINTR && $! != WSAEWOULDBLOCK) { 976 } elsif ($! != EAGAIN && $! != EINTR && $! != EWOULDBLOCK && $! != WSAEWOULDBLOCK) {
977 $self->_error ($!, 1); 977 $self->_error ($!, 1);
978 } 978 }
979 }; 979 };
980 980
981 # try to write data immediately 981 # try to write data immediately
1570}; 1570};
1571 1571
1572=item regex => $accept[, $reject[, $skip], $cb->($handle, $data) 1572=item regex => $accept[, $reject[, $skip], $cb->($handle, $data)
1573 1573
1574Makes a regex match against the regex object C<$accept> and returns 1574Makes a regex match against the regex object C<$accept> and returns
1575everything up to and including the match. 1575everything up to and including the match. All the usual regex variables
1576($1, %+ etc.) from the regex match are available in the callback.
1576 1577
1577Example: read a single line terminated by '\n'. 1578Example: read a single line terminated by '\n'.
1578 1579
1579 $handle->push_read (regex => qr<\n>, sub { ... }); 1580 $handle->push_read (regex => qr<\n>, sub { ... });
1580 1581
2038 } elsif (defined $len) { 2039 } elsif (defined $len) {
2039 delete $self->{_rw}; 2040 delete $self->{_rw};
2040 $self->{_eof} = 1; 2041 $self->{_eof} = 1;
2041 $self->_drain_rbuf; 2042 $self->_drain_rbuf;
2042 2043
2043 } elsif ($! != EAGAIN && $! != EINTR && $! != WSAEWOULDBLOCK) { 2044 } elsif ($! != EAGAIN && $! != EINTR && $! != EWOULDBLOCK && $! != WSAEWOULDBLOCK) {
2044 return $self->_error ($!, 1); 2045 return $self->_error ($!, 1);
2045 } 2046 }
2046 }; 2047 };
2047 } 2048 }
2048} 2049}
2304 push @linger, AE::io $fh, 1, sub { 2305 push @linger, AE::io $fh, 1, sub {
2305 my $len = syswrite $fh, $wbuf, length $wbuf; 2306 my $len = syswrite $fh, $wbuf, length $wbuf;
2306 2307
2307 if ($len > 0) { 2308 if ($len > 0) {
2308 substr $wbuf, 0, $len, ""; 2309 substr $wbuf, 0, $len, "";
2309 } elsif (defined $len || ($! != EAGAIN && $! != EINTR && $! != WSAEWOULDBLOCK)) { 2310 } elsif (defined $len || ($! != EAGAIN && $! != EINTR && $! != EWOULDBLOCK && $! != WSAEWOULDBLOCK)) {
2310 @linger = (); # end 2311 @linger = (); # end
2311 } 2312 }
2312 }; 2313 };
2313 push @linger, AE::timer $linger, 0, sub { 2314 push @linger, AE::timer $linger, 0, sub {
2314 @linger = (); 2315 @linger = ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines