From: Eric Wong Date: Thu, 4 Jul 2024 02:20:55 +0000 (+0000) Subject: http: don't requeue if using write buffer X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=112fbeed50629c2b366db24e5ccb70103b759821;p=thirdparty%2Fpublic-inbox.git http: don't requeue if using write buffer The write buffering will already be processed inside ->event_step, so requeue will cause a needless read(2) outside of epoll_wait/kevent(2) readiness notifications. This ought to avoid problems in case of pipelined connections, but those aren't possible behind a reverse proxy and AFAIK most HTTP clients don't do pipelining. This bug was only noticed via strace while searching for extra syscalls, and not from real-world use. --- diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index 4ccb1b817..88cab5447 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -247,7 +247,8 @@ sub response_done { delete $self->{env}; # we're no longer busy # HEAD requests set $alive = 3 so we don't send "0\r\n\r\n"; $self->write(\"0\r\n\r\n") if $alive == 2; - $self->write($alive ? $self->can('requeue') : \&close); + $self->write(\&close) if !$alive; + $self->requeue if $alive && !$self->{wbuf}; } sub getline_pull { @@ -280,7 +281,7 @@ sub getline_pull { } } elsif ($@) { warn "response ->getline error: $@"; - $self->close; + return $self->close; } response_done($self, delete $self->{alive}); }