[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#64975: 30.0.50; accept-process-output and async connect
From: |
Helmut Eller |
Subject: |
bug#64975: 30.0.50; accept-process-output and async connect |
Date: |
Tue, 08 Aug 2023 16:36:00 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
On Tue, Aug 08 2023, Robert Pluim wrote:
> I think itʼs correct, as I have a change locally setting
> got_some_output for a different test case, but Iʼm going to be a pain,
> and ask Helmut to explain why, and see if I agree with his explanation
> (thatʼs a very hairy loop)
Setting got_some_output=1, was the first thing that came to mind that
made the test case pass :-). A reasonable strategy, if we have a
comprehensive test suite. If the test suite is lacking, then writing
more tests is a good investment too. Ahem.
Setting got_some_output=1 will terminate the while(1) loop, but only on
the next iteration (around line process.c:5753) and only after another
useless call to xg_select. So maybe a change like below might be
better.
The variable got_some_output is also the return value of
wait_reading_process_output. So I thought that 1 is a reasonable value
to indicate "some event happened". 0 and negative values are converted
to nil in accept-process-output, so there isn't an obvious way to
indicate "not a timeout, 0 bytes read, but some other event". Maybe
MAX_INT could be used.
If you're asking why accept-process-output should return at all, then
the answer is that the socket is now writable and the caller probably
want's to know that.
Helmut
diff --git a/src/process.c b/src/process.c
index 2d6e08f16b5..f5fec84b53c 100644
--- a/src/process.c
+++ b/src/process.c
@@ -6028,6 +6028,9 @@ wait_reading_process_output (intmax_t time_limit, int
nsecs, int read_kbd,
status_notify to do it later, it will read input
from the process before calling the sentinel. */
exec_sentinel (proc, build_string ("open\n"));
+ got_some_output = max (got_some_output, 1);
+ if (p == wait_proc)
+ goto done_waiting;
}
if (0 <= p->infd && !EQ (p->filter, Qt)
@@ -6038,6 +6041,8 @@ wait_reading_process_output (intmax_t time_limit, int
nsecs, int read_kbd,
} /* End for each file descriptor. */
} /* End while exit conditions not met. */
+
+ done_waiting:
unbind_to (count, Qnil);
/* If calling from keyboard input, do not quit