mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Windows nonblocking write: Dont't return if async I/O finishes immediately.
This commit is contained in:
parent
1622ef60b0
commit
64d996216e
13
serialport.c
13
serialport.c
@ -1000,9 +1000,16 @@ enum sp_return sp_nonblocking_write(struct sp_port *port, const void *buf, size_
|
|||||||
/* Start asynchronous write. */
|
/* Start asynchronous write. */
|
||||||
if (WriteFile(port->hdl, &port->pending_byte, 1, NULL, &port->write_ovl) == 0) {
|
if (WriteFile(port->hdl, &port->pending_byte, 1, NULL, &port->write_ovl) == 0) {
|
||||||
if (GetLastError() == ERROR_IO_PENDING) {
|
if (GetLastError() == ERROR_IO_PENDING) {
|
||||||
DEBUG("Asynchronous write started");
|
if (HasOverlappedIoCompleted(&port->write_ovl)) {
|
||||||
port->writing = 1;
|
DEBUG("Asynchronous write completed immediately");
|
||||||
RETURN_VALUE("%d", ++written);
|
port->writing = 0;
|
||||||
|
written++;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
DEBUG("Asynchronous write running");
|
||||||
|
port->writing = 1;
|
||||||
|
RETURN_VALUE("%d", ++written);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Actual failure of some kind. */
|
/* Actual failure of some kind. */
|
||||||
RETURN_FAIL("WriteFile() failed");
|
RETURN_FAIL("WriteFile() failed");
|
||||||
|
Loading…
Reference in New Issue
Block a user