From: Patrick Dussud Date: Mon, 17 Jun 2024 18:58:36 +0000 (-0700) Subject: Add handling of ERROR_OPERATION_ABORTED in restart_wait for WIN32 X-Git-Tag: libserialport-0.1.2~9 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=33feeb0516445cd32c113b9da34e25518d5b02fa;p=libserialport.git Add handling of ERROR_OPERATION_ABORTED in restart_wait for WIN32 It appears that the standard Win11 CDC driver does produce this case on occasion when the last byte of the IO has been transferred. --- diff --git a/serialport.c b/serialport.c index 1b5a95e..58b3c3e 100644 --- a/serialport.c +++ b/serialport.c @@ -420,7 +420,7 @@ SP_API void sp_free_port_list(struct sp_port **list) /** To be called after port receive buffer is emptied. */ static enum sp_return restart_wait(struct sp_port *port) { - DWORD wait_result; + DWORD wait_result, last_error_code; if (port->wait_running) { /* Check status of running wait operation. */ @@ -428,7 +428,10 @@ static enum sp_return restart_wait(struct sp_port *port) &wait_result, FALSE)) { DEBUG("Previous wait completed"); port->wait_running = FALSE; - } else if (GetLastError() == ERROR_IO_INCOMPLETE) { + } else if ((last_error_code = GetLastError()) == ERROR_OPERATION_ABORTED) { + DEBUG("Previous wait aborted"); + port->wait_running = FALSE; + } else if (last_error_code == ERROR_IO_INCOMPLETE) { DEBUG("Previous wait still running"); RETURN_OK(); } else {