Re: [PATCH v2 13/16] lock_repo_for_gc(): compute the path to "gc.pid" only once

2 messages, 1 author, 2016-06-15 · open the first message on its own page

Re: [PATCH v2 13/16] lock_repo_for_gc(): compute the path to "gc.pid" only once

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:06:09

Michael Haggerty [off-list ref] writes:
quoted hunk
Signed-off-by: Michael Haggerty <redacted>
---
 builtin/gc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index 36fe333..c41354b 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -199,6 +199,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
 	uintmax_t pid;
 	FILE *fp;
 	int fd;
+	char *pidfile_path;
 
 	if (pidfile)
 		/* already locked */
@@ -207,12 +208,13 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
 	if (gethostname(my_host, sizeof(my_host)))
 		strcpy(my_host, "unknown");
 
-	fd = hold_lock_file_for_update(&lock, git_path("gc.pid"),
+	pidfile_path = git_pathdup("gc.pid");
+	fd = hold_lock_file_for_update(&lock, pidfile_path,
 				       LOCK_DIE_ON_ERROR);
Looks correct; somehow this reminded me of the other topic from Peff
to reduce use of git_path() ;-)
-	pidfile = git_pathdup("gc.pid");
+	pidfile = pidfile_path;
 	sigchain_push_common(remove_pidfile_on_signal);
 	atexit(remove_pidfile);
I wonder if you can reduce the atexit() here by registering this as
a tempfile to be cleared?

Re: [PATCH v2 13/16] lock_repo_for_gc(): compute the path to "gc.pid" only once

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:06:09

On Tue, Aug 11, 2015 at 1:06 PM, Junio C Hamano [off-list ref] wrote:
Looks correct; somehow this reminded me of the other topic from Peff
to reduce use of git_path() ;-)
quoted
-     pidfile = git_pathdup("gc.pid");
+     pidfile = pidfile_path;
      sigchain_push_common(remove_pidfile_on_signal);
      atexit(remove_pidfile);
I wonder if you can reduce the atexit() here by registering this as
a tempfile to be cleared?
Heh, I should have been slightly more patient. That is what 14/16 is about ;-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help