git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Jens Lindström" <jl@opera.com>
Cc: git@vger.kernel.org, Duy Nguyen <pclouds@gmail.com>
Subject: Re: [PATCH v2] Clear fd after closing to avoid double-close error
Date: Tue, 22 Oct 2013 11:29:48 -0400	[thread overview]
Message-ID: <20131022152948.GA21940@sigill.intra.peff.net> (raw)
In-Reply-To: <1382448962-31782-1-git-send-email-jl@opera.com>

On Tue, Oct 22, 2013 at 03:36:02PM +0200, Jens Lindström wrote:

> In send_pack(), clear the fd passed to pack_objects() by setting
> it to -1, since pack_objects() closes the fd (via a call to
> run_command()).  Likewise, in get_pack(), clear the fd passed to
> run_command().
> 
> Not doing so risks having git_transport_push(), caller of
> send_pack(), closing the fd again, possibly incorrectly closing
> some other open file; or similarly with fetch_refs_from_pack(),
> indirect caller of get_pack().

Thanks, this looks like the right thing to do.

You had mentioned earlier in the thread the possibility of just dropping
the close() in git_transport_push. I agree that it is not worth going
that route, as it serves as a safety check to avoid leaking in early
returns (and indeed, in both the fetch and push cases, we can return
early without spawning a subprocess when the receiver already has all of
the necessary objects).

> Signed-off-by: Jens Lindström <jl@opera.com>

Acked-by: Jeff King <peff@peff.net>

-Peff

  reply	other threads:[~2013-10-22 15:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-22 13:36 [PATCH v2] Clear fd after closing to avoid double-close error Jens Lindström
2013-10-22 15:29 ` Jeff King [this message]
2013-10-23 13:00 ` Duy Nguyen

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

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

  git send-email \
    --in-reply-to=20131022152948.GA21940@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=jl@opera.com \
    --cc=pclouds@gmail.com \
    /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 NNTP newsgroup(s).