Fix a race condition with libusb_interrupt_event_handler().
authorLars Kanis <lars@greiz-reinsdorf.de>
Sun, 27 Nov 2016 16:41:01 +0000 (17:41 +0100)
committerHans de Goede <hdegoede@redhat.com>
Mon, 28 Nov 2016 08:25:33 +0000 (09:25 +0100)
commita90331a3be0a7919dfd256d700c38cfad5718575
treef3794d8885931e57b2188f5653b2a3f8a0e59d8f
parent0a02d1212bfb7ff2e9f3fc603655b0220b7d6889
Fix a race condition with libusb_interrupt_event_handler().

USBI_EVENT_USER_INTERRUPT isn't set in case of another pending event. When
libusb_interrupt_event_handler() is called and USBI_EVENT_POLLFDS_MODIFIED is
already set, but libusb_handle_events() isn't currently active waiting in
poll(), the interrupt request will be cleared before poll() is called. poll()
therefore blocks and the event handler doesn't return.

This is especially the case, when libusb_interrupt_event_handler() is called
before the first call to libusb_handle_events(). In this case
libusb_handle_events() blocks instead of returning immediately.

This patch fixes the race condition by setting the event flag the same way a
usbi_fd_notification().

Signed-off-by: Lars Kanis <lars@greiz-reinsdorf.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
libusb/io.c