Skip to content

Commit

Permalink
Use IO::Socket::INET to check connectivity, as well as resolve the ho…
Browse files Browse the repository at this point in the history
…stname
  • Loading branch information
alexmv committed Mar 13, 2012
1 parent 93f6ae0 commit 2e89f6a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bin/smokingit-worker
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;
use lib 'lib';
use Smokingit::Worker;
use Getopt::Long;
use Socket qw//;
use IO::Socket::INET;

my $jobs = 5;
my $repos = "repos";
Expand All @@ -22,9 +22,12 @@ die "Repository path $repos isn't writable!\n" unless -w $repos;
for my $s (@{$servers}) {
my ($host, $port) = split ':', $s, 2;
$port ||= 4730;
my $packed = Socket::inet_aton($host);
die "Can't resolve server $host!\n" unless $packed;
$s = Socket::inet_ntoa($packed) . ":" . $port;

my $socket = IO::Socket::INET->new( PeerHost => "$host:$port" );
die "Connect to $s failed: $1\n"
if ($@ || "") =~ /^IO::Socket::INET: (.*)/;

$s = $socket->peerhost . ":" . $port;
}

my $worker = Smokingit::Worker->new(
Expand Down

0 comments on commit 2e89f6a

Please sign in to comment.