]> git.proxmox.com Git - pve-common.git/commit - src/PVE/Tools.pm
use more reliable checks in wait_for_vnc_port
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 27 Jun 2017 09:12:04 +0000 (11:12 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 27 Jun 2017 09:22:55 +0000 (11:22 +0200)
commit9a41a7b7c934cf62e819d00c2b6c2fc5c3add27b
tree53a7148029f1044f9bcec8791625d2d8c9b8163c
parent701270450e50160dfa804eb20e03fd31b7a3675c
use more reliable checks in wait_for_vnc_port

We run into problems where this method returned to early, even if the
port wasn't actually ready yet. The reason for this is that we
checked /proc/net/tcp which does not guarantees and always up to date
state of only those ports which are actuall available, i.e. a port
could linger around (time-wait state) or appear even if it wasn't
accepting connections yet (as stated in the kernel docs:
/proc/net/tcp is seen as obsolete by the kernel devs).

Use the `ss` tool from the iproute2 package, it uses netlink to get
the current state and has switches where we can direct it to really
only get the state of those sockets which interest us currently.
I.e., we tell it to get only listening TCP sockets from the requested
port.

The only drawback is that we loop on a run_command, which is slower
than just reading a file. A single loop needs about 1ms here vs the
60µs on the /proc/net/tcp read. But this isn't a api call which is
used highly frequently but rather once per noVNC console open.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/Tools.pm