Windows: Rework poll() emulation to a much simpler and effective design

The previous poll() implementation worked okay but had some issues. It
was inefficient, had a large footprint, and there were simply some use
cases that didn't work (e.g. a synchronous transfer that completes when
no other event or transfer is pending would not be processed until the
next poll() timeout).

This commit introduces a new, simpler design that simply associates an
OVERLAPPED structure to an integer that acts as a file descriptor. The
poll() emulation now solely cares about the OVERLAPPED structure, not
transfers or HANDLEs or cancelation functions. These details have been
moved up into the higher OS-specific layers.

For Windows NT environments, several deficiencies have been addressed:

1) It was previously possible to successfully submit a transfer but fail
   to add the "file descriptor" to the pollfd set. This was silently
   ignored and would result in the user never seeing the transfer being
   completed.

2) Synchronously completed transfers would previously not be processed
   unless another event (such as a timeout or other transfer completion)
   was processed.

3) Canceling any one transfer on an endpoint would previously result in
   *all* transfers on that endpoint being canceled, due to the use of
   the AbortPipe() function.

This commit addresses all of these issues. In particular, run-time
detection of the CancelIoEx() function will allow the user to cancel a
single outstanding transfer without affecting any others still in
process.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
10 files changed
tree: 2609450edece322a4421764a2d804fa7607a1214
  1. .private/
  2. android/
  3. doc/
  4. examples/
  5. libusb/
  6. msvc/
  7. tests/
  8. Xcode/
  9. .gitattributes
  10. .gitignore
  11. .travis.yml
  12. appveyor.yml
  13. appveyor_cygwin.bat
  14. appveyor_minGW.bat
  15. AUTHORS
  16. autogen.sh
  17. bootstrap.sh
  18. ChangeLog
  19. configure.ac
  20. COPYING
  21. INSTALL_WIN.txt
  22. libusb-1.0.pc.in
  23. Makefile.am
  24. NEWS
  25. PORTING
  26. README.git
  27. README.md
  28. TODO
  29. travis-autogen.sh
README.md

libusb

Build Status Build status Coverity Scan Build Status

libusb is a library for USB device access from Linux, Mac OS X, Windows, OpenBSD/NetBSD and Haiku userspace. It is written in C (Haiku backend in C++) and licensed under the GNU Lesser General Public License version 2.1 or, at your option, any later version (see COPYING).

libusb is abstracted internally in such a way that it can hopefully be ported to other operating systems. Please see the PORTING file for more information.

libusb homepage: http://libusb.info/

Developers will wish to consult the API documentation: http://api.libusb.info

Use the mailing list for questions, comments, etc: http://mailing-list.libusb.info

(Please use the mailing list rather than mailing developers directly)