]> git.proxmox.com Git - pve-common.git/commitdiff
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 3b26eb02a4a2494ea5f10ceef03376baec9785ac..f6571e7d18eb17fe7141c3817ebc12d4b566f13c 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 f962da50bda194311e68f01779480c14abe96bd4..43b30b14bd7c913145036270210a37298850ced1 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 5ebd7b4c1c60923a34cec8d7e9e194299d9bcea3..fc27fdf264841b2cbd3607e0ca89380e560c7231 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