[PATCH] ntdll: Skip synchronous read if a serial read interval timeout is set.

Alex Henrie alexhenrie24 at gmail.com
Fri May 27 00:34:26 CDT 2016


Fixes https://bugs.winehq.org/show_bug.cgi?id=40540

Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 dlls/ntdll/file.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 55bdac0..03254f2 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -868,6 +868,27 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
         }
     }
 
+    if (type == FD_TYPE_SERIAL)
+    {
+        if (!length)
+        {
+            status = STATUS_SUCCESS;
+            goto done;
+        }
+
+        /* an asynchronous serial port read with a read interval timeout needs to
+           skip the synchronous read to make sure that the Wineserver reads the
+           first byte and starts the read interval timer */
+        if (async_read)
+        {
+            status = get_io_timeouts(hFile, type, length, TRUE, &timeouts);
+            if (status)
+                goto err;
+            if (timeouts.interval)
+                goto wait;
+        }
+    }
+
     for (;;)
     {
         if ((result = read( unix_handle, (char *)buffer + total, length - total )) >= 0)
@@ -888,11 +909,6 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
                     status = length ? STATUS_END_OF_FILE : STATUS_SUCCESS;
                     goto done;
                 case FD_TYPE_SERIAL:
-                    if (!length)
-                    {
-                        status = STATUS_SUCCESS;
-                        goto done;
-                    }
                     break;
                 default:
                     status = STATUS_PIPE_BROKEN;
@@ -908,6 +924,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
             goto done;
         }
 
+wait:
         if (async_read)
         {
             struct async_fileio_read *fileio;
-- 
2.8.3




More information about the wine-patches mailing list