Skip to content

Commit 824234a

Browse files
committed
Fixed HIDAPI controller disconnect reading on multiple threads
If multiple threads are calling SDL_UpdateJoysticks(), then an overlapped read can be initiated on one thread (read_pending set to true) and GetOverlappedResult() called on another thread. This results in ERROR_OPERATION_ABORTED. This is harmless so we shouldn't return an error in this case, we'll just retry the read on the next call. Fixes #14033 (cherry picked from commit b2188b3)
1 parent 6519158 commit 824234a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/hidapi/windows/hid.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,11 @@ int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char
13991399
}
14001400
}
14011401
if (!res) {
1402+
if (GetLastError() == ERROR_OPERATION_ABORTED) {
1403+
/* The read request was issued on another thread.
1404+
This is harmless, so just ignore it. */
1405+
return 0;
1406+
}
14021407
register_winapi_error(dev, L"hid_read_timeout/GetOverlappedResult");
14031408
}
14041409

0 commit comments

Comments
 (0)