bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50043: 28.0.50; USABLE_SIGOI undef code paths do not work correctly


From: Ken Brown
Subject: bug#50043: 28.0.50; USABLE_SIGOI undef code paths do not work correctly
Date: Tue, 16 Nov 2021 18:06:51 -0500
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0

On 11/16/2021 12:45 PM, Eli Zaretskii wrote:
From: Ken Brown <kbrown@cornell.edu>
We certainly don't want to always skip the select call, but would it make sense
to use a very short timeout for select in that case?  Or maybe someone has a
better idea.

Making timeout shorter might be the solution, but I'd like to
understand the problem better first.

If the code is based on the premise that we check for selection when
we exit select, then I think on systems without USABLE_SIGIO we should
call wait_reading_process_output with a short timeout but in a loop,
so that the summary wait is still 2 sec, but we exit the loop as soon
as selection arrives because each call to wait_reading_process_output
has a much shorter timeout, say, 25 msec.  WDYT?

Are you talking about having x_get_foreign_selection call wait_reading_process_output in a loop? That would fix this particular bug, but I was thinking of trying to solve a more general problem. Namely, whenever wait_reading_process_output is polling for input, avoid getting stuck in select, something like this:

diff --git a/src/process.c b/src/process.c
index f923aff1cb..808bf6f1ff 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5588,6 +5588,15 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
            timeout = make_timespec (0, 0);
 #endif

+#ifndef USABLE_SIGIO
+         /* If we're polling for input, don't get stuck in select for
+            more than 25 msec. */
+         struct timespec short_timeout = make_timespec (0, 25000000);
+         if ((read_kbd || !NILP (wait_for_cell))
+             && timespec_cmp (short_timeout, timeout) < 0)
+           timeout = short_timeout;
+#endif
+
          /* Non-macOS HAVE_GLIB builds call thread_select in xgselect.c.  */
 #if defined HAVE_GLIB && !defined HAVE_NS
          nfds = xg_select (max_desc + 1,

Ken





reply via email to

[Prev in Thread] Current Thread [Next in Thread]