new helper wait_for_vnc_port()
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Oct 2012 06:21:29 +0000 (08:21 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Oct 2012 06:56:18 +0000 (08:56 +0200)
Makefile
data/PVE/Tools.pm
debian/changelog

index 3b26eb0..f6571e7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 RELEASE=2.2
 
 VERSION=1.0
-PKGREL=35
+PKGREL=36
 
 PACKAGE=libpve-common-perl
 
index f962da5..43b30b1 100644 (file)
@@ -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++) {
index 5ebd7b4..fc27fdf 100644 (file)
@@ -1,3 +1,9 @@
+libpve-common-perl (1.0-36) unstable; urgency=low
+
+  * new helper wait_for_vnc_port()
+
+ -- Proxmox Support Team <support@proxmox.com>  Wed, 24 Oct 2012 08:21:04 +0200
+
 libpve-common-perl (1.0-35) unstable; urgency=low
 
   * fix bug in read_memory_usage