From 698e880c9f03b3aaade13897de3498a5915ea8fd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 13 Jan 2004 12:36:43 +0000 Subject: [PATCH] * Tricky: make sure that the accessor count is not reset to 0 if recovery fails. --- src/libstore/db.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstore/db.cc b/src/libstore/db.cc index 72823be8b..057371ef5 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); } }