… | |
… | |
53 | package AnyEvent::Handle; |
53 | package AnyEvent::Handle; |
54 | |
54 | |
55 | use Scalar::Util (); |
55 | use Scalar::Util (); |
56 | use List::Util (); |
56 | use List::Util (); |
57 | use Carp (); |
57 | use Carp (); |
58 | use Errno qw(EAGAIN EINTR); |
58 | use Errno qw(EAGAIN EWOULDBLOCK EINTR); |
59 | |
59 | |
60 | use AnyEvent (); BEGIN { AnyEvent::common_sense } |
60 | use AnyEvent (); BEGIN { AnyEvent::common_sense } |
61 | use AnyEvent::Util qw(WSAEWOULDBLOCK); |
61 | use AnyEvent::Util qw(WSAEWOULDBLOCK); |
62 | |
62 | |
63 | our $VERSION = $AnyEvent::VERSION; |
63 | our $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 |
… | |
… | |
2038 | } elsif (defined $len) { |
2038 | } elsif (defined $len) { |
2039 | delete $self->{_rw}; |
2039 | delete $self->{_rw}; |
2040 | $self->{_eof} = 1; |
2040 | $self->{_eof} = 1; |
2041 | $self->_drain_rbuf; |
2041 | $self->_drain_rbuf; |
2042 | |
2042 | |
2043 | } elsif ($! != EAGAIN && $! != EINTR && $! != WSAEWOULDBLOCK) { |
2043 | } elsif ($! != EAGAIN && $! != EINTR && $! != EWOULDBLOCK && $! != WSAEWOULDBLOCK) { |
2044 | return $self->_error ($!, 1); |
2044 | return $self->_error ($!, 1); |
2045 | } |
2045 | } |
2046 | }; |
2046 | }; |
2047 | } |
2047 | } |
2048 | } |
2048 | } |
… | |
… | |
2304 | push @linger, AE::io $fh, 1, sub { |
2304 | push @linger, AE::io $fh, 1, sub { |
2305 | my $len = syswrite $fh, $wbuf, length $wbuf; |
2305 | my $len = syswrite $fh, $wbuf, length $wbuf; |
2306 | |
2306 | |
2307 | if ($len > 0) { |
2307 | if ($len > 0) { |
2308 | substr $wbuf, 0, $len, ""; |
2308 | substr $wbuf, 0, $len, ""; |
2309 | } elsif (defined $len || ($! != EAGAIN && $! != EINTR && $! != WSAEWOULDBLOCK)) { |
2309 | } elsif (defined $len || ($! != EAGAIN && $! != EINTR && $! != EWOULDBLOCK && $! != WSAEWOULDBLOCK)) { |
2310 | @linger = (); # end |
2310 | @linger = (); # end |
2311 | } |
2311 | } |
2312 | }; |
2312 | }; |
2313 | push @linger, AE::timer $linger, 0, sub { |
2313 | push @linger, AE::timer $linger, 0, sub { |
2314 | @linger = (); |
2314 | @linger = (); |