diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 359200e590..354bdd7d66 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -230,6 +230,27 @@ namespace { #define TEXT SCHAR #endif // WIN_NT + +Jrd::Database::~Database() +{ + delete dbb_sys_trans; + destroyIntlObjects(); + + pool_ptr* itr = dbb_pools.begin(); + while (itr != dbb_pools.end()) + { + if (*itr && *itr == dbb_bufferpool) + dbb_bufferpool = 0; + if (*itr && *itr != dbb_permanent) + itr = JrdMemoryPool::deletePool(*itr); + else + ++itr; + } + if (dbb_bufferpool) + JrdMemoryPool::deletePool(dbb_bufferpool); +} + + void Jrd::Trigger::compile(thread_db* tdbb) { if (!request /*&& !compile_in_progress*/) diff --git a/src/jrd/jrd.h b/src/jrd/jrd.h index 59b5cf3f93..da6e96e401 100644 --- a/src/jrd/jrd.h +++ b/src/jrd/jrd.h @@ -334,23 +334,7 @@ private: dbb_pools.resize(1); } - ~Database() - { - destroyIntlObjects(); - - pool_ptr* itr = dbb_pools.begin(); - while (itr != dbb_pools.end()) - { - if (*itr && *itr == dbb_bufferpool) - dbb_bufferpool = 0; - if (*itr && *itr != dbb_permanent) - itr = JrdMemoryPool::deletePool(*itr); - else - ++itr; - } - if (dbb_bufferpool) - JrdMemoryPool::deletePool(dbb_bufferpool); - } + ~Database(); // temporal measure to avoid unstable state of lock file - // this is anyway called in ~Database(), and in theory should be private diff --git a/src/jrd/tra.cpp b/src/jrd/tra.cpp index e7ac1027a6..2345f681a9 100644 --- a/src/jrd/tra.cpp +++ b/src/jrd/tra.cpp @@ -1044,6 +1044,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction) * **************************************/ SET_TDBB(tdbb); + Database* dbb = tdbb->getDatabase(); if (transaction->tra_blobs.getFirst()) while (true) @@ -1152,11 +1153,7 @@ void TRA_release_transaction(thread_db* tdbb, jrd_tra* transaction) delete transaction->tra_db_snapshot; - // Release the transaction pool. - - JrdMemoryPool* tra_pool = transaction->tra_pool; - if (tra_pool) - JrdMemoryPool::deletePool(tra_pool); + jrd_tra::destroy(dbb, transaction); } diff --git a/src/jrd/tra.h b/src/jrd/tra.h index 2b6b926c1c..ff857072f3 100644 --- a/src/jrd/tra.h +++ b/src/jrd/tra.h @@ -111,6 +111,18 @@ public: delete tra_blob_space; } + static void destroy(Database* const dbb, jrd_tra* const transaction) + { + if (transaction) + { + JrdMemoryPool* const pool = transaction->tra_pool; + delete transaction; + + if (pool) + JrdMemoryPool::deletePool(pool); + } + } + Attachment* tra_attachment; /* database attachment */ SLONG tra_number; /* transaction number */ SLONG tra_top; /* highest transaction in snapshot */