From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Stefan Beller" <sbeller@google.com>,
"Martin Ågren" <martin.agren@gmail.com>,
gitgitgadget@gmail.com, git <git@vger.kernel.org>,
"Gaël Lhez" <gael.lhez@gmail.com>
Subject: Re: [PATCH] bundle: dup() output descriptor closer to point-of-use
Date: Sat, 17 Nov 2018 16:05:44 +0900 [thread overview]
Message-ID: <xmqqk1lci3p3.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20181116094358.GA6054@sigill.intra.peff.net> (Jeff King's message of "Fri, 16 Nov 2018 04:43:59 -0500")
Jeff King <peff@peff.net> writes:
> Actually, I realized there's an even simpler way to do this. Here it is.
>
> -- >8 --
> Subject: [PATCH] bundle: dup() output descriptor closer to point-of-use
>
> When writing a bundle to a file, the bundle code actually creates
> "your.bundle.lock" using our lockfile interface. We feed that output
> descriptor to a child git-pack-objects via run-command, which has the
> quirk that it closes the output descriptor in the parent.
>
> To avoid confusing the lockfile code (which still thinks the descriptor
> is valid), we dup() it, and operate on the duplicate.
Yes...
> We can solve this by moving the dup() much closer to start_command(),
> shrinking the window in which we have the second descriptor open. It's
> easy to place this in such a way that no die() is possible. We could
> still die due to a signal in the exact wrong moment, but we already
> tolerate races there (e.g., a signal could come before we manage to put
> the file on the cleanup list in the first place).
>
> As a bonus, this shields create_bundle() itself from the duplicate-fd
> trick, and we can simplify its error handling (note that the lock
> rollback now happens unconditionally, but that's OK; it's a noop if we
> didn't open the lock in the first place).
... I found this way too clever for me, but by following the
codeflow, it was easy to convince myself that this does the right
thing. Almost magical ;-)
Will queue, with a Tested-by: with Dscho's name on it.
TAhanks, both.
next prev parent reply other threads:[~2018-11-17 7:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 15:09 [PATCH 0/1] bundle: fix issue when bundles would be empty Johannes Schindelin via GitGitGadget
2018-11-13 15:09 ` [PATCH 1/1] bundle: refuse to create empty bundle Gaël Lhez via GitGitGadget
2018-11-13 19:28 ` Stefan Beller
2018-11-13 20:37 ` Gaël Lhez
[not found] ` <CAK8L4uiMHrsdwJz9+rD1tSCywL2kHosx-hKZdS=UtZDHLy464A@mail.gmail.com>
2018-11-13 21:11 ` Stefan Beller
2018-11-14 15:23 ` Johannes Schindelin
2018-11-14 15:25 ` [PATCH v2 0/1] bundle: fix issue when bundles would be empty Johannes Schindelin via GitGitGadget
2018-11-14 15:25 ` [PATCH v2 1/1] bundle: cleanup lock files on error Gaël Lhez via GitGitGadget
2018-11-14 21:43 ` Martin Ågren
2018-11-14 22:08 ` Stefan Beller
2018-11-15 4:34 ` Jeff King
2018-11-15 12:57 ` Johannes Schindelin
2018-11-15 13:37 ` Jeff King
2018-11-15 16:32 ` Johannes Schindelin
2018-11-15 16:43 ` Jeff King
2018-11-15 20:01 ` Johannes Schindelin
2018-11-16 9:43 ` [PATCH] bundle: dup() output descriptor closer to point-of-use Jeff King
2018-11-16 15:06 ` Johannes Schindelin
2018-11-17 7:05 ` Junio C Hamano [this message]
2018-11-15 16:49 ` [PATCH v2 1/1] bundle: cleanup lock files on error 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk1lci3p3.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=gael.lhez@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=martin.agren@gmail.com \
--cc=peff@peff.net \
--cc=sbeller@google.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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).