From e933e28dcacad0e8acc614287423783c4098d485 Mon Sep 17 00:00:00 2001 From: Laxmi Devi Date: Mon, 15 Aug 2022 15:08:06 +0530 Subject: [PATCH] JackClient: Lock before killing client notification thread The client notification thread locks a mutex before reading/writing from/to the socket. If the thread is killed while the lock is taken it would leave the mutex dangling. To avoid this take the mutex and then kill the client notification thread. Signed-off-by: Laxmi Devi --- common/JackClient.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/JackClient.cpp b/common/JackClient.cpp index 5befdfbde..42374c7d1 100644 --- a/common/JackClient.cpp +++ b/common/JackClient.cpp @@ -107,14 +107,17 @@ int JackClient::Close() int result = 0; Deactivate(); + + assert(JackGlobals::fSynchroMutex); // Channels is stopped first to avoid receiving notifications while closing - fChannel->Stop(); + JackGlobals::fSynchroMutex->Lock(); + fChannel->Stop(); + JackGlobals::fSynchroMutex->Unlock(); // Then close client fChannel->ClientClose(GetClientControl()->fRefNum, &result); fChannel->Close(); - assert(JackGlobals::fSynchroMutex); JackGlobals::fSynchroMutex->Lock(); fSynchroTable[GetClientControl()->fRefNum].Disconnect(); JackGlobals::fSynchroMutex->Unlock();