Subject: Re: bug#36362: New feature-x-check-server

From: Noam Postavsky <[email-masked]>
Date: Thu, 27 Jun 2019 20:34:45 -0400

[forwarding to list, please use "Reply All" to keep [email-masked] on Cc]

Subject: Re: bug#36362: New feature-x-check-server
From: "otadmor ." <[email-masked]>
To: Noam Postavsky <[email-masked]>
Date: Thu, 27 Jun 2019 22:12:56 +0300

I have some non consistency of the terms client and server. Some refer to
the emacs client/daemon, some refer to the xserver, emacs as x11 client.

Hi,
I have this scenerio:
1. Laptop with Windows 10 host and Ubuntu 1804 vm.putty and xming (latest
versions) are installed on host and emacs 26.2 on the vm.
2. Connect with putty via sshx to the vm and run emacsclient -c. Doest
really matter how emacs deamon is started (with the ex, via the ssh as
emacs -daemon, directly in the vm, as sysctl -user start emacs).
3. Close the laptop lid so it goes to sleep.
4. Open the lid and reconnect with sshx and emacs client -c.
5. The second emacs client causes emacs daemon to stuck on xcb select (they
have no timeout). The emacs client is still running correctly before the
second emacs client.

The propose is to have this connectivity check native function + timer
which executes it on all existing frames every few seconds.

This native function closes the fd of the xcb and causes the select to
return EINTR. xcb have internal infinate loop Incase of EINTR, so closing
the fd is necessary to get out of this infinite loop. Closing the fd also
causes libx11 to realize the connection was closed and call the error
handler of emacs for x11 failures for a clean termination of the resources
in emacs.

This native function is consist of a a native timer with a signal handler
to handle when this timer expires. I have set the native timer for 0.5
seconds and it is configurable using an elisp variable. When the server was
not disconnected this timer don't expires, doesnt close the fd and returned
immediately without waiting 0.5 seconds. When the client crashed because of
sleep, the native code will have to wait before realizing it. I have
selected GetGeomerty arbitrarly. This is usually used by emacs and I don't
believe it has an extra side effect. The xcb knows the sequence numbers of
the requests and should not be confused with other GetGeomerty/other
non-GetGeomerty requests.

Shalom.

On Thu, Jun 27, 2019, 18:10 Noam Postavsky <[email-masked]> wrote:

> "otadmor ." <[email-masked]> writes:
>
> > A new native method to check connectivity of xserver.
>
> Can you explain a bit when/why this is useful?  As it stands this patch
> is rather "apropos of nothing"...
>
>