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.
This commit is contained in:
Simon Arlott 2021-08-24 09:01:16 +01:00
parent e4619fdae6
commit 0665208299
No known key found for this signature in database
GPG Key ID: DF001BFD83E75990

View File

@ -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;
}