cygrunsrv + sshd + rsync = 20 times too slow -- throttled?

Ken Brown kbrown@cornell.edu
Wed Sep 15 17:09:30 GMT 2021


On 9/15/2021 12:22 PM, Ken Brown wrote:
> One other small detail:
> 
> diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
> index 566cf66d6..cdb213a42 100644
> --- a/winsup/cygwin/select.cc
> +++ b/winsup/cygwin/select.cc
> @@ -645,7 +645,7 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, 
> bool writing)
>              return 1; /* We cannot know actual write pipe space. */
>            DWORD nbytes_in_pipe;
>            if (!PeekNamedPipe (query_hdl, NULL, 0, NULL, &nbytes_in_pipe, NULL))
> -           return 1;
> +           return -1;
>            fpli.WriteQuotaAvailable = fpli.InboundQuota - nbytes_in_pipe;
>          }
>         if (fpli.WriteQuotaAvailable > 0)
> 
> Having noticed that, I checked the callers of pipe_data_available with writing 
> == true, and they don't check for a return of -1.  So I think I need to fix that 
> too.

Could one of you (Corinna or Takashi) please check that I haven't done anything 
stupid in the attached patches?  If they look OK, I'll push them, and then maybe 
we're ready for a test release.

Ken
-------------- next part --------------
>From fc8d2b2ccaf3b519e6b606fd95217f94b4a6fcbc Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Wed, 15 Sep 2021 11:24:25 -0400
Subject: [PATCH 1/2] Cygwin: pipes: fix a return value

If PeekNamedPipe fails in select.cc:pipe_data_available, return -1
rather than 1.
---
 winsup/cygwin/select.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 566cf66d6..cdb213a42 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -645,7 +645,7 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
 	    return 1; /* We cannot know actual write pipe space. */
 	  DWORD nbytes_in_pipe;
 	  if (!PeekNamedPipe (query_hdl, NULL, 0, NULL, &nbytes_in_pipe, NULL))
-	    return 1;
+	    return -1;
 	  fpli.WriteQuotaAvailable = fpli.InboundQuota - nbytes_in_pipe;
 	}
       if (fpli.WriteQuotaAvailable > 0)
-- 
2.33.0

-------------- next part --------------
>From 9d00b583c3d622c5ab8fcbdc3ba089eef8dd9ce5 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Wed, 15 Sep 2021 12:56:34 -0400
Subject: [PATCH 2/2] Cygwin: select: check for negative return from
 pipe_data_available

Make sure except_ready is set (if except_selected) on a negative
return from pipe_data_available.
---
 winsup/cygwin/select.cc | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index cdb213a42..cf9fbbbd3 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -753,8 +753,11 @@ out:
 	    gotone += s->except_ready = true;
 	  return gotone;
 	}
-      gotone += s->write_ready =  pipe_data_available (s->fd, fh, h, true);
-      select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
+      int n = pipe_data_available (s->fd, fh, h, true);
+      select_printf ("write: %s, n %d", fh->get_name (), n);
+      gotone += s->write_ready = n;
+      if (n < 0 && s->except_selected)
+	gotone += s->except_ready = true;
     }
   return gotone;
 }
@@ -953,9 +956,11 @@ peek_fifo (select_record *s, bool from_select)
 out:
   if (s->write_selected)
     {
-      gotone += s->write_ready
-	= pipe_data_available (s->fd, fh, fh->get_handle (), true);
-      select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
+      int n = pipe_data_available (s->fd, fh, fh->get_handle (), true);
+      select_printf ("write: %s, n %d", fh->get_name (), n);
+      gotone += s->write_ready = n;
+      if (n < 0 && s->except_selected)
+	gotone += s->except_ready = true;
     }
   return gotone;
 }
@@ -1394,8 +1399,11 @@ out:
   HANDLE h = ptys->get_output_handle ();
   if (s->write_selected)
     {
-      gotone += s->write_ready =  pipe_data_available (s->fd, fh, h, true);
-      select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
+      int n = pipe_data_available (s->fd, fh, h, true);
+      select_printf ("write: %s, n %d", fh->get_name (), n);
+      gotone += s->write_ready = n;
+      if (n < 0 && s->except_selected)
+	gotone += s->except_ready = true;
     }
   return gotone;
 }
-- 
2.33.0



More information about the Cygwin-developers mailing list