diff --git a/include/ircd/json/stack.h b/include/ircd/json/stack.h index 7ed4f015d..a6ec44ffc 100644 --- a/include/ircd/json/stack.h +++ b/include/ircd/json/stack.h @@ -268,10 +268,9 @@ struct ircd::json::stack::checkpoint bool exception_rollback {true}; public: - bool committing() const; ///< When false, destructor will rollback() - bool recommit(); ///< Sets committing() to true. - bool decommit(); ///< Sets committing() to false. - bool rollback(); ///< Performs rollback of buffer. + bool committing() const noexcept; ///< When false, destructor will rollback() + bool committing(const bool &) noexcept; ///< Sets committing() to value. + bool rollback(); ///< Performs rollback of buffer. checkpoint(stack &s, const bool &committed = true, @@ -351,3 +350,19 @@ ircd::json::stack::object::append(const json::tuple &t) }; }); } + +inline bool +ircd::json::stack::checkpoint::committing(const bool &committed) +noexcept +{ + const bool ret(this->committed); + this->committed = committed; + return ret; +} + +inline bool +ircd::json::stack::checkpoint::committing() +const noexcept +{ + return committed; +} diff --git a/ircd/json.cc b/ircd/json.cc index 4ab21306e..778e58e40 100644 --- a/ircd/json.cc +++ b/ircd/json.cc @@ -1731,7 +1731,7 @@ ircd::json::stack::checkpoint::~checkpoint() noexcept { if(std::uncaught_exceptions() && exception_rollback) - decommit(); + committing(false); if(!committing()) rollback(); @@ -1772,31 +1772,10 @@ ircd::json::stack::checkpoint::rollback() else if(top.m) top.m->vc = vc; - recommit(); + committing(true); return true; } -bool -ircd::json::stack::checkpoint::decommit() -{ - committed = false; - return true; -} - -bool -ircd::json::stack::checkpoint::recommit() -{ - committed = true; - return true; -} - -bool -ircd::json::stack::checkpoint::committing() -const -{ - return committed; -} - // // chase // diff --git a/matrix/room_auth.cc b/matrix/room_auth.cc index 695603bdc..adf668606 100644 --- a/matrix/room_auth.cc +++ b/matrix/room_auth.cc @@ -40,7 +40,7 @@ ircd::m::room::auth::generate(const mutable_buffer &buf, { json::stack::array array{out}; if(!generate(array, room, event)) - cp.decommit(); + cp.committing(false); } return json::array{out.completed()}; diff --git a/modules/client/sync.cc b/modules/client/sync.cc index 8054ccab6..cb97a3f1b 100644 --- a/modules/client/sync.cc +++ b/modules/client/sync.cc @@ -478,7 +478,7 @@ try ret = true; data.out->invalidate_checkpoints(); } - else checkpoint.decommit(); + else checkpoint.committing(false); return true; }); @@ -518,7 +518,7 @@ try } if(!ret) - checkpoint.decommit(); + checkpoint.committing(false); if(!data.phased && stats_info) log::info { @@ -618,7 +618,7 @@ try json::merge(top, vector); } - else checkpoint.decommit(); + else checkpoint.committing(false); log::debug { diff --git a/modules/client/sync/rooms.cc b/modules/client/sync/rooms.cc index 9d7354e28..c1e4d3dde 100644 --- a/modules/client/sync/rooms.cc +++ b/modules/client/sync/rooms.cc @@ -262,13 +262,13 @@ ircd::m::sync::_rooms_polylog_room(data &data, ret = true; data.out->invalidate_checkpoints(); } - else checkpoint.decommit(); + else checkpoint.committing(false); return true; }); if(!ret) - checkpoint.decommit(); + checkpoint.committing(false); return ret; } diff --git a/modules/federation/make_join.cc b/modules/federation/make_join.cc index c5304b8b5..7df1c54c8 100644 --- a/modules/federation/make_join.cc +++ b/modules/federation/make_join.cc @@ -152,7 +152,7 @@ get__make_join(client &client, }; if(!m::room::auth::generate(auth_events, room, m::event{args})) - cp.decommit(); + cp.committing(false); } json::stack::member diff --git a/modules/federation/make_leave.cc b/modules/federation/make_leave.cc index 7944c46c7..d4b4695c9 100644 --- a/modules/federation/make_leave.cc +++ b/modules/federation/make_leave.cc @@ -139,7 +139,7 @@ get__make_leave(client &client, }; if(!m::room::auth::generate(auth_events, room, m::event{args})) - cp.decommit(); + cp.committing(false); } json::stack::member