lockfile.c: schedule remove_lock_file only once.
Removing a lockfile once should be enough. Signed-off-by: Sven Verdoolaege <skimo@kotnet.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sven Verdoolaege committed
Jul 13, 2007 at 16:14 UTC
9a4cbdca34f6aa9424fce8a55fe9dd6f7c25d97b
1 file changed
+4
-4
lockfile.c
+4
-4
@@ -31,16 +31,16 @@ static int lock_file(struct lock_file *lk, const char *path)
31
sprintf(lk->filename, "%s.lock", path);
32
fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
33
if (0 <= fd) {
34
+ if (!lock_file_list) {
35
+ signal(SIGINT, remove_lock_file_on_signal);
36
+ atexit(remove_lock_file);
37
+ }
38
lk->owner = getpid();
39
if (!lk->on_list) {
40
lk->next = lock_file_list;
41
lock_file_list = lk;
42
lk->on_list = 1;
43
}
40
- if (lock_file_list) {
41
- signal(SIGINT, remove_lock_file_on_signal);
42
- atexit(remove_lock_file);
43
- }
44
if (adjust_shared_perm(lk->filename))
45
return error("cannot fix permission bits on %s",
46
lk->filename);