Skip to content

Commit

Permalink
JackPosixProcessSync: Fix mutex owner on TimedWait() timeout.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
0EVSG committed Dec 9, 2023
1 parent f14409b commit 886b35c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion posix/JackPosixProcessSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 886b35c

Please sign in to comment.