]> sigrok.org Git - libserialport.git/commitdiff
windows: Handle ERROR_IO_PENDING from ReadFile in sp_nonblocking_read().
authorMartin Ling <redacted>
Tue, 8 Dec 2015 20:08:49 +0000 (20:08 +0000)
committerUwe Hermann <redacted>
Wed, 9 Dec 2015 11:43:11 +0000 (12:43 +0100)
This fixes bug #707.

serialport.c

index 2f7618e8e4a1778bc1abee0c640b17972fd86d24..520d27e8531a4014e6a9746f9bd25b5d2b91103b 100644 (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));