Skip to content

Commit

Permalink
http-push: remove remote locks on exit signals
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Clemens Buchacher authored and Junio C Hamano committed May 25, 2008
1 parent a129293 commit 6a491a1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 6a491a1

Please sign in to comment.