From 329953d5754e7755679b30dca39afd1e578c6e46 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Thu, 12 Sep 2013 12:18:17 +0200 Subject: [PATCH] keyring: better open/close behavior --- src/keyring.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/keyring.cpp b/src/keyring.cpp index 08500f7..43d5ed7 100644 --- a/src/keyring.cpp +++ b/src/keyring.cpp @@ -419,6 +419,7 @@ bool keyring::open() if (flock (lockfd, LOCK_EX) ) { ::close (lockfd); + lockfd = -1; return false; } @@ -462,10 +463,15 @@ bool keyring::close() * Note that unlink goes first, so that the lock disappears atomically. */ + if (lockfd < 0) return true; //nothing to close + std::string fn = get_user_dir() + LOCK_FILENAME; unlink (fn.c_str() ); flock (lockfd, LOCK_UN); ::close (lockfd); + + lockfd = -1; + return true; }