From 05c2144ac14cac000b57bc1b0ecec4c555a631a2 Mon Sep 17 00:00:00 2001 From: dimitr Date: Fri, 15 Apr 2011 16:35:00 +0000 Subject: [PATCH] Fixed possible deadlock between the shutting down engine and the running service. Reported by RedSoft. --- src/jrd/jrd.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 97ec4002bd..7439330dd0 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -6149,18 +6149,20 @@ static THREAD_ENTRY_DECLARE shutdown_thread(THREAD_ENTRY_PARAM arg) { ThreadContextHolder tdbb; - MutexLockGuard guard(databases_mutex); + { // scope + MutexLockGuard guard(databases_mutex); - cancel_attachments(); + cancel_attachments(); - Database* dbb_next; - for (Database* dbb = databases; dbb; dbb = dbb_next) - { - dbb_next = dbb->dbb_next; - if (!shutdown_dbb(tdbb, dbb)) + Database* dbb_next; + for (Database* dbb = databases; dbb; dbb = dbb_next) { - success = false; - break; + dbb_next = dbb->dbb_next; + if (!shutdown_dbb(tdbb, dbb)) + { + success = false; + break; + } } }