From: Michael Haggerty <mhagger@alum.mit.edu>
To: Ronnie Sahlberg <sahlberg@google.com>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, Brad King <brad.king@kitware.com>
Subject: Re: What's cooking in git.git (Mar 2014, #07; Fri, 28)
Date: Mon, 31 Mar 2014 22:22:19 +0200 [thread overview]
Message-ID: <5339CE7B.2030307@alum.mit.edu> (raw)
In-Reply-To: <CAL=YDWnKb7Di3wsw7i1kn0mCGAmqvSY+xQOA5wo2v_EohkHEEg@mail.gmail.com>
On 03/31/2014 07:56 PM, Ronnie Sahlberg wrote:
> I am new to git, so sorry If I overlooked something.
>
> I think there might be a race in ref_transaction_commit() when
> deleting references.
>
> /* Perform deletes now that updates are safely completed */
> for (i = 0; i < n; i++) {
> struct ref_update *update = updates[i];
>
> if (update->lock) {
> delnames[delnum++] = update->lock->ref_name;
> ret |= delete_ref_loose(update->lock, update->type);
> }
> }
>
> ret |= repack_without_refs(delnames, delnum);
> for (i = 0; i < delnum; i++)
> unlink_or_warn(git_path("logs/%s", delnames[i]));
>
> These two blocks should be reordered so that you first delete the
> actual refs first, while holding the lock and then release the lock
> afterward ?
I think what you suggest is what is already being done. The locks of
references that are being deleted are not released until a few lines
after the code that you quoted:
> for (i = 0; i < n; i++)
> if (updates[i]->lock)
> unlock_ref(updates[i]->lock);
Before the code that you quoted, some locks are released, but only for
references being updated (not those being deleted).
But maybe I misunderstand your critique.
By the way, there *is* a race here, but it is a subtler one involving
the interaction between packed and loose references when references are
deleted.
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
next prev parent reply other threads:[~2014-03-31 20:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 22:21 What's cooking in git.git (Mar 2014, #07; Fri, 28) Junio C Hamano
2014-03-28 23:23 ` Michael Haggerty
2014-03-30 7:51 ` Junio C Hamano
2014-03-31 17:56 ` Ronnie Sahlberg
2014-03-31 20:22 ` Michael Haggerty [this message]
2014-03-29 15:44 ` Max Horn
2014-03-30 2:01 ` Duy Nguyen
2014-03-31 22:04 ` Junio C Hamano
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=5339CE7B.2030307@alum.mit.edu \
--to=mhagger@alum.mit.edu \
--cc=brad.king@kitware.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sahlberg@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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.