aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-05-14 13:06:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-05-14 13:06:20 +0200
commit00a601a9268d7c85be2147a2b7af9f855ea7d957 (patch)
treeeecfbbb445d63335e4db0ac5da9ae7612f8bd61e
parent582ff699fd099ba066f31e1fc0ea4c9551ed1cd5 (diff)
Fix nested transaction issue in sync
-rw-r--r--bdep/sync.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index 19afdce..651f6ad 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -123,11 +123,27 @@ namespace bdep
{
using query = bdep::query<configuration>;
- database db (open (d, trace));
+ // Save and restore the current transaction, if any.
+ //
+ transaction* ct (nullptr);
+ if (transaction::has_current ())
+ {
+ ct = &transaction::current ();
+ transaction::reset_current ();
+ }
- transaction t (db.begin ());
- c = db.query_one<configuration> (query::path == cfg.string ());
- t.commit ();
+ auto tg (make_guard ([ct] ()
+ {
+ if (ct != nullptr)
+ transaction::current (*ct);
+ }));
+
+ {
+ database db (open (d, trace));
+ transaction t (db.begin ());
+ c = db.query_one<configuration> (query::path == cfg.string ());
+ t.commit ();
+ }
}
// If the project is a repository of this configuration but the bdep