5
0
mirror of git://git.proxmox.com/git/pve-common.git synced 2025-01-24 14:03:35 +03:00

tools: next_unused_port: use IPPROTO_TCP explicitly

Otherwise perl tries to bind+listen on a UDP socket if the
TCP socket fails - which is a waste since we're looking for
TCP ports.
Additionall since UDP doesn't support listen(), perl will
return EOPNOTSUPP instead of, say, EADDRINUSE. (We don't
care about the error in this code though.)
This commit is contained in:
Wolfgang Bumiller 2017-05-30 15:30:10 +02:00 committed by Dietmar Maurer
parent c14960cc1d
commit a0ecb15991

View File

@ -4,7 +4,8 @@ use strict;
use warnings;
use POSIX qw(EINTR EEXIST EOPNOTSUPP);
use IO::Socket::IP;
use Socket qw(AF_INET AF_INET6 AI_ALL AI_V4MAPPED AI_CANONNAME SOCK_DGRAM);
use Socket qw(AF_INET AF_INET6 AI_ALL AI_V4MAPPED AI_CANONNAME SOCK_DGRAM
IPPROTO_TCP);
use IO::Select;
use File::Basename;
use File::Path qw(make_path);
@ -789,7 +790,7 @@ sub next_unused_port {
my %sockargs = (Listen => 5,
ReuseAddr => 1,
Family => $family,
Proto => 0,
Proto => IPPROTO_TCP,
GetAddrInfoFlags => 0);
$sockargs{LocalAddr} = $address if defined($address);