]> Sergey Matveev's repositories - public-inbox.git/commitdiff
http: prevent zero-byte writes
authorEric Wong <e@80x24.org>
Sat, 12 Mar 2016 00:20:12 +0000 (00:20 +0000)
committerEric Wong <e@80x24.org>
Sat, 12 Mar 2016 00:20:51 +0000 (00:20 +0000)
Plack::Middleware::Deflater (and perhaps other middleware)
triggers zero-byte writes which wastes syscalls when
they get passed to Danga::Socket.  This may also trigger
problems when we introduce TLS support in the future.

lib/PublicInbox/HTTP.pm

index 0675f6a68b35ee1fc0a2424a43ab510a6bfe088f..288831146da11f4a1d329ca991f58f79565a824a 100644 (file)
@@ -371,6 +371,13 @@ sub quit {
 sub event_hup { $_[0]->close }
 sub event_err { $_[0]->close }
 
+sub write ($$) : method {
+       my PublicInbox::HTTP $self = $_[0];
+       return 1 if (defined($_[1]) && ref($_[1]) eq '' && $_[1] eq '');
+
+       $self->SUPER::write($_[1]);
+}
+
 # for graceful shutdown in PublicInbox::Daemon:
 sub busy () {
        my ($self) = @_;