]> Sergey Matveev's repositories - public-inbox.git/commitdiff
httpd/async: do not attempt future writes on closed sockets
authorEric Wong <e@80x24.org>
Sat, 9 Jul 2016 04:51:36 +0000 (04:51 +0000)
committerEric Wong <e@80x24.org>
Sat, 9 Jul 2016 04:52:11 +0000 (04:52 +0000)
Danga::Socket::close does not clear the write_buf_size field,
so it's conceivable we could attempt to queue up data and
callbacks we can never flush out.

lib/PublicInbox/HTTPD/Async.pm

index a936d9b5a0c6fc5e3988c88085437a1322b13333..880cf021cef763a97ea9add08cea295d4c9789fa 100644 (file)
@@ -41,6 +41,7 @@ sub async_pass {
                my $r = sysread($self->{sock}, $$bref, 8192);
                if ($r) {
                        $fh->write($$bref);
+                       return if $io->{closed};
                        if ($io->{write_buf_size}) {
                                $self->watch_read(0);
                                $io->write($restart_read); # D::S::write