Skip to content

Commit d385cf8

Browse files
committed
pipe: fix SSH hang (again)
The recent changes in Cygwin's pipe logic are a gift that keeps on giving. The recurring pattern is that bugs are fixed, but with many bug fixes, new bugs are produced, and we are stuck in this seemingly endless tunnel of fixing bugs caused by bug fixes. In cbfaeba (Cygwin: pipe: Fix incorrect write length in raw_write(), 2024-11-06), for example, a segmentation fault was fixed. Which is good! However, a bug was introduced, where e.g. Git for Windows' `git clone` via SSH frequently hangs indefinitely for large-ish repositories. That commit removed logic whereby in non-blocking mode, not only the chunk size, but also the overall count of bytes to write (`len`) was clamped to whatever is indicated as the `WriteQuotaAvailable`. Now only `chunk` is clamped to that, but `len` is left at its original number. However, the following `while` loop expects `len - chunk` (which is assigned to `left1`) not to be positive in non-blocking mode. Let's reinstate that clamping logic and implicitly fix this SSH hang. Fixes: cbfaeba (Cygwin: pipe: Fix incorrect write length in raw_write(), 2024-11-06) Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 1f8def9 commit d385cf8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

winsup/cygwin/fhandler/pipe.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
542542

543543
if (len <= (size_t) avail)
544544
chunk = len;
545+
else if (is_nonblocking ())
546+
chunk = len = avail;
545547
else
546548
chunk = avail;
547549

0 commit comments

Comments
 (0)