X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FHTTP.pm;h=88020ae82438375e42a0854b6c6ae2c4defe2c89;hb=0d38f65c490466837ae091afa7a7b6f59d04ce7c;hp=8281746538e2df420a7003a8fc62cdd2dab159a9;hpb=94096cab6cd5e00c8a36a4a2667bdb9acf43d01f;p=public-inbox.git diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index 82817465..88020ae8 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -70,7 +70,7 @@ sub new ($$$) { 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; @@ -488,6 +488,13 @@ sub busy () { ($self->{rbuf} || exists($self->{env}) || $self->{wbuf}); } +# runs $cb on the next iteration of the event loop at earliest +sub next_step { + my ($self, $cb) = @_; + return unless exists $self->{sock}; + $self->requeue if 1 == push(@{$self->{wbuf}}, $cb); +} + # Chunked and Identity packages are used for writing responses. # They may be exposed to the PSGI application when the PSGI app # returns a CODE ref for "push"-based responses