about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-07-07 20:09:39 +0000
committerEric Wong <e@80x24.org>2016-07-07 20:12:06 +0000
commitd9128a9d891429b369ded55fdb80dabc4a53961c (patch)
tree419f132b1e9fac537456c6b128f44ff63fab3b11 /lib
parent4a1612ec77c1904b4ba44422ec8cfade3fe603f4 (diff)
downloadpublic-inbox-d9128a9d891429b369ded55fdb80dabc4a53961c.tar.gz
There was a spurious test failure in t/httpd-corner.t
which I have not been able to reproduce.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/HTTP.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index abf648f9..17f89302 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -98,7 +98,7 @@ sub rbuf_process {
         $self->{rbuf} = substr($self->{rbuf}, $r);
 
         my $len = input_prepare($self, \%env);
-        defined $len or return write_err($self); # EMFILE/ENFILE
+        defined $len or return write_err($self, undef); # EMFILE/ENFILE
 
         $len ? event_read_input($self) : app_dispatch($self);
 }
@@ -118,7 +118,7 @@ sub event_read_input ($) {
         while ($len > 0) {
                 if ($$rbuf ne '') {
                         my $w = write_in_full($input, $rbuf, $len);
-                        return write_err($self) unless $w;
+                        return write_err($self, $len) unless $w;
                         $len -= $w;
                         die "BUG: $len < 0 (w=$w)" if $len < 0;
                         if ($len == 0) { # next request may be pipelined
@@ -332,9 +332,10 @@ sub input_prepare {
 sub env_chunked { ($_[0]->{HTTP_TRANSFER_ENCODING} || '') =~ /\bchunked\b/i }
 
 sub write_err {
-        my ($self) = @_;
+        my ($self, $len) = @_;
         my $err = $self->{httpd}->{env}->{'psgi.errors'};
         my $msg = $! || '(zero write)';
+        $msg .= " ($len bytes remaining)\n" if defined $len;
         $err->print("error buffering to input: $msg\n");
         quit($self, 500);
 }
@@ -410,7 +411,7 @@ sub event_read_input_chunked { # unlikely...
                 until ($len <= 0) {
                         if ($$rbuf ne '') {
                                 my $w = write_in_full($input, $rbuf, $len);
-                                return write_err($self) unless $w;
+                                return write_err($self, "$len chunk") if !$w;
                                 $len -= $w;
                                 if ($len == 0) {
                                         # we may have leftover data to parse