* Close the database before the destructor runs.

This commit is contained in:
Eelco Dolstra 2006-03-01 16:36:35 +00:00
parent fa95f4be3f
commit d822bf32e4
4 changed files with 15 additions and 0 deletions

View file

@ -14,6 +14,7 @@ extern "C" {
#include "globals.hh" #include "globals.hh"
#include "gc.hh" #include "gc.hh"
#include "store.hh"
#include "shared.hh" #include "shared.hh"
#include "config.h" #include "config.h"
@ -213,6 +214,8 @@ static void initAndRun(int argc, char * * argv)
RemoveTempRoots removeTempRoots; /* unused variable - don't remove */ RemoveTempRoots removeTempRoots; /* unused variable - don't remove */
run(remaining); run(remaining);
closeDB(); /* it's fine if the DB isn't actually open */
} }

View file

@ -278,6 +278,8 @@ void Database::close()
} catch (DbException e) { rethrow(e); } } catch (DbException e) { rethrow(e); }
delete env; delete env;
env = 0;
} }

View file

@ -136,6 +136,13 @@ void initDB()
} }
void closeDB()
{
/* If the database isn't open, this is a NOP. */
nixDB.close();
}
void createStoreTransaction(Transaction & txn) void createStoreTransaction(Transaction & txn)
{ {
Transaction txn2(nixDB); Transaction txn2(nixDB);

View file

@ -49,6 +49,9 @@ void openDB(bool reserveSpace = true);
/* Create the required database tables. */ /* Create the required database tables. */
void initDB(); void initDB();
/* Close the database. */
void closeDB();
/* Get a transaction object. */ /* Get a transaction object. */
void createStoreTransaction(Transaction & txn); void createStoreTransaction(Transaction & txn);