From d822bf32e470e46a3634638fee3c4b1472d2cd26 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 1 Mar 2006 16:36:35 +0000 Subject: * Close the database before the destructor runs. --- src/libstore/db.cc | 2 ++ src/libstore/store.cc | 7 +++++++ src/libstore/store.hh | 3 +++ 3 files changed, 12 insertions(+) (limited to 'src/libstore') diff --git a/src/libstore/db.cc b/src/libstore/db.cc index 448b70e6c..667951ae7 100644 --- a/src/libstore/db.cc +++ b/src/libstore/db.cc @@ -278,6 +278,8 @@ void Database::close() } catch (DbException e) { rethrow(e); } delete env; + + env = 0; } diff --git a/src/libstore/store.cc b/src/libstore/store.cc index 94c992f22..e792fd28c 100644 --- a/src/libstore/store.cc +++ b/src/libstore/store.cc @@ -136,6 +136,13 @@ void initDB() } +void closeDB() +{ + /* If the database isn't open, this is a NOP. */ + nixDB.close(); +} + + void createStoreTransaction(Transaction & txn) { Transaction txn2(nixDB); diff --git a/src/libstore/store.hh b/src/libstore/store.hh index c617585ba..a170c69e7 100644 --- a/src/libstore/store.hh +++ b/src/libstore/store.hh @@ -49,6 +49,9 @@ void openDB(bool reserveSpace = true); /* Create the required database tables. */ void initDB(); +/* Close the database. */ +void closeDB(); + /* Get a transaction object. */ void createStoreTransaction(Transaction & txn); -- cgit v1.2.3