Skip to content

Commit

Permalink
Cygwin: pipe: Fix a regression that raw_write() slows down
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
tyan0 committed Sep 2, 2024
1 parent 68a14b6 commit 37ab3e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions winsup/cygwin/fhandler/pipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,17 @@ 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)
{
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);
Expand Down
3 changes: 3 additions & 0 deletions winsup/cygwin/release/3.5.5
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 37ab3e0

Please sign in to comment.