unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, 50043@debbugs.gnu.org
Subject: bug#50043: 28.0.50; USABLE_SIGOI undef code paths do not work correctly
Date: Wed, 17 Nov 2021 12:25:38 -0500	[thread overview]
Message-ID: <f7ff89ec-d063-00c3-9b75-94e3c4989db7@cornell.edu> (raw)
In-Reply-To: <83czmyzpno.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1618 bytes --]

On 11/17/2021 11:57 AM, Eli Zaretskii wrote:
>> Date: Wed, 17 Nov 2021 09:59:35 -0500
>> Cc: larsi@gnus.org, 50043@debbugs.gnu.org
>> From: Ken Brown <kbrown@cornell.edu>
>>
>>> But maybe it will be better to do it the same way we
>>> decrease the timeout when a timer is expected to expire before the
>>> timeout: we decrease the timeout, but still remember its value, and
>>> don't return from waiting before the timeout unless there really was
>>> some input.  This would avoid affecting unrelated features such as
>>> accept-process-output.
>>
>> I think that's already taken care of.  The timeout is recalculated on each
>> iteration of the main while loop:
>>
>>         /* Compute time from now till when time limit is up.  */
>>         /* Exit if already run out.  */
>>         if (wait == TIMEOUT)
>> 	{
>> 	  if (!timespec_valid_p (now))
>> 	    now = current_timespec ();
>> 	  if (timespec_cmp (end_time, now) <= 0)
>> 	    break;
>> 	  timeout = timespec_sub (end_time, now);
>> 	}
>>         else
>> 	timeout = make_timespec (wait < TIMEOUT ? 0 : 100000, 0);
>>
>> My reduction of timeout to 25 msec occurs after this.
> 
> So the result will be that on systems without USABLE_SIGIO we loop
> more times with shorter timeouts for select?

Yes.

> If so, it SGTM.

Thanks, I've pushed that change.

There's still one more issue related to this bug, which I mentioned earlier: If 
x_selection_timeout is zero, x_get_foreign_selection will call 
wait_reading_process output with an infinite timeout rather than a zero timeout, 
which I'm sure is not what was intended.  The attached patch fixes that.

Ken

[-- Attachment #2: 0001-Avoid-an-accidental-use-of-an-infinite-timeout.patch --]
[-- Type: text/plain, Size: 1151 bytes --]

From 5a0afdf1cb2ef276a2b6e4cf26abf18405127db2 Mon Sep 17 00:00:00 2001
From: Ken Brown <kbrown@cornell.edu>
Date: Wed, 17 Nov 2021 12:20:24 -0500
Subject: [PATCH] Avoid an accidental use of an infinite timeout

* src/xselect.c (x_get_foreign_selection): If x-selection-timeout
is zero, call wait_reading_process_output with a zero timeout
rather than an infinite timeout.  (Bug#50043)
---
 src/xselect.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/xselect.c b/src/xselect.c
index cd6d86bdf4..53b41f1ea2 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1196,6 +1196,10 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
   intmax_t timeout = max (0, x_selection_timeout);
   intmax_t secs = timeout / 1000;
   int nsecs = (timeout % 1000) * 1000000;
+  /* If x_selection_timeout == 0, avoid the "zero means infinite"
+     behavior of wait_reading_process_output. */
+  if (secs == 0 && nsecs == 0)
+    nsecs = -1;
   TRACE1 ("  Start waiting %"PRIdMAX" secs for SelectionNotify", secs);
   wait_reading_process_output (secs, nsecs, 0, false,
 			       reading_selection_reply, NULL, 0);
-- 
2.33.0


  reply	other threads:[~2021-11-17 17:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 11:56 bug#50043: 28.0.50; USABLE_SIGOI undef code paths do not work correctly Lars Ingebrigtsen
2021-08-13 13:16 ` Eli Zaretskii
2021-08-13 14:31   ` Lars Ingebrigtsen
2021-08-13 15:51     ` Eli Zaretskii
2021-08-14 11:52       ` Lars Ingebrigtsen
2021-11-15 15:19         ` Ken Brown
2021-11-15 17:24           ` Eli Zaretskii
2021-11-15 19:26             ` Ken Brown
2021-11-16 17:44               ` Eli Zaretskii
2021-11-16 23:06                 ` Ken Brown
2021-11-17  7:41                   ` Lars Ingebrigtsen
2021-11-17 14:25                     ` Ken Brown
2021-11-17 13:14                   ` Eli Zaretskii
2021-11-17 14:19                     ` Ken Brown
2021-11-17 14:34                       ` Eli Zaretskii
2021-11-17 14:59                         ` Ken Brown
2021-11-17 16:56                           ` Eli Zaretskii
2021-11-17 17:25                             ` Ken Brown [this message]
2021-11-17 17:37                               ` Eli Zaretskii
2021-11-17 17:45                                 ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7ff89ec-d063-00c3-9b75-94e3c4989db7@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=50043@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).