From: Martin Ling Date: Tue, 8 Dec 2015 20:08:49 +0000 (+0000) Subject: windows: Handle ERROR_IO_PENDING from ReadFile in sp_nonblocking_read(). X-Git-Tag: libserialport-0.1.1~9 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ae2c5825e79ab5b38a8ca53941df6d73679a52e6;p=libserialport.git windows: Handle ERROR_IO_PENDING from ReadFile in sp_nonblocking_read(). This fixes bug #707. --- diff --git a/serialport.c b/serialport.c index 2f7618e..520d27e 100644 --- a/serialport.c +++ b/serialport.c @@ -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));