From 3a99616968a7ffcc8f51bda7a781d3233aa9b428 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 9 Feb 2005 14:37:24 +0000 Subject: * Commit more often to prevent out-of-memory errors. --- src/libstore/db.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/libstore/db.cc') diff --git a/src/libstore/db.cc b/src/libstore/db.cc index 4a815a5f90..82211bd1de 100644 --- a/src/libstore/db.cc +++ b/src/libstore/db.cc @@ -33,11 +33,9 @@ Transaction::Transaction() Transaction::Transaction(Database & db) + : txn(0) { - db.requireEnv(); - try { - db.env->txn_begin(0, &txn, 0); - } catch (DbException e) { rethrow(e); } + begin(db); } @@ -47,6 +45,16 @@ Transaction::~Transaction() } +void Transaction::begin(Database & db) +{ + assert(txn == 0); + db.requireEnv(); + try { + db.env->txn_begin(0, &txn, 0); + } catch (DbException e) { rethrow(e); } +} + + void Transaction::commit() { if (!txn) throw Error("commit called on null transaction"); -- cgit 1.4.1