| 4609 | |
| 4610 | |
| 4611 | void 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 |
no test coverage detected