Apparently they happen (triggered by my -imapd instance), so
bail out by closing the underlying socket rather than stopping
the event loop and daemon process.
(cherry picked from commit
c51c22c349529d9c377160abcc7961a6ca7b7d5c)
goto next_buf;
}
} elsif ($! == EAGAIN) {
goto next_buf;
}
} elsif ($! == EAGAIN) {
- epwait($sock, epbit($sock, EPOLLOUT) | EPOLLONESHOT);
+ my $ev = epbit($sock, EPOLLOUT) or return $self->close;
+ epwait($sock, $ev | EPOLLONESHOT);
return 0;
} else {
return $self->close;
return 0;
} else {
return $self->close;
# common for clients to break connections without warning,
# would be too noisy to log here:
if ($! == EAGAIN) {
# common for clients to break connections without warning,
# would be too noisy to log here:
if ($! == EAGAIN) {
- epwait($sock, epbit($sock, EPOLLIN) | EPOLLONESHOT);
+ my $ev = epbit($sock, EPOLLIN) or return $self->close;
+ epwait($sock, $ev | EPOLLONESHOT);
rbuf_idle($self, $rbuf);
0;
} else {
rbuf_idle($self, $rbuf);
0;
} else {
return 1 if $written == $to_write;
requeue($self); # runs: event_step -> flush_write
} elsif ($! == EAGAIN) {
return 1 if $written == $to_write;
requeue($self); # runs: event_step -> flush_write
} elsif ($! == EAGAIN) {
- epwait($sock, epbit($sock, EPOLLOUT) | EPOLLONESHOT);
+ my $ev = epbit($sock, EPOLLOUT) or return $self->close;
+ epwait($sock, $ev | EPOLLONESHOT);
$written = 0;
} else {
return $self->close;
$written = 0;
} else {
return $self->close;
my $sock = $self->{sock} or return;
return 1 if $sock->accept_SSL;
return $self->close if $! != EAGAIN;
my $sock = $self->{sock} or return;
return 1 if $sock->accept_SSL;
return $self->close if $! != EAGAIN;
- epwait($sock, PublicInbox::TLS::epollbit() | EPOLLONESHOT);
+ my $ev = PublicInbox::TLS::epollbit() or return $self->close;
+ epwait($sock, $ev | EPOLLONESHOT);
unshift(@{$self->{wbuf}}, \&accept_tls_step); # autovivifies
0;
}
unshift(@{$self->{wbuf}}, \&accept_tls_step); # autovivifies
0;
}
my $sock = $self->{sock} or return;
return $self->close if $sock->stop_SSL(SSL_fast_shutdown => 1);
return $self->close if $! != EAGAIN;
my $sock = $self->{sock} or return;
return $self->close if $sock->stop_SSL(SSL_fast_shutdown => 1);
return $self->close if $! != EAGAIN;
- epwait($sock, PublicInbox::TLS::epollbit() | EPOLLONESHOT);
+ my $ev = PublicInbox::TLS::epollbit() or return $self->close;
+ epwait($sock, $ev | EPOLLONESHOT);
unshift(@{$self->{wbuf}}, \&shutdn_tls_step); # autovivifies
0;
}
unshift(@{$self->{wbuf}}, \&shutdn_tls_step); # autovivifies
0;
}
my $wbuf;
if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
return CORE::close($sock) if $! != EAGAIN;
my $wbuf;
if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
return CORE::close($sock) if $! != EAGAIN;
- $ev = PublicInbox::TLS::epollbit();
+ $ev = PublicInbox::TLS::epollbit() or return CORE::close($sock);
$wbuf = [ \&PublicInbox::DS::accept_tls_step ];
}
$self->{wbuf} = $wbuf if $wbuf;
$wbuf = [ \&PublicInbox::DS::accept_tls_step ];
}
$self->{wbuf} = $wbuf if $wbuf;
my $wbuf;
if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
return CORE::close($sock) if $! != EAGAIN;
my $wbuf;
if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
return CORE::close($sock) if $! != EAGAIN;
- $ev = PublicInbox::TLS::epollbit();
+ $ev = PublicInbox::TLS::epollbit() or return CORE::close($sock);
$wbuf = [ \&PublicInbox::DS::accept_tls_step, \&greet ];
}
$self->SUPER::new($sock, $ev | EPOLLONESHOT);
$wbuf = [ \&PublicInbox::DS::accept_tls_step, \&greet ];
}
$self->SUPER::new($sock, $ev | EPOLLONESHOT);
my $wbuf;
if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
return CORE::close($sock) if $! != EAGAIN;
my $wbuf;
if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
return CORE::close($sock) if $! != EAGAIN;
- $ev = PublicInbox::TLS::epollbit();
+ $ev = PublicInbox::TLS::epollbit() or return CORE::close($sock);
$wbuf = [ \&PublicInbox::DS::accept_tls_step, \&greet ];
}
$self->SUPER::new($sock, $ev | EPOLLONESHOT);
$wbuf = [ \&PublicInbox::DS::accept_tls_step, \&greet ];
}
$self->SUPER::new($sock, $ev | EPOLLONESHOT);
use strict;
use IO::Socket::SSL;
use PublicInbox::Syscall qw(EPOLLIN EPOLLOUT);
use strict;
use IO::Socket::SSL;
use PublicInbox::Syscall qw(EPOLLIN EPOLLOUT);
sub err () { $SSL_ERROR }
sub err () { $SSL_ERROR }
sub epollbit () {
return EPOLLIN if $SSL_ERROR == SSL_WANT_READ;
return EPOLLOUT if $SSL_ERROR == SSL_WANT_WRITE;
sub epollbit () {
return EPOLLIN if $SSL_ERROR == SSL_WANT_READ;
return EPOLLOUT if $SSL_ERROR == SSL_WANT_WRITE;
- die "unexpected SSL error: $SSL_ERROR";
+ carp "unexpected SSL error: $SSL_ERROR";
+ undef;