Bernhard Übelacker : server: Return ReadDataAvailable value for FilePipeLocalInformation.

Alexandre Julliard julliard at winehq.org
Mon Dec 6 16:08:00 CST 2021


Module: wine
Branch: master
Commit: c488f29122cb871b3b61d80656f537cc0ba66a77
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c488f29122cb871b3b61d80656f537cc0ba66a77

Author: Bernhard Übelacker <bernhardu at mailbox.org>
Date:   Fri Nov 26 22:32:09 2021 +0100

server: Return ReadDataAvailable value for FilePipeLocalInformation.

Makes Cygwin mintty.exe or script.exe show output, if the
stack issues got worked around.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47808
Signed-off-by: Bernhard Übelacker <bernhardu at mailbox.org>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/tests/pipe.c | 8 ++++++++
 server/named_pipe.c     | 8 +++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/tests/pipe.c b/dlls/ntdll/tests/pipe.c
index 1118f41f81f..6940e0020b7 100644
--- a/dlls/ntdll/tests/pipe.c
+++ b/dlls/ntdll/tests/pipe.c
@@ -1888,8 +1888,16 @@ static void test_pipe_with_data_state(HANDLE pipe, BOOL is_server, DWORD state)
             "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %u: %x\n",
             is_server ? "server" : "client", state, status);
     if (!status)
+    {
         ok(local_info.NamedPipeState == state, "%s NamedPipeState = %u, expected %u\n",
             is_server ? "server" : "client", local_info.NamedPipeState, state);
+        if (state != FILE_PIPE_DISCONNECTED_STATE && state != FILE_PIPE_LISTENING_STATE)
+            ok(local_info.ReadDataAvailable != 0, "ReadDataAvailable, expected non-zero, in %s state %u\n",
+                is_server ? "server" : "client", state);
+        else
+            ok(local_info.ReadDataAvailable == 0, "ReadDataAvailable, expected zero, in %s state %u\n",
+                is_server ? "server" : "client", state);
+    }
 
     status = pNtQueryInformationFile(pipe, &io, &pipe_info, sizeof(pipe_info), FilePipeInformation);
     if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE)
diff --git a/server/named_pipe.c b/server/named_pipe.c
index 1bbf7f17a3a..3e6cf09d4f2 100644
--- a/server/named_pipe.c
+++ b/server/named_pipe.c
@@ -670,6 +670,8 @@ static void pipe_end_get_file_info( struct fd *fd, obj_handle_t handle, unsigned
     case FilePipeLocalInformation:
         {
             FILE_PIPE_LOCAL_INFORMATION *pipe_info;
+            struct pipe_message *message;
+            data_size_t avail = 0;
 
             if (!(get_handle_access( current->process, handle) & FILE_READ_ATTRIBUTES))
             {
@@ -706,7 +708,11 @@ static void pipe_end_get_file_info( struct fd *fd, obj_handle_t handle, unsigned
             pipe_info->MaximumInstances    = pipe->maxinstances;
             pipe_info->CurrentInstances    = pipe->instances;
             pipe_info->InboundQuota        = pipe->insize;
-            pipe_info->ReadDataAvailable   = 0; /* FIXME */
+
+            LIST_FOR_EACH_ENTRY( message, &pipe_end->message_queue, struct pipe_message, entry )
+                avail += message->iosb->in_size - message->read_pos;
+            pipe_info->ReadDataAvailable   = avail;
+
             pipe_info->OutboundQuota       = pipe->outsize;
             pipe_info->WriteQuotaAvailable = 0; /* FIXME */
             pipe_info->NamedPipeState      = pipe_end->state;




More information about the wine-cvs mailing list