ntdll: Stop waiting for COM-port events if the device handle gets closed.

Dmitry Timoshkov dmitry at baikal.ru
Wed Aug 28 02:15:13 CDT 2013


This could happen when an overlapped WaitCommEvent() creates a thread and
then an application after failing with a timeout waiting for events closes
the device handle.
---
 dlls/ntdll/serial.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/serial.c b/dlls/ntdll/serial.c
index a389d0f..93991f9 100644
--- a/dlls/ntdll/serial.c
+++ b/dlls/ntdll/serial.c
@@ -306,7 +306,7 @@ static NTSTATUS get_modem_status(int fd, DWORD* lpModemStat)
               (*lpModemStat & MS_CTS_ON)  ? "MS_CTS_ON  " : "");
         return STATUS_SUCCESS;
     }
-    WARN("ioctl failed\n");
+    WARN("TIOCMGET err %s\n", strerror(errno));
     status = FILE_GetNtStatus();
 #endif
     return status;
@@ -928,7 +928,11 @@ static DWORD CALLBACK wait_for_event(LPVOID arg)
             NtDelayExecution(FALSE, &time);
             get_irq_info(fd, &new_irq_info);
             if (get_modem_status(fd, &new_mstat))
+            {
                 TRACE("get_modem_status failed\n");
+                *commio->events = 0;
+                break;
+            }
             *commio->events = check_events(fd, commio->evtmask,
                                            &new_irq_info, &commio->irq_info,
                                            new_mstat, commio->mstat);
-- 
1.8.3.4




More information about the wine-patches mailing list