Skip to content

Commit f5a0199

Browse files
committed
macOS: forcely ignore wait failures when closing down
Signed-off-by: falkTX <[email protected]>
1 parent d2d4415 commit f5a0199

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

common/JackClient.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
Copyright (C) 2001 Paul Davis
33
Copyright (C) 2004-2008 Grame
4+
Copyright (C) 2016-2023 Filipe Coelho <[email protected]>
45
56
This program is free software; you can redistribute it and/or modify
67
it under the terms of the GNU Lesser General Public License as published by
@@ -638,6 +639,13 @@ inline bool JackClient::WaitSync()
638639
{
639640
// Suspend itself: wait on the input synchro
640641
if (GetGraphManager()->SuspendRefNum(GetClientControl(), fSynchroTable, LONG_MAX) < 0) {
642+
#ifdef __APPLE__
643+
// FIXME macOS reports wait failures when closing down, due to aborted semaphore, ignore it
644+
if (!GetClientControl()->fActive) {
645+
fThread.Terminate();
646+
return true;
647+
}
648+
#endif
641649
jack_error("SuspendRefNum error");
642650
return false;
643651
} else {

macosx/JackMachSemaphore.mm

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
Copyright (C) 2004-2008 Grame
3+
Copyright (C) 2016-2023 Filipe Coelho <[email protected]>
34
45
This program is free software; you can redistribute it and/or modify
56
it under the terms of the GNU Lesser General Public License as published by
@@ -92,11 +93,15 @@
9293

9394
kern_return_t res = semaphore_wait(fSemaphore);
9495

95-
// killing a thread will abort the semaphore wait
96-
if (res == KERN_SUCCESS || res == KERN_ABORTED) {
96+
if (res == KERN_SUCCESS) {
9797
return true;
9898
}
9999

100+
// killing a thread will abort the semaphore wait, skip the error log
101+
if (res == KERN_ABORTED) {
102+
return false;
103+
}
104+
100105
jack_error("JackMachSemaphore::Wait name = %s err = %s", fName, mach_error_string(res));
101106
return false;
102107
}
@@ -114,11 +119,15 @@
114119

115120
kern_return_t res = semaphore_timedwait(fSemaphore, time);
116121

117-
// killing a thread will abort the semaphore wait
118-
if (res == KERN_SUCCESS || res == KERN_ABORTED) {
122+
if (res == KERN_SUCCESS) {
119123
return true;
120124
}
121125

126+
// killing a thread will abort the semaphore wait, skip the error log
127+
if (res == KERN_ABORTED) {
128+
return false;
129+
}
130+
122131
jack_error("JackMachSemaphore::TimedWait name = %s usec = %ld err = %s", fName, usec, mach_error_string(res));
123132
return false;
124133
}

0 commit comments

Comments
 (0)