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: rcopley@gmail.com, 25875@debbugs.gnu.org
Subject: bug#25875: 26.0.50; Hang logging out of MS-Windows
Date: Sun, 26 Feb 2017 13:58:23 -0500	[thread overview]
Message-ID: <3f07808e-ab1c-d6b5-9ea0-dfc4c6fd6fc9@cornell.edu> (raw)
In-Reply-To: <834lzgreqq.fsf@gnu.org>

On 2/26/2017 1:25 PM, Eli Zaretskii wrote:
>> Cc: 25875@debbugs.gnu.org
>> From: Ken Brown <kbrown@cornell.edu>
>> Date: Sun, 26 Feb 2017 13:04:18 -0500
>>
>> The problem might be that 1000 sec is too long for the input thread to sleep.  I chose that number arbitrarily, not realizing that the main thread could get stuck waiting for the input thread.  What about something like this?
>>
>> --- a/src/w32fns.c
>> +++ b/src/w32fns.c
>> @@ -4801,8 +4801,10 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
>>
>>      case WM_ENDSESSION:
>>        my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
>> -      /* If we return, the process will be terminated immediately.  */
>> -      sleep (1000);
>> +      /* Allow time for Emacs to attempt an orderly shutdown.  If we
>> +        return, the process will be terminated immediately.  */
>> +      sleep (5);
>> +      return 0;
>>
>>      case WM_WINDOWPOSCHANGING:
>>        /* Don't restrict the sizing of any kind of frames.  If the window
>>
>> With this change, I think Emacs will be killed in at most 5 seconds no matter what state it is in.  But
>> I can't test this because I don't know how to reproduce Richard's problem.
>
> I think the problem in this particular scenario is not that the input
> thread sleeps too long, it's that whenever it finishes sleeping and
> returns, Emacs will be killed, so the WM_ENDSESSION message that was
> posted to the main thread will never have a chance to be processed,
> and thus orderly shutdown will never happen.
>
> That is why I thought about using SendMessageTimeout in the main
> thread: what we really want is to cause the main thread to wake up and
> process the WM_ENDSESSION message.  Right?

Yes, that would obviously be better.  But in any case, I don't think we 
want the input thread to sleep for 1000 seconds.  If we can't arrange an 
orderly shutdown, we should give up after a reasonable amount of time.

Ken





  reply	other threads:[~2017-02-26 18:58 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-25 19:35 bug#25875: 26.0.50; Hang logging out of MS-Windows Richard Copley
2017-02-25 19:41 ` Richard Copley
2017-02-25 20:36   ` Eli Zaretskii
2017-02-25 21:13     ` Richard Copley
2017-02-26 15:47       ` Eli Zaretskii
2017-02-26 18:26         ` Richard Copley
2017-02-25 20:33 ` Eli Zaretskii
2017-02-25 21:07   ` Richard Copley
2017-02-25 21:30     ` Richard Copley
2017-02-25 21:37       ` Richard Copley
2017-02-25 22:02         ` Richard Copley
2017-02-26 15:47           ` Eli Zaretskii
2017-02-26 18:37             ` Richard Copley
2017-02-26 15:44     ` Eli Zaretskii
2017-02-26 18:04       ` Ken Brown
2017-02-26 18:25         ` Eli Zaretskii
2017-02-26 18:58           ` Ken Brown [this message]
2017-02-26 19:25             ` Eli Zaretskii
2017-02-26 23:38               ` Ken Brown
2017-02-27  8:14                 ` Richard Copley
2017-02-27 15:36                   ` Eli Zaretskii
2017-02-27 19:04                     ` Richard Copley
2017-02-27 19:16                       ` Eli Zaretskii
2017-02-27 19:23                         ` Richard Copley
2017-02-27 19:30                           ` Richard Copley
2017-02-27 19:39                             ` Ken Brown
2017-02-27 19:46                               ` Richard Copley
2017-02-27 19:56                                 ` Richard Copley
2017-02-27 20:19                                   ` Ken Brown
2017-02-27 20:27                                 ` Eli Zaretskii
2017-02-27 20:52                                   ` Richard Copley
2017-02-27 20:58                                     ` Eli Zaretskii
2017-02-27 21:09                                       ` Richard Copley
2017-02-28  3:30                                         ` Eli Zaretskii
2017-02-28  6:37                                           ` Richard Copley
2017-02-27 22:37                   ` Ken Brown
2017-02-27 23:03                     ` Richard Copley
2017-02-28  3:35                       ` Eli Zaretskii
2017-02-28  7:21                         ` Richard Copley
2017-02-28 15:36                           ` Eli Zaretskii
2017-02-28 16:40                             ` Ken Brown
2017-02-28 16:44                               ` Eli Zaretskii
2017-02-28 18:59                                 ` Richard Copley

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=3f07808e-ab1c-d6b5-9ea0-dfc4c6fd6fc9@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=25875@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=rcopley@gmail.com \
    /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).