… | |
… | |
2 | |
2 | |
3 | no warnings; |
3 | no warnings; |
4 | use strict; |
4 | use strict; |
5 | |
5 | |
6 | use AnyEvent (); |
6 | use AnyEvent (); |
7 | use AnyEvent::Util (); |
7 | use AnyEvent::Util qw(WSAWOULDBLOCK); |
8 | use Scalar::Util (); |
8 | use Scalar::Util (); |
9 | use Carp (); |
9 | use Carp (); |
10 | use Fcntl (); |
10 | use Fcntl (); |
11 | use Errno qw/EAGAIN EINTR/; |
11 | use Errno qw/EAGAIN EINTR/; |
12 | |
12 | |
… | |
… | |
301 | $self->{on_drain}($self) |
301 | $self->{on_drain}($self) |
302 | if $self->{low_water_mark} >= length $self->{wbuf} |
302 | if $self->{low_water_mark} >= length $self->{wbuf} |
303 | && $self->{on_drain}; |
303 | && $self->{on_drain}; |
304 | |
304 | |
305 | delete $self->{ww} unless length $self->{wbuf}; |
305 | delete $self->{ww} unless length $self->{wbuf}; |
306 | } elsif ($! != EAGAIN && $! != EINTR) { |
306 | } elsif ($! != EAGAIN && $! != EINTR && $! != WSAWOULDBLOCK) { |
307 | $self->error; |
307 | $self->error; |
308 | } |
308 | } |
309 | }; |
309 | }; |
310 | |
310 | |
311 | $self->{ww} = AnyEvent->io (fh => $self->{fh}, poll => "w", cb => $cb); |
311 | $self->{ww} = AnyEvent->io (fh => $self->{fh}, poll => "w", cb => $cb); |
… | |
… | |
787 | } elsif (defined $len) { |
787 | } elsif (defined $len) { |
788 | delete $self->{rw}; |
788 | delete $self->{rw}; |
789 | $self->{eof} = 1; |
789 | $self->{eof} = 1; |
790 | $self->_drain_rbuf; |
790 | $self->_drain_rbuf; |
791 | |
791 | |
792 | } elsif ($! != EAGAIN && $! != EINTR) { |
792 | } elsif ($! != EAGAIN && $! != EINTR && $! != &AnyEvent::Util::WSAWOULDBLOCK) { |
793 | return $self->error; |
793 | return $self->error; |
794 | } |
794 | } |
795 | }); |
795 | }); |
796 | } |
796 | } |
797 | } |
797 | } |
… | |
… | |
863 | # but the openssl maintainers basically said: "trust us, it just works". |
863 | # but the openssl maintainers basically said: "trust us, it just works". |
864 | # (unfortunately, we have to hardcode constants because the abysmally misdesigned |
864 | # (unfortunately, we have to hardcode constants because the abysmally misdesigned |
865 | # and mismaintained ssleay-module doesn't even offer them). |
865 | # and mismaintained ssleay-module doesn't even offer them). |
866 | # http://www.mail-archive.com/openssl-dev@openssl.org/msg22420.html |
866 | # http://www.mail-archive.com/openssl-dev@openssl.org/msg22420.html |
867 | Net::SSLeay::CTX_set_mode ($self->{tls}, |
867 | Net::SSLeay::CTX_set_mode ($self->{tls}, |
868 | (eval { Net::SSLeay::MODE_ENABLE_PARTIAL_WRITE () } || 1) |
868 | (eval { local $SIG{__DIE__}; Net::SSLeay::MODE_ENABLE_PARTIAL_WRITE () } || 1) |
869 | | (eval { Net::SSLeay::MODE_ACCEPT_MOVING_WRITE_BUFFER () } || 2)); |
869 | | (eval { local $SIG{__DIE__}; Net::SSLeay::MODE_ACCEPT_MOVING_WRITE_BUFFER () } || 2)); |
870 | |
870 | |
871 | $self->{tls_rbio} = Net::SSLeay::BIO_new (Net::SSLeay::BIO_s_mem ()); |
871 | $self->{tls_rbio} = Net::SSLeay::BIO_new (Net::SSLeay::BIO_s_mem ()); |
872 | $self->{tls_wbio} = Net::SSLeay::BIO_new (Net::SSLeay::BIO_s_mem ()); |
872 | $self->{tls_wbio} = Net::SSLeay::BIO_new (Net::SSLeay::BIO_s_mem ()); |
873 | |
873 | |
874 | Net::SSLeay::set_bio ($ssl, $self->{tls_rbio}, $self->{tls_wbio}); |
874 | Net::SSLeay::set_bio ($ssl, $self->{tls_rbio}, $self->{tls_wbio}); |