user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <>
Subject: [PATCH 1/4] www: gzip_filter: gracefully handle socket ->write failures
Date: Wed,  3 Aug 2022 07:59:09 +0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Socket ->write failures are expected and common for TCP traffic,
especially if it's facing unreliable remote connections.  So
just bail out silently if our {gz} field was already clobbered
during the small bit of recursion we hit on ->write failures
from async responses.

This ought to fix some GzipFilter::zflush errors (via $forward
->close from PublicInbox::HTTP) I've been noticing on
deployments running -netd.  I'm still unsure as to why I hadn't
seen them before, but it might've only been ignorance on my

 lib/PublicInbox/ | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/ b/lib/PublicInbox/
index e37f1f76..c586d2f8 100644
--- a/lib/PublicInbox/
+++ b/lib/PublicInbox/
@@ -149,10 +149,11 @@ sub zflush ($;$) {
 	my $zbuf = delete $self->{zbuf};
 	my $gz = delete $self->{gz};
 	my $err;
-	if (defined $_[1]) {
+	if (defined $_[1]) { # it's a bug iff $gz is undef w/ $_[1]
 		$err = $gz->deflate($_[1], $zbuf);
 		die "gzip->deflate: $err" if $err != Z_OK;
+	$gz // return; # not a bug, recursing on DS->write failure
 	$err = $gz->flush($zbuf);
 	die "gzip->flush: $err" if $err != Z_OK;

  reply	other threads:[~2022-08-03  7:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03  7:59 [PATCH 0/4] compression-related stuff Eric Wong
2022-08-03  7:59 ` Eric Wong [this message]
2022-08-03  7:59 ` [PATCH 2/4] www: gzip_filter: update a few comments Eric Wong
2022-08-03  7:59 ` [PATCH 3/4] ds: use ->dflush to distinguish from ->zflush Eric Wong
2022-08-03  7:59 ` [PATCH 4/4] www: simplify GzipFilter->zflush callers Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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).