user/dev discussion of public-inbox itself
 help / color / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [MAYBE] kill rpipe early
Date: Tue, 17 Sep 2019 09:19:15 +0000
Message-ID: <20190917091915.o5nylhjzk2g7rwax@dcvr> (raw)
In-Reply-To: <20190917083123.6468-1-e@80x24.org>

Eric Wong <e@80x24.org> wrote:
> Still haven't found anything which is causing problems on korg,
> but found a bunch of worthwhile cleanups, clarifications
> and perhaps minor efficiency improvements that I'm comfortable
> putting on 'master'.

This might help narrow down where the FD leak is if it stops
pipes (but not regular files) from leaking.  However, if it
fixes things, I also don't understand why it'd work, but I'm
mostly running on fumes at this point...

diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index 5a30064..3bf5c03 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -224,7 +224,7 @@ sub filter_fh ($$) {
 #              immediately (or streamed via ->getline (pull-based)).
 sub psgi_return {
 	my ($self, $env, $limiter, $parse_hdr) = @_;
-	my ($fh, $rpipe);
+	my $fh;
 	my $end = sub {
 		my $err = $_[0]; # $!
 		log_err($env, "psgi_return: $err") if defined($err);
@@ -233,6 +233,7 @@ sub psgi_return {
 	};
 
 	my $buf = '';
+	my $rpipe;
 	my $rd_hdr = sub {
 		# typically used for reading CGI headers
 		# we must loop until EAGAIN for EPOLLET in HTTPD/Async.pm
@@ -275,6 +276,7 @@ sub psgi_return {
 			$fh = $wcb->($r); # scalar @$r == 2
 			$fh = filter_fh($fh, $filter) if $filter;
 			$async->async_pass($env->{'psgix.io'}, $fh, \$buf);
+			$rpipe = undef;
 		} else { # for synchronous PSGI servers
 			require PublicInbox::GetlineBody;
 			$r->[2] = PublicInbox::GetlineBody->new($rpipe, $end,

  parent reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-17  8:31 [PATCH 0/6] qspawn-related cleanups, comments, and minor fix Eric Wong
2019-09-17  8:31 ` [PATCH 1/6] qspawn: remove return value from ->finish Eric Wong
2019-09-17  8:31 ` [PATCH 2/6] qspawn: log errors for generic PSGI server users Eric Wong
2019-09-17  8:31 ` [PATCH 3/6] qspawn: shorten lifetime of circular references Eric Wong
2019-09-17  8:31 ` [PATCH 4/6] qspawn: improve variable naming and commenting Eric Wong
2019-09-17  8:31 ` [PATCH 5/6] http: drop unused `$env' variable after delete Eric Wong
2019-09-17  8:31 ` [PATCH 6/6] http: remove unnecessary delete Eric Wong
2019-09-17  9:19 ` Eric Wong [this message]
2019-09-17  9:40   ` [MAYBE] kill rpipe early Eric Wong

Reply instructions:

You may reply publically 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

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

  git send-email \
    --in-reply-to=20190917091915.o5nylhjzk2g7rwax@dcvr \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git