From: Johannes Sixt <j.sixt@viscovery.net>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: About close() in commit_lock_file()
Date: Tue, 06 Aug 2013 08:41:20 +0200 [thread overview]
Message-ID: <52009A90.7050701@viscovery.net> (raw)
In-Reply-To: <CACsJy8By1cpPZ5QyVd6VhKSkd-y_E6pTYdDimK9P0wXia-uMqg@mail.gmail.com>
Am 8/5/2013 16:23, schrieb Duy Nguyen:
> close() is added in commit_lock_file(), before rename(), by 4723ee9
> (Close files opened by lock_file() before unlinking. - 2007-11-13),
> which is needed by Windows. But doesn't that create a gap between
> close() and rename() on other platforms where another process can
> replace .lock file with something else before rename() is executed?
First, files manipulated by commit_lock_file() are to be opened only using
lock_file() by definition. Opening such a file in with open() or fopen()
or renaming it via rename() without using the lockfile.[ch] API is
possible regardless of whether commit_lock_file() has closed the file or
not. Such manipulation is already undefined behavior (from Git's point of
view), and there is nothing we can do about "misbehaving" processes.
Second, lock_file() uses O_CREAT|O_EXCL, which fails when the file exists,
regardless of whether it is open or not.
Conclusion: There is no problem.
-- Hannes
next prev parent reply other threads:[~2013-08-06 6:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-05 14:23 About close() in commit_lock_file() Duy Nguyen
2013-08-05 16:56 ` Junio C Hamano
2013-08-06 6:41 ` Johannes Sixt [this message]
2013-08-06 8:36 ` 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=52009A90.7050701@viscovery.net \
--to=j.sixt@viscovery.net \
--cc=git@vger.kernel.org \
--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).