about summary refs log tree commit diff
path: root/src/libstore/db.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-02-09T14·37+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-02-09T14·37+0000
commit3a99616968a7ffcc8f51bda7a781d3233aa9b428 (patch)
treee3c0fbc0856d868771b58b333006df670c7e9434 /src/libstore/db.cc
parent98df735b5149bc1e39ce6b0bae13fbf7cebcdc05 (diff)
* Commit more often to prevent out-of-memory errors.
Diffstat (limited to 'src/libstore/db.cc')
-rw-r--r--src/libstore/db.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/libstore/db.cc b/src/libstore/db.cc
index 4a815a5f90a8..82211bd1dee8 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");