unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: Re: [MAYBE] kill rpipe early
Date: Tue, 17 Sep 2019 09:40:05 +0000	[thread overview]
Message-ID: <20190917094005.GA17633@dcvr> (raw)
In-Reply-To: <20190917091915.o5nylhjzk2g7rwax@dcvr>

Eric Wong <e@80x24.org> wrote:
> 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;

			# if the above "$rpipe = undef" fixes the pipe leak,
			# the following ought to fix the regular file leak.
			# HOWEVER, there is still a likely memory leak
			# even if all the FD leaks are fixed, so keeping the
			# FD leaks would help find and fix the memory leak
			delete $env->{'psgi.input'};

>  		} else { # for synchronous PSGI servers
>  			require PublicInbox::GetlineBody;
>  			$r->[2] = PublicInbox::GetlineBody->new($rpipe, $end,

      reply	other threads:[~2019-09-17  9:40 UTC|newest]

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 ` [MAYBE] kill rpipe early Eric Wong
2019-09-17  9:40   ` Eric Wong [this message]

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:
  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=20190917094005.GA17633@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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).