Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waitforx changes #3297

Merged
merged 1 commit into from
Nov 27, 2024
Merged

Conversation

matt335672
Copy link
Member

Two changes to waitforx:-

  1. Changed alarm message from "Timed out waiting for RandR outputs" to "Timed out waiting for X display". The former was confusing, and the times where this message was triggered were nothing to do with RandR
  2. Don't try to open a display of the form ":n" directory (n >= 0). If the X server hasn't yet opened its local socket, the XOpenDisplay() call can go to the network and possibly block for a long time. Instead, use the (undocumented) "unix:n" display specification, which never goes to the network, and doesn't block.

We've had three reports now of waitforx seemingly blocking:-

I've not been able to get to the bottom of any of them satisfactorily, but I got a clue when looking at the last of these.

What I think is happening is this:-

  1. xrdp-sesman starts Xorg
  2. Xorg takes a while to initialise and open the UNIX socket for the display
  3. waitforx runs before the socket has opened and tries to open a display of the form ":n". Let's say this is ":10".
  4. Because the local socket is unavailable, the code in XOpenDisplay() goes to the network to try to connect to TCP port localhost:6010 for the X server.
  5. Network code blocks, either resolving localhost or because the user has not unreasonably firewalled off X11 ports.
  6. waitforx times out.

The fix is to use a display specification of (e.g.) unix:10 instead of :10. This never goes to the network, and so the scenario above is avoided.

However, the DISPLAY specification 'unix:n' is not documented.

It's clearly supported in the xcb code in _xcb_open(), which libX11 is now layered on:-

https://gitlab.freedesktop.org/xorg/lib/libxcb/-/blob/master/src/xcb_util.c?ref_type=heads#L247

There's evidence of it being supported back in 2007:-
https://gitlab.freedesktop.org/xorg/lib/libxcb/-/commit/09045eaac34973662aaa820a94ca8ed66d9dcb4e

I've tried the notation for both CentOS 7 and Ubuntu 16.04, which are the oldest distros I have available. These both support it.

Are people happy with this notation being used here? Is there a better way to get the same result?

@matt335672
Copy link
Member Author

I'm going to merge this into devel, so we can give it more of a test. Works fine on Linux & FreeBSD

@matt335672
Copy link
Member Author

Just spotted an issue - we need to support (e.g.) :10.0 as well as :10. I'll fix this before a merge

1) Changed alarm message from "Timed out waiting for RandR outputs" to
   "Timed out waiting for X display". The former was confusing, and the
   times where this message was triggered were nothing to do with
   RandR
2) Don't try to open a display of the form ":n" or ":n.m" directly
   (n,m >= 0). If the X server hasn't yet opened its local socket,
   the XOpenDisplay() call can go to the network and possibly block
   for a long time. Instead, use the (undocumented) "unix:n" display
   specification, whih never goes to the network, and doesn't block.
@matt335672 matt335672 merged commit 600549c into neutrinolabs:devel Nov 27, 2024
14 checks passed
@matt335672 matt335672 deleted the waitforx_improvements branch November 27, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant