win32: fix error code checking in _cancel_overlapped_io
it may also report ERROR_IO_INCOMPLETE when io is in progress
diff --git a/serial/serialwin32.py b/serial/serialwin32.py
index b843ac7..d11a2c4 100644
--- a/serial/serialwin32.py
+++ b/serial/serialwin32.py
@@ -437,7 +437,7 @@
ctypes.byref(overlapped),
ctypes.byref(rc),
False)
- if not err and win32.GetLastError() == win32.ERROR_IO_PENDING:
+ if not err and win32.GetLastError() in (win32.ERROR_IO_PENDING, win32.ERROR_IO_INCOMPLETE):
# cancel, ignoring any errors (e.g. it may just have finished on its own)
win32.CancelIoEx(self._port_handle, overlapped)
diff --git a/serial/win32.py b/serial/win32.py
index cef5568..2fddf6b 100644
--- a/serial/win32.py
+++ b/serial/win32.py
@@ -219,6 +219,7 @@
MAXDWORD = 4294967295 # Variable c_uint
EV_RLSD = 32 # Variable c_int
ERROR_SUCCESS = 0
+ERROR_IO_INCOMPLETE = 996
ERROR_IO_PENDING = 997 # Variable c_long
MS_CTS_ON = 16 # Variable c_ulong
EV_EVENT1 = 2048 # Variable c_int