MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / ~GlobalObjectHolder

Method ~GlobalObjectHolder

src/jrd/Database.cpp:655–688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653 }
654
655 Database::GlobalObjectHolder::~GlobalObjectHolder()
656 {
657 // dtor is executed under g_mutex protection
658
659 // Stole the object from the hash table without incrementing ref counter, so we will be the one who will delete the object
660 // at the end of this function.
661 RefPtr<Database::GlobalObjectHolder::DbId> entry(REF_NO_INCR, g_hashTable->lookup(m_id));
662 fb_assert(entry);
663 fb_assert(entry->holder == this);
664 // We need to unlock the global mutex to safely shutdown some managers, so lock shutdown mutex to make sure that
665 // other threads will wait until we done our shutdown routine.
666 // This is done to eliminate potential race conditions involving global objects, such as shared memory.
667 //! Be careful with order of mutex locking: first - `g_mutex`, second - `shutdownMutex`, but after `MutexUnlockGuard`
668 //! this order will be reversed, so potentially a deadlock situation may occur here.
669 MutexLockGuard guard(entry->shutdownMutex, FB_FUNCTION);
670
671 { // scope
672 // here we cleanup what should not be globally protected
673 MutexUnlockGuard guard(g_mutex, FB_FUNCTION);
674 if (m_replMgr)
675 m_replMgr->shutdown();
676 }
677
678 m_lockMgr = nullptr;
679 m_eventMgr = nullptr;
680 m_replMgr = nullptr;
681
682 if (!g_hashTable->remove(m_id))
683 fb_assert(false);
684
685 entry->holder = nullptr;
686
687 fb_assert(m_tempCacheUsage == 0);
688 }
689
690 LockManager* Database::GlobalObjectHolder::getLockManager()
691 {

Callers

nothing calls this directly

Calls 3

lookupMethod · 0.45
shutdownMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected