Long time delay from ck-get-x11-server-pid with remote DISPLAY

Bug #517323 reported by Joe Mullally on 2010-02-04
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
consolekit (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: consolekit

Dear consolekit maintainers,

When DISPLAY is set to a remote display, the remote display server is down/unreachable and you su from user to root (or someother user), this can take ~30 seconds+ to complete.

ps reveals ck-get-x11-server-pid is waiting on network connection to the xserver that will eventually timeout.

Since it is impossible to get the process ID of the other end of a TCP connection (manpages say Xlib uses TCP connections when DISPLAY has a hostname: part), I have a patch below which skips getting the PID for remote DISPLAYs. This fixes this problem for me (su times are now unnoticable), and I submit the patch in case you are interested. I have not done any extensive testing with it however, and don't know what effects it might have on its callers, return code wise. This is a pretty low priority problem.

Supporting info:

DISPLAY="192.168.1.254:0.0"
root@localhost:~# time su -c exit

real 0m25.355s
user 0m0.064s
sys 0m0.212s

25469 pts/3 S+ 0:00 su -c exit
25470 ? S 0:00 /usr/lib/ConsoleKit/ck-collect-session-info --uid 0 --pid 25469
25471 ? S 0:00 /usr/lib/ConsoleKit/ck-get-x11-server-pid

Calling /usr/lib/ConsoleKit/ck-get-x11-server-pid directly also takes ~25 sec on my machine, and will eventually say:
 ** (process:17961): WARNING **: cannot open display: 192.168.254.1:0.0

References:
If the DISPLAY variable has a hostname component, e.g. "remotehost:0.0", XOpenDisplay will use a TCP connection to it, and the fd it returns later will be a TCP socket.
(http://tronche.com/gui/x/xlib/display/opening.html)

It is only possible to get the peer socket's PID for UNIX domain sockets.
(E.g. On linux, SO_PEERCRED is only usable for UNIX domain sockets (i.e. PF_UNIX) )( http://linux.die.net/man/7/socket)

Changed in consolekit (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers