Skip to content

Commit c1b9d2a

Browse files
authored
Properly handle the close of run loop on macOS (#522)
- as per documentation `kCFRunLoopRunStopped` should be handled once the runloop is closed via `CFRunLoopStop`; - if it is not handled - a race condition/crash may happen on the latest macOS when a device gets disconnected while being open;
1 parent ad4a972 commit c1b9d2a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mac/hid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ static void *read_thread(void *param)
877877
while (!dev->shutdown_thread && !dev->disconnected) {
878878
code = CFRunLoopRunInMode(dev->run_loop_mode, 1000/*sec*/, FALSE);
879879
/* Return if the device has been disconnected */
880-
if (code == kCFRunLoopRunFinished) {
880+
if (code == kCFRunLoopRunFinished || code == kCFRunLoopRunStopped) {
881881
dev->disconnected = 1;
882882
break;
883883
}

0 commit comments

Comments
 (0)