Skip to content
Snippets Groups Projects
Commit 84f79b58 authored by Eric Cano's avatar Eric Cano
Browse files

Added automatic recreation of lock files in VFS objectstore backend (useful when on /tmp).

parent 62db83e8
No related branches found
No related tags found
No related merge requests found
......@@ -227,13 +227,19 @@ BackendVFS::ScopedLock * BackendVFS::lockHelper(
ret->set(::open(path.c_str(), O_RDONLY), path);
if(0 > ret->m_fd) {
const std::string errnoStr = utils::errnoToString(errno);
exception::Exception ex;
ex.getMessage() << "In BackendVFS::lockHelper(): Failed to open file " << path <<
": " << errnoStr;
// fd=-1, so there will be no need to close the file (when *ret will be destroyed).
ret->m_fdSet=false;
throw ex;
// Create the lock file if missing.
if (ENOENT == errno) {
ret->set(::open(path.c_str(), O_RDONLY | O_CREAT, S_IRWXU | S_IRGRP | S_IROTH), path);
exception::Errnum::throwOnMinusOne(ret->m_fd, "In BackendVFS::lockHelper(): Failed to recreate missing lock file");
} else {
const std::string errnoStr = utils::errnoToString(errno);
exception::Exception ex;
ex.getMessage() << "In BackendVFS::lockHelper(): Failed to open file " << path <<
": " << errnoStr;
// fd=-1, so there will be no need to close the file (when *ret will be destroyed).
ret->m_fdSet=false;
throw ex;
}
}
if(::flock(ret->m_fd, LOCK_EX)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment