From: Jonathan Nieder <jrnieder@gmail.com>
To: Michael Haggerty <mhagger@alum.mit.edu>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 5/5] rename_ref(): fix a mkdir()/rmdir() race
Date: Thu, 26 Dec 2013 15:20:23 -0800 [thread overview]
Message-ID: <20131226232023.GA20443@google.com> (raw)
In-Reply-To: <1387696451-32224-6-git-send-email-mhagger@alum.mit.edu>
Michael Haggerty wrote:
> refs.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
A test or example reproduction recipe would be nice. (But I can
understand not having one --- races are hard to test.)
[...]
> --- a/refs.c
> +++ b/refs.c
[...]
> @@ -2574,6 +2575,13 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
> }
> goto retry;
> } else {
> + if (errno == ENOENT && --attempts)
> + /*
> + * Perhaps somebody just pruned the empty
> + * directory into which we wanted to move the
> + * file.
> + */
> + goto retry;
Style nit: it's easier to read a test of errno when the 'else's
cascade (i.e., using 'else if' here).
This patch doesn't depend on any of the others from the series. For
what it's worth, with or without the following squashed in,
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Thanks.
diff --git i/refs.c w/refs.c
index 3ab1491..ea62395 100644
--- i/refs.c
+++ w/refs.c
@@ -2574,14 +2574,14 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
goto rollback;
}
goto retry;
+ } else if (errno == ENOENT && --attempts)
+ /*
+ * Perhaps somebody just pruned the empty
+ * directory into which we wanted to move the
+ * file.
+ */
+ goto retry;
} else {
- if (errno == ENOENT && --attempts)
- /*
- * Perhaps somebody just pruned the empty
- * directory into which we wanted to move the
- * file.
- */
- goto retry;
error("unable to move logfile "TMP_RENAMED_LOG" to logs/%s: %s",
newrefname, strerror(errno));
goto rollback;
prev parent reply other threads:[~2013-12-26 23:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-22 7:14 [PATCH 0/5] Fix two mkdir/rmdir races Michael Haggerty
2013-12-22 7:14 ` [PATCH 1/5] safe_create_leading_directories(): modernize format of "if" chaining Michael Haggerty
2013-12-26 21:52 ` Jonathan Nieder
2013-12-22 7:14 ` [PATCH 2/5] safe_create_leading_directories(): reduce scope of local variable Michael Haggerty
2013-12-26 21:55 ` Jonathan Nieder
2014-01-01 12:39 ` Michael Haggerty
2013-12-22 7:14 ` [PATCH 3/5] safe_create_leading_directories(): add "slash" pointer Michael Haggerty
2013-12-26 22:34 ` Jonathan Nieder
2014-01-01 21:10 ` Michael Haggerty
2013-12-22 7:14 ` [PATCH 4/5] safe_create_leading_directories(): fix a mkdir/rmdir race Michael Haggerty
2013-12-22 22:42 ` Ramsay Jones
2013-12-26 23:02 ` Jonathan Nieder
2014-01-02 0:53 ` Michael Haggerty
2013-12-22 7:14 ` [PATCH 5/5] rename_ref(): fix a mkdir()/rmdir() race Michael Haggerty
2013-12-26 23:20 ` Jonathan Nieder [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131226232023.GA20443@google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
/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).