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

Method shutdown

src/jrd/jrd.cpp:4611–4693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4609
4610
4611void JProvider::shutdown(CheckStatusWrapper* status, unsigned int timeout, const int reason)
4612{
4613/**************************************
4614 *
4615 * G D S _ S H U T D O W N
4616 *
4617 **************************************
4618 *
4619 * Functional description
4620 * Rollback every transaction, release
4621 * every attachment, and shutdown every
4622 * database.
4623 *
4624 **************************************/
4625 try
4626 {
4627 { // scope
4628 MutexLockGuard guard(shutdownMutex, FB_FUNCTION);
4629
4630 if (engineShutdown)
4631 {
4632 return;
4633 }
4634 { // scope
4635 MutexLockGuard guard(newAttachmentMutex, FB_FUNCTION);
4636 engineShutdown = true;
4637 }
4638
4639 ThreadContextHolder tdbb;
4640 WorkerAttachment::shutdown();
4641 EDS::Manager::shutdown();
4642
4643 ULONG attach_count, database_count, svc_count;
4644 JRD_enum_attachments(NULL, attach_count, database_count, svc_count);
4645
4646 if (attach_count > 0 || svc_count > 0)
4647 {
4648 gds__log("Shutting down the server with %d active connection(s) to %d database(s), "
4649 "%d active service(s)",
4650 attach_count, database_count, svc_count);
4651 }
4652
4653 if (reason == fb_shutrsn_exit_called)
4654 {
4655 // Starting threads may fail when task is going to close.
4656 // This happens at least with some microsoft C runtimes.
4657 // If people wish to have timeout, they should better call fb_shutdown() themselves.
4658 // Therefore:
4659 timeout = 0;
4660 }
4661
4662 if (timeout)
4663 {
4664 Semaphore shutdown_semaphore;
4665
4666 Thread shutThd;
4667 Thread::start(shutdown_thread, &shutdown_semaphore, THREAD_medium, &shutThd);
4668

Callers 6

shutdownBeforeUnloadFunction · 0.45
freeEngineDataMethod · 0.45
release_attachmentFunction · 0.45
JRD_shutdown_databaseFunction · 0.45
releaseLocksMethod · 0.45
~GlobalObjectHolderMethod · 0.45

Calls 10

shutdownFunction · 0.85
JRD_enum_attachmentsFunction · 0.85
waitForShutdownFunction · 0.85
shutdown_threadFunction · 0.85
iscLogStatusFunction · 0.85
startFunction · 0.50
tryEnterMethod · 0.45
waitForCompletionMethod · 0.45
joinMethod · 0.45
stuffExceptionMethod · 0.45

Tested by

no test coverage detected