login
Header Space

 
 

Re: [PATCH 2/2] close_lock_file(): new function in the lockfile API

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Brandon Casey <casey@...>
Cc: Linus Torvalds <torvalds@...>, Git Mailing List <git@...>, Alex Riesen <raa.lkml@...>, Kristian <krh@...>
Date: Wednesday, January 16, 2008 - 7:19 pm

Brandon Casey <casey@nrlssc.navy.mil> writes:


But that would bring us back to the same double-close issue,
wouldn't it?

	if (close_lock_file(lock))
		die("Oops, failed to close fd %d", lock->fd);

is not enough.  You need to do:

	if (close_lock_file(lock)) {
        	int fd = lock->fd;
                lock->fd = -1;
		die("Oops, failed to close fd %d", fd);
	}

to avoid atexit handler closing the lock->fd.

Worse yet, a careless caller may do:

	close_lock_file(lock);

	... do something that opens a new fd, perhaps for
        ... mmaping a packfile in

	rollback_lock_file(lock);

	... Oops, we cannot mmap the packfile.

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 2/2] close_lock_file(): new function in the lockf..., Junio C Hamano, (Wed Jan 16, 7:19 pm)
[PATCH 1/2] Document lockfile API, Junio C Hamano, (Wed Jan 16, 3:00 pm)
speck-geostationary