From: Dietmar Maurer Date: Wed, 24 Oct 2012 06:21:29 +0000 (+0200) Subject: new helper wait_for_vnc_port() X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=ec6d95b45d4647a5954ac367257bcec13bbf45c9 new helper wait_for_vnc_port() --- diff --git a/Makefile b/Makefile index 3b26eb0..f6571e7 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ RELEASE=2.2 VERSION=1.0 -PKGREL=35 +PKGREL=36 PACKAGE=libpve-common-perl diff --git a/data/PVE/Tools.pm b/data/PVE/Tools.pm index f962da5..43b30b1 100644 --- a/data/PVE/Tools.pm +++ b/data/PVE/Tools.pm @@ -580,6 +580,30 @@ sub extract_param { return $res; } +# Note: we use this to wait until vncterm is ready +sub wait_for_vnc_port { + my ($port, $timeout) = @_; + + $timeout = 5 if !$timeout; + + for (my $i = 0; $i < $timeout; $i++) { + if (my $fh = IO::File->new ("/proc/net/tcp", "r")) { + while (defined (my $line = <$fh>)) { + if ($line =~ m/^\s*\d+:\s+([0-9A-Fa-f]{8}):([0-9A-Fa-f]{4})\s/) { + if ($port == hex($2)) { + close($fh); + return 1; + } + } + } + close($fh); + } + sleep(1); + } + + return undef; +} + sub next_vnc_port { for (my $p = 5900; $p < 6000; $p++) { diff --git a/debian/changelog b/debian/changelog index 5ebd7b4..fc27fdf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libpve-common-perl (1.0-36) unstable; urgency=low + + * new helper wait_for_vnc_port() + + -- Proxmox Support Team Wed, 24 Oct 2012 08:21:04 +0200 + libpve-common-perl (1.0-35) unstable; urgency=low * fix bug in read_memory_usage