mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
Deregistration of hid_device_removal_callback fails because the call to IOHIDDeviceRegisterRemovalCallback doesn't deregister it as it should. This causes crashes when hid_device_removal_callback is called after the read_thread has been shutdown. This patch works around this problem by: 1) Letting the 'dev' hid_device, so that the callback can safely read the struct, even after the read_thread has been shut down and the memory should have been freed. 2) Making sure that the two racing callbacks that previously called CFRunLoopStop, hid_device_removal_callback and perform_signal_callback, now synchronize and make sure that CFRunLoopStop is only called once.