unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] http: additional info for write failures
@ 2016-07-07 20:12 Eric Wong
  2016-07-08 18:20 ` [PATCH 2/1] http: drop extra newline in error message Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2016-07-07 20:12 UTC (permalink / raw)
  To: meta

There was a spurious test failure in t/httpd-corner.t
which I have not been able to reproduce.
---
 lib/PublicInbox/HTTP.pm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index abf648f..17f8930 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
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/1] http: drop extra newline in error message
  2016-07-07 20:12 [PATCH] http: additional info for write failures Eric Wong
@ 2016-07-08 18:20 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2016-07-08 18:20 UTC (permalink / raw)
  To: meta

We already add the extra newline when we call print.
---
 lib/PublicInbox/HTTP.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index 17f8930..fa34b44 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -335,7 +335,7 @@ sub write_err {
 	my ($self, $len) = @_;
 	my $err = $self->{httpd}->{env}->{'psgi.errors'};
 	my $msg = $! || '(zero write)';
-	$msg .= " ($len bytes remaining)\n" if defined $len;
+	$msg .= " ($len bytes remaining)" if defined $len;
 	$err->print("error buffering to input: $msg\n");
 	quit($self, 500);
 }
-- 
EW

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-07-08 18:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-07 20:12 [PATCH] http: additional info for write failures Eric Wong
2016-07-08 18:20 ` [PATCH 2/1] http: drop extra newline in error message Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).