diff options
author | Mark Spruiell <mes@zeroc.com> | 2010-05-28 15:21:24 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2010-05-28 15:21:24 -0700 |
commit | 74581003486030ea874707085d5bf7cdce28f501 (patch) | |
tree | b6007dfaeb37919c52e84dbd6454528e8b914a6f /java/src/Freeze/SharedDbEnv.java | |
parent | Bug 4754 - VS plugin properties not working with VS2010 (diff) | |
download | ice-74581003486030ea874707085d5bf7cdce28f501.tar.bz2 ice-74581003486030ea874707085d5bf7cdce28f501.tar.xz ice-74581003486030ea874707085d5bf7cdce28f501.zip |
bug 4714 - FreezeScript utilities do not work on an open environment
Diffstat (limited to 'java/src/Freeze/SharedDbEnv.java')
-rw-r--r-- | java/src/Freeze/SharedDbEnv.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/java/src/Freeze/SharedDbEnv.java b/java/src/Freeze/SharedDbEnv.java index 1bd5ccf232d..ccdf4821d29 100644 --- a/java/src/Freeze/SharedDbEnv.java +++ b/java/src/Freeze/SharedDbEnv.java @@ -280,15 +280,30 @@ public class SharedDbEnv implements com.sleepycat.db.ErrorHandler, Runnable throw new DatabaseException("DbHome directory `" + dbHome + "' does not exists"); } - dir = new java.io.File(dbHome + "/__Freeze"); - if(!dir.exists()) + // + // 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(properties.getPropertyAsIntWithDefault(propertyPrefix + ".LockFile", 1) > 0) { - if(!dir.mkdir()) + // + // 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). + // + dir = new java.io.File(dbHome + "/__Freeze"); + if(!dir.exists()) { - throw new DatabaseException("Failed to create directory `" + dbHome + "/__Freeze'"); + if(!dir.mkdir()) + { + throw new DatabaseException("Failed to create directory `" + dbHome + "/__Freeze'"); + } } + _fileLock = new IceUtilInternal.FileLock(dbHome + "/__Freeze/lock"); } - _fileLock = new IceUtilInternal.FileLock(dbHome + "/__Freeze/lock"); + try { if(_ownDbEnv) |