about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-01-13T12·36+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-01-13T12·36+0000
commit698e880c9f03b3aaade13897de3498a5915ea8fd (patch)
tree78553b79064359f2fd06aa79c9d0783888a14eb0
parent23fbc72f5d65725dd1804efe695aaa84580a8637 (diff)
* Tricky: make sure that the accessor count is not reset to 0 if
  recovery fails.

-rw-r--r--src/libstore/db.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libstore/db.cc b/src/libstore/db.cc
index 72823be8bbf6..057371ef50b5 100644
--- a/src/libstore/db.cc
+++ b/src/libstore/db.cc
@@ -155,6 +155,7 @@ void Database::open(const string & path)
 
 
         /* Create the database environment object. */
+        DbEnv * env = 0; /* !!! close on error */
         env = new DbEnv(0);
 
         env->set_lg_bsize(32 * 1024); /* default */
@@ -199,7 +200,6 @@ void Database::open(const string & path)
                other readers or writers. */
 
             int n = getAccessorCount(fdAccessors);
-            setAccessorCount(fdAccessors, 1);
 
             if (n != 0) {
                 printMsg(lvlTalkative,
@@ -213,6 +213,8 @@ void Database::open(const string & path)
                 /* Open the environment normally. */
                 openEnv(env, path, 0);
 
+            setAccessorCount(fdAccessors, 1);
+
             /* Downgrade to a read lock. */
             debug(format("downgrading to read lock on `%1%'") % lockPath);
             lockFile(fdLock, ltRead, true);
@@ -236,6 +238,8 @@ void Database::open(const string & path)
             openEnv(env, path, 0);
         }
 
+        this->env = env;
+        
     } catch (DbException e) { rethrow(e); }
 }