1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

windows: Handle ERROR_IO_PENDING from ReadFile in sp_nonblocking_read().

This fixes bug #707.
This commit is contained in:
Martin Ling 2015-12-08 20:08:49 +00:00 committed by Uwe Hermann
parent 127d8d0ce7
commit ae2c5825e7

View File

@ -1234,10 +1234,11 @@ SP_API enum sp_return sp_nonblocking_read(struct sp_port *port, void *buf,
/* Do read. */
if (ReadFile(port->hdl, buf, count, NULL, &port->read_ovl) == 0)
RETURN_FAIL("ReadFile() failed");
if (GetLastError() != ERROR_IO_PENDING)
RETURN_FAIL("ReadFile() failed");
/* Get number of bytes read. */
if (GetOverlappedResult(port->hdl, &port->read_ovl, &bytes_read, TRUE) == 0)
if (GetOverlappedResult(port->hdl, &port->read_ovl, &bytes_read, FALSE) == 0)
RETURN_FAIL("GetOverlappedResult() failed");
TRY(restart_wait_if_needed(port, bytes_read));