diff options
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/HTTP.pm | 5 | ||||
-rw-r--r-- | lib/PublicInbox/HTTPD/Async.pm | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index fcbd758a..6df1c3fc 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -265,10 +265,13 @@ sub getline_response { my $pull = $self->{pull} = sub { local $/ = \8192; my $forward = $self->{forward}; + # limit our own running time for fairness with other + # clients and to avoid buffering too much: + my $n = 100; while ($forward && defined(my $buf = $forward->getline)) { $write->($buf); last if $self->{closed}; - if ($self->{write_buf_size}) { + if ((--$n) <= 0 || $self->{write_buf_size}) { $self->write($self->{pull}); return; } 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 { $self->watch_read(0); $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}; } |