Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix shutdown race with hotplug_libusb rescan pipe
Fix the possibility that the hotplug_libusb rescan thread remains read()'ing from the rescan pipe throughout the daemon shutdown process. This is possible because the |rescan_pipe| is created with some delay after the hotplug mechanism is initialized: HPEstablishUSBNotifications() first notifies about the initialization via writing to |pipefd|, and only then creates |rescan_pipe|. So if HPStopHotPluggables() is called in between, it'll end up doing nothing, letting the hotplug thread sit infinitely long on the read() call meanwhile the main daemon thread is shutting down. The proposed fix is to create |rescan_pipe| in advance, so that the shutdown logic is guaranteed to be able to write a byte to it, notifying the background thread about the shutdown regardless of when it happens.
- Loading branch information