Pause event handling while opening and closing devices
authorDaniel Drake <dsd@gentoo.org>
Thu, 20 Nov 2008 15:31:10 +0000 (15:31 +0000)
committerDaniel Drake <dsd@gentoo.org>
Fri, 21 Nov 2008 10:44:34 +0000 (10:44 +0000)
commitc32aa662769b676ff3247778664fccc71fc427ec
treed3c27ca15790286996169038b27ce3116d401627
parent1d7cf3d0fa8698eae25097cbda1870be90ff6f5e
Pause event handling while opening and closing devices

Ludovic Rousseau found that crashes often occur if you close a device
while another thread is doing event handling.

Fix this by adding an internal control pipe, which the close routines
use to interrupt the event handler and obtain the event handling lock,
ensuring that no other thread is handling events while the device is
closed. After the close completes, it signals all the event handlers
to start up again using the usual mechanism.

Also modified libusb_open() to do a similar thing, so that event
handlers are interrupted in order to realise that a new poll fd has
appeared.
libusb/core.c
libusb/io.c
libusb/libusbi.h