Skip to content

Commit

Permalink
[PATCH] hold_index_file_for_update should not unlink failed to open .…
Browse files Browse the repository at this point in the history
…lock files atexit

Set up atexit only if the .lock-file was opened successfully.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Alex Riesen authored and Junio C Hamano committed Oct 5, 2005
1 parent 0b34379 commit d6e548d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ static void remove_lock_file_on_signal(int signo)

int hold_index_file_for_update(struct cache_file *cf, const char *path)
{
int fd;
sprintf(cf->lockfile, "%s.lock", path);
cf->next = cache_file_list;
cache_file_list = cf;
if (!cf->next) {
fd = open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0666);
if (fd >=0 && !cf->next) {
cf->next = cache_file_list;
cache_file_list = cf;
signal(SIGINT, remove_lock_file_on_signal);
atexit(remove_lock_file);
}
return open(cf->lockfile, O_RDWR | O_CREAT | O_EXCL, 0666);
return fd;
}

int commit_index_file(struct cache_file *cf)
Expand Down

0 comments on commit d6e548d

Please sign in to comment.