From 066520829970fd14c45f953884e6aeeb7d4e1202 Mon Sep 17 00:00:00 2001 From: Simon Arlott Date: Tue, 24 Aug 2021 09:01:16 +0100 Subject: [PATCH] xml-backend: Lock file is deleted even if the lock is not acquired The lock file is set in m_lockfile and then unlinked in session_end even if the lock was not acquired. Clear m_lockfile if locking was not successful. --- libgnucash/backend/xml/gnc-xml-backend.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libgnucash/backend/xml/gnc-xml-backend.cpp b/libgnucash/backend/xml/gnc-xml-backend.cpp index d9e3c9d3da..f6cb55a785 100644 --- a/libgnucash/backend/xml/gnc-xml-backend.cpp +++ b/libgnucash/backend/xml/gnc-xml-backend.cpp @@ -641,6 +641,7 @@ GncXmlBackend::get_file_lock () { /* oops .. file is locked by another user .. */ set_error(ERR_BACKEND_LOCKED); + m_lockfile.clear(); return false; } @@ -664,6 +665,7 @@ GncXmlBackend::get_file_lock () PWARN ("Unable to create the lockfile %s: %s", m_lockfile.c_str(), strerror(errno)); set_error(be_err); + m_lockfile.clear(); return false; } @@ -713,6 +715,7 @@ GncXmlBackend::get_file_lock () close (m_lockfd); m_lockfd = -1; g_unlink (m_lockfile.c_str()); + m_lockfile.clear(); return false; } @@ -727,6 +730,7 @@ GncXmlBackend::get_file_lock () close (m_lockfd); m_lockfd = -1; g_unlink (m_lockfile.c_str()); + m_lockfile.clear(); return false; } @@ -737,6 +741,7 @@ GncXmlBackend::get_file_lock () close (m_lockfd); m_lockfd = -1; g_unlink (m_lockfile.c_str()); + m_lockfile.clear(); return false; }