From e7cb3fd1afec831f9da7e5bdfb5847cd437aef61 Mon Sep 17 00:00:00 2001 From: Florian Walpen Date: Sun, 30 Jul 2023 21:17:44 +0200 Subject: [PATCH] JackPosixProcessSync: Fix mutex owner on TimedWait() timeout. Per POSIX definition, pthread_cond_timedwait() re-acquires the mutex when a timeout occurs and ETIMEDOUT is returned. In that case also mark the waiting thread as owner again, for consistency. Otherwise subsequent attempts to unlock the mutex will fail, leaving the mutex locked forever. --- posix/JackPosixProcessSync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posix/JackPosixProcessSync.cpp b/posix/JackPosixProcessSync.cpp index 04c8785f4..9812edf29 100644 --- a/posix/JackPosixProcessSync.cpp +++ b/posix/JackPosixProcessSync.cpp @@ -122,7 +122,7 @@ bool JackPosixProcessSync::TimedWait(long usec) time.tv_nsec = (next_date_usec % 1000000) * 1000; res = pthread_cond_timedwait(&fCond, &fMutex, &time); - if (res != 0) { + if (res != 0 && res != ETIMEDOUT) { jack_error("JackPosixProcessSync::TimedWait error usec = %ld err = %s", usec, strerror(res)); } else { fOwner = pthread_self();