Re: [PATCH] lockfile.c: schedule remove_lock_file only once.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 13, 2007, 18:23 UTC
- Message-ID
- <7vabu0noxg.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <20070713141450.GA8392MdfPADPa@greensroom.kotnet.org>
Sven Verdoolaege <skimo@kotnet.org> writes:
> Removing a lockfile once should be enough.
Yeah. I wonder what we were smoking. 415e96c8 which introduces the atexit to index.c does:
int hold_index_file_for_update(struct cache_file *cf, const char *path)
{
sprintf(cf->lockfile, "%s.lock", path);
cf->next = cache_file_list;
cache_file_list = cf;
if (!cf->next) {
signal(SIGINT, remove_lock_file_on_signal);
atexit(remove_lock_file);
}
return open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0600);
}whose intent is exactly "do this once, only for the first one".
The reason we do not use lk->next but instead check lk->on_list, and the reason why we do not remove the lock from the list, are described in 1084b845.
But your "fire atexit() once" fix is needed. Thanks.