Browse Source

macOS: killing a thread will abort the semaphore wait

Signed-off-by: falkTX <falktx@falktx.com>
tags/v1.9.22
falkTX 1 year ago
parent
commit
79ea0746fa
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
1 changed files with 16 additions and 8 deletions
  1. +16
    -8
      macosx/JackMachSemaphore.mm

+ 16
- 8
macosx/JackMachSemaphore.mm View File

@@ -90,11 +90,15 @@ bool JackMachSemaphore::Wait()
return false;
}

kern_return_t res;
if ((res = semaphore_wait(fSemaphore)) != KERN_SUCCESS) {
jack_error("JackMachSemaphore::Wait name = %s err = %s", fName, mach_error_string(res));
kern_return_t res = semaphore_wait(fSemaphore);

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

jack_error("JackMachSemaphore::Wait name = %s err = %s", fName, mach_error_string(res));
return false;
}

bool JackMachSemaphore::TimedWait(long usec)
@@ -104,15 +108,19 @@ bool JackMachSemaphore::TimedWait(long usec)
return false;
}

kern_return_t res;
mach_timespec time;
time.tv_sec = usec / 1000000;
time.tv_nsec = (usec % 1000000) * 1000;

if ((res = semaphore_timedwait(fSemaphore, time)) != KERN_SUCCESS) {
jack_error("JackMachSemaphore::TimedWait name = %s usec = %ld err = %s", fName, usec, mach_error_string(res));
kern_return_t res = semaphore_timedwait(fSemaphore, time);

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

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

/*! \brief Server side: create semaphore and publish IPC primitives to make it accessible.


Loading…
Cancel
Save