From c488f29122cb871b3b61d80656f537cc0ba66a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= Date: Fri, 26 Nov 2021 22:32:09 +0100 Subject: [PATCH] server: Return ReadDataAvailable value for FilePipeLocalInformation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Alexandre Julliard --- 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;