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>
Clemens Buchacher committed
May 25, 2008 at 20:27 UTC
6a491a176593a9ab3bd7ff24ef12323371671112
1 file changed
+22
http-push.c
+22
@@ -1349,6 +1349,24 @@ static int unlock_remote(struct remote_lock *lock)
1349
return rc;
1350
}
1351
1352
+static void remove_locks(void)
1353
+{
1354
+ struct remote_lock *lock = remote->locks;
1355
+
1356
+ fprintf(stderr, "Removing remote locks...\n");
1357
+ while (lock) {
1358
+ unlock_remote(lock);
1359
+ lock = lock->next;
1360
+ }
1361
+}
1362
+
1363
+static void remove_locks_on_signal(int signo)
1364
+{
1365
+ remove_locks();
1366
+ signal(signo, SIG_DFL);
1367
+ raise(signo);
1368
+}
1369
+
1370
static void remote_ls(const char *path, int flags,
1371
void (*userFunc)(struct remote_ls_ctx *ls),
1372
void *userData);
@@ -2256,6 +2274,10 @@ int main(int argc, char **argv)
2274
goto cleanup;
2275
}
2276
2277
+ signal(SIGINT, remove_locks_on_signal);
2278
+ signal(SIGHUP, remove_locks_on_signal);
2279
+ signal(SIGQUIT, remove_locks_on_signal);
2280
+
2281
/* Check whether the remote has server info files */
2282
remote->can_update_info_refs = 0;
2283
remote->has_info_refs = remote_exists("info/refs");