MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / shutdown_thread

Function shutdown_thread

src/jrd/jrd.cpp:8996–9063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8994
8995
8996static THREAD_ENTRY_DECLARE shutdown_thread(THREAD_ENTRY_PARAM arg)
8997{
8998/**************************************
8999 *
9000 * s h u t d o w n _ t h r e a d
9001 *
9002 **************************************
9003 *
9004 * Functional description
9005 * Shutdown the engine.
9006 *
9007 **************************************/
9008 Semaphore* const semaphore = static_cast<Semaphore*>(arg);
9009
9010 bool success = true;
9011 MemoryPool& pool = *getDefaultMemoryPool();
9012 AttachmentsRefHolder* const attachments = FB_NEW_POOL(pool) AttachmentsRefHolder(pool);
9013
9014 try
9015 {
9016 { // scope
9017 MutexLockGuard guard(databases_mutex, FB_FUNCTION);
9018
9019 for (Database* dbb = databases; dbb; dbb = dbb->dbb_next)
9020 {
9021 if (!(dbb->dbb_flags & DBB_bugcheck))
9022 {
9023 Sync dbbGuard(&dbb->dbb_sync, FB_FUNCTION);
9024 dbbGuard.lock(SYNC_EXCLUSIVE);
9025
9026 for (Attachment* att = dbb->dbb_attachments; att; att = att->att_next)
9027 attachments->add(att->getStable());
9028 }
9029 }
9030 // No need in databases_mutex any more
9031 }
9032
9033 // Shutdown existing attachments
9034 success = success && shutdownAttachments(attachments, isc_att_shut_engine);
9035
9036 HalfStaticArray<Database*, 32> dbArray(pool);
9037 { // scope
9038 MutexLockGuard guard(databases_mutex, FB_FUNCTION);
9039
9040 for (Database* dbb = databases; dbb; dbb = dbb->dbb_next)
9041 dbArray.push(dbb);
9042
9043 // No need in databases_mutex any more
9044 }
9045
9046 for (unsigned n = 0; n < dbArray.getCount(); ++n)
9047 JRD_shutdown_database(dbArray[n], SHUT_DBB_RELEASE_POOLS);
9048
9049 // Extra shutdown operations
9050 Service::shutdownServices();
9051 TRA_shutdown_sweep();
9052 }
9053 catch (const Exception& ex)

Callers 1

shutdownMethod · 0.85

Calls 12

getDefaultMemoryPoolFunction · 0.85
shutdownAttachmentsFunction · 0.85
JRD_shutdown_databaseFunction · 0.85
TRA_shutdown_sweepFunction · 0.85
iscLogExceptionFunction · 0.85
lockMethod · 0.45
addMethod · 0.45
getStableMethod · 0.45
pushMethod · 0.45
getCountMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected