From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C1F7A1F463; Tue, 17 Sep 2019 09:40:05 +0000 (UTC) Date: Tue, 17 Sep 2019 09:40:05 +0000 From: Eric Wong To: meta@public-inbox.org Subject: Re: [MAYBE] kill rpipe early Message-ID: <20190917094005.GA17633@dcvr> References: <20190917083123.6468-1-e@80x24.org> <20190917091915.o5nylhjzk2g7rwax@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190917091915.o5nylhjzk2g7rwax@dcvr> List-Id: Eric Wong 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,