From 043c8be7476381232f0c37bdff5a331ec52f945d Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 26 Sep 2013 11:28:51 +0200 Subject: [PATCH] create lock file if it does not exist --- DataStructures/SharedMemoryFactory.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/DataStructures/SharedMemoryFactory.h b/DataStructures/SharedMemoryFactory.h index 9c908a187..4218250c7 100644 --- a/DataStructures/SharedMemoryFactory.h +++ b/DataStructures/SharedMemoryFactory.h @@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include #include +#include #include #include @@ -36,9 +37,9 @@ struct OSRMLockFile { boost::filesystem::path operator()() { boost::filesystem::path temp_dir = boost::filesystem::temp_directory_path(); - SimpleLogger().Write(logDEBUG) << "creating lock file in " << temp_dir; + // SimpleLogger().Write(logDEBUG) << "creating lock file in " << temp_dir; boost::filesystem::path lock_file = temp_dir / "osrm.lock"; - SimpleLogger().Write(logDEBUG) << "locking at " << lock_file; + // SimpleLogger().Write(logDEBUG) << "locking at " << lock_file; return lock_file; } }; @@ -144,8 +145,13 @@ public: ) { try { LockFileT lock_file; - if(0 == size && !boost::filesystem::exists(lock_file()) ) { - throw OSRMException("lock file does not exist, exiting"); + if(!boost::filesystem::exists(lock_file()) ) { + if( 0 == size ) { + throw OSRMException("lock file does not exist, exiting"); + } else { + boost::filesystem::ofstream ofs(lock_file()); + ofs.close(); + } } return new SharedMemory(lock_file(), id, size); } catch(const boost::interprocess::interprocess_exception &e){