about summary refs log tree commit homepage
path: root/lib/PublicInbox/HTTPD/Async.pm
diff options
authorEric Wong <e@80x24.org>2016-05-30 04:39:57 +0000
committerEric Wong <e@80x24.org>2016-05-30 04:46:23 +0000
commit56692b57c4e6a404fee0ec8eef857f35e09ce767 (patch)
treeba5a3c77f8995122110fa18780b47cad5618c81b /lib/PublicInbox/HTTPD/Async.pm
parent1cf14fe543ad6259003cdd1995a1c83a7a70b535 (diff)
http: yield body->getline running time
We cannot let a client monopolize the single-threaded server
even if it can drain the socket buffer faster than we can
emit data.

While we're at it, acknowledge the this behavior (which happens
naturally) in httpd/async.

The same idea is present in NNTP for the long_response code.

This is the HTTP followup to:
commit 0d0fde0bff97 ("nntp: introduce long response API for streaming")
commit 79d8bfedcdd2 ("nntp: avoid signals for long responses")
Diffstat (limited to 'lib/PublicInbox/HTTPD/Async.pm')
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm
index add07ce4..fadf2d3a 100644
--- a/lib/PublicInbox/HTTPD/Async.pm
+++ b/lib/PublicInbox/HTTPD/Async.pm
@@ -45,7 +45,9 @@ sub async_pass {
                                 $io->write($restart_read); # D::S::write
-                        return; # stay in watch_read
+                        # stay in watch_read, but let other clients
+                        # get some work done, too.
+                        return;
                 } elsif (!defined $r) {
                         return if $!{EAGAIN} || $!{EINTR};