[newlib-cygwin/cygwin-3_5-branch] Cygwin: pipe: Fix a regression that raw_write() slows down
Takashi Yano
tyan0@sourceware.org
Mon Sep 2 11:23:01 GMT 2024
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=37ab3e0d55e3ff3932509bfd2f2625c138b18866
commit 37ab3e0d55e3ff3932509bfd2f2625c138b18866
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date: Sun Sep 1 04:31:03 2024 +0900
Cygwin: pipe: Fix a regression that raw_write() slows down
After the commit 7f3c22532577, writing to pipe extremely slows down.
This is because cygwait(select_sem, 10, cw_cancel) is called even
when write operation is already completed. With this patch, the
cygwait() is called only if the write operation is not completed.
Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256398.html
Fixes: 7f3c22532577 ("Cygwin: pipe: handle signals explicitely in raw_write")
Reported-by: Jim Reisert AD1C <jjreisert@alum.mit.edu>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
(cherry picked from commit f78009cb1ccf84cc343cf2441c76196461d87532)
Diff:
---
winsup/cygwin/fhandler/pipe.cc | 6 ++++--
winsup/cygwin/release/3.5.5 | 3 +++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc
index 6658a23e7..997346877 100644
--- a/winsup/cygwin/fhandler/pipe.cc
+++ b/winsup/cygwin/fhandler/pipe.cc
@@ -503,8 +503,9 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
raise (SIGPIPE);
goto out;
}
- else
- cygwait (select_sem, 10, cw_cancel);
+ /* Break out on completion */
+ if (waitret == WAIT_OBJECT_0)
+ break;
/* If we got a timeout in the blocking case, and we already
did a short write, we got a signal in the previous loop. */
if (waitret == WAIT_TIMEOUT && short_write_once)
@@ -512,6 +513,7 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
waitret = WAIT_SIGNALED;
break;
}
+ cygwait (select_sem, 10, cw_cancel);
}
/* Loop in case of blocking write or SA_RESTART */
while (waitret == WAIT_TIMEOUT || waitret == WAIT_SIGNALED);
diff --git a/winsup/cygwin/release/3.5.5 b/winsup/cygwin/release/3.5.5
index a98687c26..904119a38 100644
--- a/winsup/cygwin/release/3.5.5
+++ b/winsup/cygwin/release/3.5.5
@@ -4,3 +4,6 @@ Fixes:
- Fix undesired behaviour of console master thread in win32-input-mode
which is supported by Windows Termainal.
Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256380.html
+
+- Fix a regression in 3.5.4 that writing to pipe extremely slows down.
+ Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256398.html
More information about the Cygwin-cvs
mailing list