cygrunsrv + sshd + rsync = 20 times too slow -- throttled?
Corinna Vinschen
corinna-cygwin@cygwin.com
Wed Sep 15 12:20:48 GMT 2021
On Sep 15 20:54, Takashi Yano wrote:
> This shoudl be:
>
> @@ -652,11 +652,17 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
> }
> /* TODO: Buffer really full or non-Cygwin reader? */
> }
> - else if (fpli.ReadDataAvailable)
> + else
> {
> - paranoid_printf ("fd %d, %s, read avail %u", fd, fh->get_name (),
> - fpli.ReadDataAvailable);
> - return 1;
> + DWORD nbytes_in_pipe;
> + if (PeekNamedPipe (h, NULL, 0, NULL, &nbytes_in_pipe, NULL))
> + {
> + paranoid_printf ("fd %d, %s, read avail %u", fd, fh->get_name (),
> + nbytes_in_pipe);
> + return nbytes_in_pipe > 0;
> + }
> + else if (GetLastError () == ERROR_BROKEN_PIPE)
> + return -1;
> }
> if (fpli.NamedPipeState & FILE_PIPE_CLOSING_STATE)
> return -1;
After Ken's comment, I was going to suggest this one:
>From 34b14470406cb9551f98707bf63175811a506523 Mon Sep 17 00:00:00 2001
From: Corinna Vinschen
Date: Wed, 15 Sep 2021 14:17:59 +0200
Subject: [PATCH] Cygwin: pipes: don't call NtQueryInformationFile on read side
of pipes
NtQueryInformationFile hangs if it's called on the read side handle of
a pipe while another thread or process is performing a blocking read.
Avoid select potentially hanging by calling NtQueryInformationFile
only on the write side of the pipe and using PeekNamedPipe otherwise.
---
winsup/cygwin/select.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index a09d8a34da2e..566cf66d653b 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -587,6 +587,14 @@ no_verify (select_record *, fd_set *, fd_set *, fd_set *)
static int
pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
{
+ if (fh->get_device () == FH_PIPER)
+ {
+ DWORD nbytes_in_pipe;
+ if (!writing && PeekNamedPipe (h, NULL, 0, NULL, &nbytes_in_pipe, NULL))
+ return nbytes_in_pipe > 0;
+ return -1;
+ }
+
IO_STATUS_BLOCK iosb = {{0}, 0};
FILE_PIPE_LOCAL_INFORMATION fpli = {0};
NTSTATUS status;
--
2.31.1
More information about the Cygwin-developers
mailing list