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

[PATCH] http-push: remove remote locks on exit signals

From
Clemens Buchacher <drizzd@aon.at>
Date
May 25, 2008, 18:27 UTC
Message-ID
<20080525182744.GB17806@localhost>
In-Reply-To
<20080523221723.GA4366@localhost>
If locks are not cleaned up the repository is inaccessible for 10 minutes.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
 http-push.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/http-push.c b/http-push.c
index 5b23038..b44768e 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1349,6 +1349,24 @@ static int unlock_remote(struct remote_lock *lock)
 	return rc;
 }
 
+static void remove_locks(void)
+{
+	struct remote_lock *lock = remote->locks;
+	
+	fprintf(stderr, "Removing remote locks...\n");
+	while (lock) {
+		unlock_remote(lock);
+		lock = lock->next;
+	}
+}
+
+static void remove_locks_on_signal(int signo)
+{
+	remove_locks();
+	signal(signo, SIG_DFL);
+	raise(signo);
+}
+
 static void remote_ls(const char *path, int flags,
 		      void (*userFunc)(struct remote_ls_ctx *ls),
 		      void *userData);
@@ -2255,6 +2273,10 @@ int main(int argc, char **argv)
 		goto cleanup;
 	}
 
+	signal(SIGINT, remove_locks_on_signal);
+	signal(SIGHUP, remove_locks_on_signal);
+	signal(SIGQUIT, remove_locks_on_signal);
+
 	/* Check whether the remote has server info files */
 	remote->can_update_info_refs = 0;
 	remote->has_info_refs = remote_exists("info/refs");
-- 
1.5.5.1
Previous: Clemens Buchacher
Message 9 of 9 in “http-push: remove remote locks on exit signals”
  1. http-push: remove remote locks on exit signalsClemens Buchacher, May 22, 2008
  2. Junio C HamanoMay 23, 2008
  3. Clemens BuchacherMay 23, 2008
  4. Reset the signal being handledClemens Buchacher, May 25, 2008
  5. Johannes SchindelinMay 26, 2008
  6. lockfile: reset the correct signalClemens Buchacher, May 26, 2008
  7. Johannes SchindelinMay 26, 2008
  8. Clemens BuchacherMay 27, 2008
  9. http-push: remove remote locks on exit signalsClemens Buchacher, May 25, 2008

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.