you should not override the global alarm timer
On 08/25/2015 11:10 AM, Wolfgang Bumiller wrote:
We use Net::Ping twice in pve-storage (once for ISCSIPlugin
and once in GlusterfsPlugin, both with the 'tcp' variant.),
but Net::Ping doesn't support IPv6.
---
src/PVE/Network.pm | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
index ff4a89c..b296225 100644
--- a/src/PVE/Network.pm
+++ b/src/PVE/Network.pm
@@ -6,6 +6,8 @@ use PVE::Tools qw(run_command);
use PVE::ProcFSTools;
use PVE::INotify;
use File::Basename;
+use IO::Socket::IP;
+use Time::HiRes 'alarm';
# host network related utility functions
@@ -437,4 +439,20 @@ sub activate_bridge_vlan {
return $bridgevlan;
}
+sub tcp_ping {
+ my ($host, $port, $timeout) = @_;
+ eval {
+ local $SIG{ALRM} = sub { die "timed out\n"; };
+ alarm($timeout || 3);
+ my $sock = IO::Socket::IP->new(PeerHost => $host,
+ PeerPort => $port,
+ # Timeout=> isn't implemented
+ Type => SOCK_STREAM);
+ alarm 0;
+ die "timed out\n" if !$sock;
+ $sock->close();
+ };
+ return $@ ne "timed out\n";
+}
+
1;
_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel