Skip to content

Commit

Permalink
hidapi/mac: import mainstream commit c1b9d2ad
Browse files Browse the repository at this point in the history
libusb/hidapi@c1b9d2a
Properly handle the close of run loop on macOS
(libusb/hidapi#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;

(cherry picked from commit 62d1a2c)
  • Loading branch information
sezero authored and slouken committed Apr 24, 2023
1 parent a688ecd commit 5f344c1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hidapi/mac/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ static void *read_thread(void *param)
while (!dev->shutdown_thread && !dev->disconnected) {
code = CFRunLoopRunInMode(dev->run_loop_mode, 1000/*sec*/, FALSE);
/* Return if the device has been disconnected */
if (code == kCFRunLoopRunFinished) {
if (code == kCFRunLoopRunFinished || code == kCFRunLoopRunStopped) {
dev->disconnected = 1;
break;
}
Expand Down

0 comments on commit 5f344c1

Please sign in to comment.