1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-28 18:03:36 +00:00

keyring: remove race condition from unlocking

This commit is contained in:
Mirek Kratochvil 2013-04-20 23:43:37 +02:00
parent c6278b8e54
commit bb9640f6b7

@ -459,10 +459,14 @@ bool keyring::close()
/*
* close and remove the lock. Because of temporary lack of proper
* reporting, we just ignore the errors now.
*
* Note that unlink goes first, so that the lock disappears atomically.
*/
flock (lockfd, LOCK_UN);
::close (lockfd);
std::string fn = get_user_dir() + LOCK_FILENAME;
unlink (fn.c_str() );
flock (lockfd, LOCK_UN);
::close (lockfd);
return true;
}