core: Improve the handling of the pollfd list
authorChris Dickens <christopher.a.dickens@gmail.com>
Sun, 21 Dec 2014 22:58:35 +0000 (14:58 -0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Mon, 29 Dec 2014 20:19:55 +0000 (12:19 -0800)
commit4c28cd8593cbbca234a1fa0b9b84f4356fd00796
tree6dfca103d53b286b269b637a7e07d331ecf6c010
parent89b5407b9aa74790a64b6f32a5b14a96242ba128
core: Improve the handling of the pollfd list

This change consists of two parts that must be taken together.

Part 1 moves the pollfd list under the protection of event_data_lock
and eliminates the pollfd_lock. Since modifications to the pollfd
list are considered an event, it makes sense to merge this. Another
benefit of doing so is an enhancement to event handling. The event
handler can get the updated pollfd list upon entry into handle_events()
and can clear the event pipe if no other pending events exist, which
saves a needless iteration.

Part 2 makes notification of pollfd list changes part of adding or
removing a pollfd from the list. Previously this was done in two
distinct steps, however nothing prevented a new pollfd from being
used by an event handler before an explicit notification was sent out.
This change eliminates the need for USBI_TRANSFER_UPDATED_FDS and
reverts 9a9ef3ec2b9c691609ec9f8b82ac4436a662df18.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/core.c
libusb/io.c
libusb/libusbi.h
libusb/os/darwin_usb.c
libusb/os/linux_usbfs.c
libusb/os/netbsd_usb.c
libusb/os/openbsd_usb.c
libusb/os/wince_usb.c
libusb/os/windows_usb.c