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 7f3c225, 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.

Backported-from: 37ab3e0d55 (Cygwin: pipe: Fix a regression that raw_write() slows down, 2024-09-01)
Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256398.html
Fixes: 7f3c225 ("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>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
tyan0 authored and dscho committed Sep 3, 2024
1 parent dd9d970 commit 2bfb773
Showing 1 changed file with 4 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

0 comments on commit 2bfb773

Please sign in to comment.