[PATCH 2/2] ntdll: Make avail_mode always TRUE for serial ports.

Alex Henrie alexhenrie24 at gmail.com
Mon Jan 11 03:02:33 CST 2016


Cc: Eric Pouech <eric.pouech at orange.fr>
Cc: Sebastian Lackner <sebastian at fds-team.de>

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

avail_mode controls whether a read operation is considered a success as
long as at least one byte can be read, or whether the operation is
considered pending until the total number of requested bytes has been
received. For serial ports, avail_mode was TRUE if read operations
always finished immediately, and FALSE if read operations did not finish
until data was available or the request timed out.[1] However, whether
or not a zero-byte read is considered a success has nothing to do with
whether or not a one-byte read is considered a success.

Since serial ports are essentially hardware-based pipes, it makes sense
that they behave the same as software pipes and sockets.

[1] "If ReadIntervalTimeout is set to MAXULONG, and both
ReadTotalTimeoutConstant and ReadTotalTimeoutMultiplier are zero, a read
request completes immediately with the bytes that have already been
received, even if no bytes have been received. In this case, the read
request returns the STATUS_SUCCESS status code."
https://msdn.microsoft.com/en-us/library/windows/hardware/hh439614%28v=vs.85%29.aspx

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

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index b90695e..b2da2d5 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -738,37 +738,19 @@ static inline int get_next_io_timeout( const struct io_timeouts *timeouts, ULONG
 
 
 /* retrieve the avail_mode flag for async reads */
-static NTSTATUS get_io_avail_mode( HANDLE handle, enum server_fd_type type, BOOL *avail_mode )
+static BOOL get_io_avail_mode( enum server_fd_type type )
 {
-    NTSTATUS status = STATUS_SUCCESS;
-
     switch(type)
     {
     case FD_TYPE_SERIAL:
-        {
-            /* GetCommTimeouts */
-            SERIAL_TIMEOUTS st;
-            IO_STATUS_BLOCK io;
-
-            status = NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io,
-                                            IOCTL_SERIAL_GET_TIMEOUTS, NULL, 0, &st, sizeof(st) );
-            if (status) break;
-            *avail_mode = (!st.ReadTotalTimeoutMultiplier &&
-                           !st.ReadTotalTimeoutConstant &&
-                           st.ReadIntervalTimeout == MAXDWORD);
-        }
-        break;
     case FD_TYPE_MAILSLOT:
     case FD_TYPE_SOCKET:
     case FD_TYPE_PIPE:
     case FD_TYPE_CHAR:
-        *avail_mode = TRUE;
-        break;
+        return TRUE;
     default:
-        *avail_mode = FALSE;
-        break;
+        return FALSE;
     }
-    return status;
 }
 
 
@@ -905,8 +887,7 @@ NTSTATUS WINAPI NtReadFile(HANDLE hFile, HANDLE hEvent,
             struct async_fileio_read *fileio;
             BOOL avail_mode;
 
-            if ((status = get_io_avail_mode( hFile, type, &avail_mode )))
-                goto err;
+            avail_mode = get_io_avail_mode( type );
             if (total && avail_mode)
             {
                 status = STATUS_SUCCESS;
-- 
2.7.0




More information about the wine-patches mailing list