Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
macOS: forcely ignore wait failures when closing down
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed Jan 30, 2023
1 parent d2d4415 commit f5a0199
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 8 additions & 0 deletions common/JackClient.cpp
@@ -1,6 +1,7 @@
/*
Copyright (C) 2001 Paul Davis
Copyright (C) 2004-2008 Grame
Copyright (C) 2016-2023 Filipe Coelho <falktx@falktx.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -638,6 +639,13 @@ inline bool JackClient::WaitSync()
{
// Suspend itself: wait on the input synchro
if (GetGraphManager()->SuspendRefNum(GetClientControl(), fSynchroTable, LONG_MAX) < 0) {
#ifdef __APPLE__
// FIXME macOS reports wait failures when closing down, due to aborted semaphore, ignore it
if (!GetClientControl()->fActive) {
fThread.Terminate();
return true;
}
#endif
jack_error("SuspendRefNum error");
return false;
} else {
Expand Down
17 changes: 13 additions & 4 deletions macosx/JackMachSemaphore.mm
@@ -1,5 +1,6 @@
/*
Copyright (C) 2004-2008 Grame
Copyright (C) 2016-2023 Filipe Coelho <falktx@falktx.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -92,11 +93,15 @@

kern_return_t res = semaphore_wait(fSemaphore);

// killing a thread will abort the semaphore wait
if (res == KERN_SUCCESS || res == KERN_ABORTED) {
if (res == KERN_SUCCESS) {
return true;
}

// killing a thread will abort the semaphore wait, skip the error log
if (res == KERN_ABORTED) {
return false;
}

jack_error("JackMachSemaphore::Wait name = %s err = %s", fName, mach_error_string(res));
return false;
}
Expand All @@ -114,11 +119,15 @@

kern_return_t res = semaphore_timedwait(fSemaphore, time);

// killing a thread will abort the semaphore wait
if (res == KERN_SUCCESS || res == KERN_ABORTED) {
if (res == KERN_SUCCESS) {
return true;
}

// killing a thread will abort the semaphore wait, skip the error log
if (res == KERN_ABORTED) {
return false;
}

jack_error("JackMachSemaphore::TimedWait name = %s usec = %ld err = %s", fName, usec, mach_error_string(res));
return false;
}
Expand Down

0 comments on commit f5a0199

Please sign in to comment.