From 8c0ee3ba2db18ba759a5be502a89d31f3288d32e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Mar 2016 15:50:44 +0200 Subject: Assert that statements are not already locked in top-level calls This can be violated with crafty callbacks. --- odb/relational/source.cxx | 2 ++ odb/relational/source.hxx | 1 + 2 files changed, 3 insertions(+) (limited to 'odb') diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx index e9ddd77..a20406a 100644 --- a/odb/relational/source.cxx +++ b/odb/relational/source.cxx @@ -3127,6 +3127,7 @@ traverse_object (type& c) // os << endl << "statements_type::auto_lock l (" << rsts << ");" + << "assert (l.locked ()) /* Must be a top-level call. */;" << endl; os << "if (!find_ (sts, &id" << @@ -3233,6 +3234,7 @@ traverse_object (type& c) // os << endl << "statements_type::auto_lock l (" << rsts << ");" + << "assert (l.locked ()) /* Must be a top-level call. */;" << endl; os << "const id_type& id (object_traits_impl::id (obj));" diff --git a/odb/relational/source.hxx b/odb/relational/source.hxx index eae49a5..ce031b1 100644 --- a/odb/relational/source.hxx +++ b/odb/relational/source.hxx @@ -2906,6 +2906,7 @@ namespace relational // This can only be top-level call so lock must succeed. // os << r_tr << "::statements_type::auto_lock l (sts);" + << "assert (l.locked ()) /* Must be a top-level call. */;" << endl << r_tr << "::id_image_type& i (sts.id_image ());" << r_tr << "::init (i, " << id << ");" -- cgit v1.1