Cygwin: pipe: Fix a regression that raw_write() slows down

After the commit 7f3c225325, 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: 7f3c225325 ("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>
This commit is contained in:
Takashi Yano 2024-09-01 04:31:03 +09:00
parent 84d77e5918
commit f78009cb1c
2 changed files with 7 additions and 2 deletions

View File

@ -518,8 +518,9 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
raise (SIGPIPE); raise (SIGPIPE);
goto out; goto out;
} }
else /* Break out on completion */
cygwait (select_sem, 10, cw_cancel); if (waitret == WAIT_OBJECT_0)
break;
/* If we got a timeout in the blocking case, and we already /* If we got a timeout in the blocking case, and we already
did a short write, we got a signal in the previous loop. */ did a short write, we got a signal in the previous loop. */
if (waitret == WAIT_TIMEOUT && short_write_once) if (waitret == WAIT_TIMEOUT && short_write_once)
@ -527,6 +528,7 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
waitret = WAIT_SIGNALED; waitret = WAIT_SIGNALED;
break; break;
} }
cygwait (select_sem, 10, cw_cancel);
} }
/* Loop in case of blocking write or SA_RESTART */ /* Loop in case of blocking write or SA_RESTART */
while (waitret == WAIT_TIMEOUT || waitret == WAIT_SIGNALED); while (waitret == WAIT_TIMEOUT || waitret == WAIT_SIGNALED);

View File

@ -4,3 +4,6 @@ Fixes:
- Fix undesired behaviour of console master thread in win32-input-mode - Fix undesired behaviour of console master thread in win32-input-mode
which is supported by Windows Termainal. which is supported by Windows Termainal.
Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256380.html 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