Skip to content

Commit

Permalink
SerialPort: avoid occasional hangs in .read() on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aslze committed Sep 24, 2024
1 parent 0b2f37c commit a621c86
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/SerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int SerialPort::read(void *p, int n)
DWORD bytes;
OVERLAPPED overlapped;
memset(&overlapped, 0, sizeof(OVERLAPPED));
if (!ReadFile(_handle, p, n, NULL, &overlapped))
if (!ReadFile(_handle, p, n, NULL, &overlapped) && GetLastError() != ERROR_IO_PENDING)
return 0;
GetOverlappedResult(_handle, &overlapped, &bytes, TRUE);
return bytes;
Expand Down

0 comments on commit a621c86

Please sign in to comment.