|
| 1 | +From cbe555e054cefeccd65250bb11dc56f82196301f Mon Sep 17 00:00:00 2001 |
| 2 | +From: Johannes Schindelin < [email protected]> |
| 3 | +Date: Thu, 10 Oct 2024 19:52:47 +0200 |
| 4 | +Subject: [PATCH 52/N] Fix SSH hangs |
| 5 | + |
| 6 | +It was reported in https://github.com/git-for-windows/git/issues/5199 |
| 7 | +that as of v3.5.4, cloning or fetching via SSH is hanging indefinitely. |
| 8 | + |
| 9 | +Bisecting the problem points to 555afcb2f3 (Cygwin: select: set pipe |
| 10 | +writable only if PIPE_BUF bytes left, 2024-08-18). That commit's |
| 11 | +intention seems to look at the write buffer, and only report the pipe as |
| 12 | +writable if there are more than one page (4kB) available. |
| 13 | + |
| 14 | +However, the number that is looked up is the number of bytes that are |
| 15 | +already in the buffer, ready to be read, and further analysis |
| 16 | +shows that in the scenario described in the report, the number of |
| 17 | +available bytes is substantially below `PIPE_BUF`, but as long as they |
| 18 | +are not handled, there is apparently a dead-lock. |
| 19 | + |
| 20 | +Since the old logic worked, and the new logic causes a dead-lock, let's |
| 21 | +essentially revert 555afcb2f3 (Cygwin: select: set pipe writable only if |
| 22 | +PIPE_BUF bytes left, 2024-08-18). |
| 23 | + |
| 24 | +Note: This is not a straight revert, as the code in question has been |
| 25 | +modified subsequently, and trying to revert the original commit would |
| 26 | +cause merge conflicts. Therefore, the diff looks very different from the |
| 27 | +reverse diff of the commit whose logic is reverted. |
| 28 | + |
| 29 | +Signed-off-by: Johannes Schindelin < [email protected]> |
| 30 | +--- |
| 31 | + winsup/cygwin/select.cc | 6 +++--- |
| 32 | + 1 file changed, 3 insertions(+), 3 deletions(-) |
| 33 | + |
| 34 | +diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc |
| 35 | +index bc02c3f..2c09b14 100644 |
| 36 | +--- a/winsup/cygwin/select.cc |
| 37 | ++++ b/winsup/cygwin/select.cc |
| 38 | +@@ -776,7 +776,7 @@ out: |
| 39 | + } |
| 40 | + ssize_t n = pipe_data_available (s->fd, fh, h, PDA_SELECT | PDA_WRITE); |
| 41 | + select_printf ("write: %s, n %d", fh->get_name (), n); |
| 42 | +- gotone += s->write_ready = (n >= PIPE_BUF); |
| 43 | ++ gotone += s->write_ready = (n > 0); |
| 44 | + if (n < 0 && s->except_selected) |
| 45 | + gotone += s->except_ready = true; |
| 46 | + } |
| 47 | +@@ -990,7 +990,7 @@ out: |
| 48 | + ssize_t n = pipe_data_available (s->fd, fh, fh->get_handle (), |
| 49 | + PDA_SELECT | PDA_WRITE); |
| 50 | + select_printf ("write: %s, n %d", fh->get_name (), n); |
| 51 | +- gotone += s->write_ready = (n >= PIPE_BUF); |
| 52 | ++ gotone += s->write_ready = (n > 0); |
| 53 | + if (n < 0 && s->except_selected) |
| 54 | + gotone += s->except_ready = true; |
| 55 | + } |
| 56 | +@@ -1416,7 +1416,7 @@ out: |
| 57 | + { |
| 58 | + ssize_t n = pipe_data_available (s->fd, fh, h, PDA_SELECT | PDA_WRITE); |
| 59 | + select_printf ("write: %s, n %d", fh->get_name (), n); |
| 60 | +- gotone += s->write_ready = (n >= PIPE_BUF); |
| 61 | ++ gotone += s->write_ready = (n > 0); |
| 62 | + if (n < 0 && s->except_selected) |
| 63 | + gotone += s->except_ready = true; |
| 64 | + } |
0 commit comments