diff options
Diffstat (limited to 'cpp/src/Freeze/SharedDbEnv.cpp')
-rw-r--r-- | cpp/src/Freeze/SharedDbEnv.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/cpp/src/Freeze/SharedDbEnv.cpp b/cpp/src/Freeze/SharedDbEnv.cpp index 9692794e041..bd3d8ca1afc 100644 --- a/cpp/src/Freeze/SharedDbEnv.cpp +++ b/cpp/src/Freeze/SharedDbEnv.cpp @@ -484,18 +484,26 @@ Freeze::SharedDbEnv::SharedDbEnv(const std::string& envName, string propertyPrefix = string("Freeze.DbEnv.") + envName; string dbHome = properties->getPropertyWithDefault(propertyPrefix + ".DbHome", envName); - + // - // File lock to prevent multiple process open the same db env. We create the lock - // file in a sub-directory to ensure db_hotbackup won't try to copy the file when - // backing up the environment (this would fail on Windows where copying a locked - // file isn't possible). + // Normally the file lock is necessary, but for read-only situations (such as when + // using the FreezeScript utilities) this property allows the file lock to be + // disabled. // - if(!::IceUtilInternal::directoryExists(dbHome + "/__Freeze")) + if(properties->getPropertyAsIntWithDefault(propertyPrefix + ".LockFile", 1) > 0) { - ::IceUtilInternal::mkdir(dbHome + "/__Freeze", 0777); + // + // Use a file lock to prevent multiple processes from opening the same db env. We + // create the lock file in a sub-directory to ensure db_hotbackup won't try to copy + // the file when backing up the environment (this would fail on Windows where copying + // a locked file isn't possible). + // + if(!::IceUtilInternal::directoryExists(dbHome + "/__Freeze")) + { + ::IceUtilInternal::mkdir(dbHome + "/__Freeze", 0777); + } + _fileLock = new ::IceUtilInternal::FileLock(dbHome + "/__Freeze/lock"); } - _fileLock = new ::IceUtilInternal::FileLock(dbHome + "/__Freeze/lock"); _trace = properties->getPropertyAsInt("Freeze.Trace.DbEnv"); @@ -543,13 +551,11 @@ Freeze::SharedDbEnv::SharedDbEnv(const std::string& envName, { flags |= DB_PRIVATE; } - - + // // Auto delete // - bool autoDelete = (properties->getPropertyAsIntWithDefault( - propertyPrefix + ".OldLogsAutoDelete", 1) != 0); + bool autoDelete = (properties->getPropertyAsIntWithDefault(propertyPrefix + ".OldLogsAutoDelete", 1) != 0); if(autoDelete) { |