mirror of
https://github.com/RPCS3/libusb.git
synced 2026-01-31 01:25:19 +01:00
Windows: Fix race condition between submit and handle events
Check the event object for completion in poll instead of using HasOverlappedIoCompleted. When we submit a transfer on Windows the fd is added to the poll list before the read/write begins, so HasOverlappedIoCompleted can be called before overlapped.Internal is set to ERROR_IO_PENDING if events are being being handled concurrently, so the fd will be marked as completed before it has actually started. [dickens] Instead of replacing HasOverlappedIoCompleted, supplement it so that it can provide a fast path to avoid WaitForSingleObject() in the general case Closes #386, Closes #387 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
This commit is contained in:
committed by
Chris Dickens
parent
cd7aeec8e7
commit
32617df714
@@ -149,8 +149,8 @@ static int check_pollfds(struct pollfd *fds, unsigned int nfds,
|
||||
continue;
|
||||
}
|
||||
|
||||
// The following macro only works if overlapped I/O was reported pending
|
||||
if (HasOverlappedIoCompleted(&fd->overlapped)) {
|
||||
if (HasOverlappedIoCompleted(&fd->overlapped)
|
||||
&& (WaitForSingleObject(fd->overlapped.hEvent, 0) == WAIT_OBJECT_0)) {
|
||||
fds[n].revents = fds[n].events;
|
||||
nready++;
|
||||
} else if (wait_handles != NULL) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define LIBUSB_NANO 11298
|
||||
#define LIBUSB_NANO 11299
|
||||
|
||||
Reference in New Issue
Block a user