git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] lockfile.c: schedule remove_lock_file only once.

From
SVSven Verdoolaege <skimo@kotnet.org>
Date
Jul 13, 2007, 14:14 UTC
Message-ID
<20070713141450.GA8392MdfPADPa@greensroom.kotnet.org>
Removing a lockfile once should be enough.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
---
...unless we're running on VMS.

Anyway, it's not clear to me why we can't remove lk from lock_file_list (and then free it) after we unlink it in unlock_ref.

skimo
 lockfile.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lockfile.c b/lockfile.c
index 5ad2858..fb8f13b 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -31,16 +31,16 @@ static int lock_file(struct lock_file *lk, const char *path)
 	sprintf(lk->filename, "%s.lock", path);
 	fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
 	if (0 <= fd) {
+		if (!lock_file_list) {
+			signal(SIGINT, remove_lock_file_on_signal);
+			atexit(remove_lock_file);
+		}
 		lk->owner = getpid();
 		if (!lk->on_list) {
 			lk->next = lock_file_list;
 			lock_file_list = lk;
 			lk->on_list = 1;
 		}
-		if (lock_file_list) {
-			signal(SIGINT, remove_lock_file_on_signal);
-			atexit(remove_lock_file);
-		}
 		if (adjust_shared_perm(lk->filename))
 			return error("cannot fix permission bits on %s",
 				     lk->filename);
-- 
1.5.3.rc1.10.gae1ae
Next: Junio C Hamano
Message 1 of 3 in “lockfile.c: schedule remove_lock_file only once.”
  1. lockfile.c: schedule remove_lock_file only once.Sven Verdoolaege, Jul 13, 2007
  2. Junio C HamanoJul 13, 2007
  3. Sven VerdoolaegeJul 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.