Skip to content

Commit

Permalink
JackClient: Lock before killing client notification thread
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
DeviLaxmii committed Aug 15, 2022
1 parent 03b8316 commit e933e28
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions common/JackClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e933e28

Please sign in to comment.