summaryrefslogtreecommitdiff
path: root/http-push.c
diff options
context:
space:
mode:
authorClemens Buchacher <drizzd@aon.at>2008-05-25 20:27:44 +0200
committerJunio C Hamano <gitster@pobox.com>2008-05-25 13:07:24 -0700
commit6a491a176593a9ab3bd7ff24ef12323371671112 (patch)
tree2a2459a88455a142f38f5b20beac543741c7b668 /http-push.c
parenta1292939381507be9489451076d49a5b927e9cc4 (diff)
downloadgit-6a491a176593a9ab3bd7ff24ef12323371671112.tar.gz
http-push: remove remote locks on exit signals
If locks are not cleaned up the repository is inaccessible for 10 minutes. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http-push.c')
-rw-r--r--http-push.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/http-push.c b/http-push.c
index 42727c8a45..f173dcd64f 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);
@@ -2256,6 +2274,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");