line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Check::Socket; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
76265
|
use base qw(Exporter); |
|
5
|
|
|
|
|
33
|
|
|
5
|
|
|
|
|
706
|
|
4
|
5
|
|
|
5
|
|
35
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
93
|
|
5
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
172
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
54
|
use Config; |
|
5
|
|
|
|
|
25
|
|
|
5
|
|
|
|
|
286
|
|
8
|
5
|
|
|
5
|
|
2826
|
use Readonly; |
|
5
|
|
|
|
|
20210
|
|
|
5
|
|
|
|
|
291
|
|
9
|
5
|
|
|
5
|
|
2881
|
use Socket; |
|
5
|
|
|
|
|
25045
|
|
|
5
|
|
|
|
|
3730
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $ERROR_MESSAGE; |
12
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(check_socket $ERROR_MESSAGE); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.04; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub check_socket { |
17
|
6
|
|
|
6
|
1
|
3718
|
my ($config_hr, $os, $env_hr) = @_; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
100
|
|
|
27
|
$config_hr ||= \%Config; |
20
|
6
|
|
66
|
|
|
18
|
$os ||= $^O; |
21
|
6
|
|
100
|
|
|
18
|
$env_hr ||= \%ENV; |
22
|
|
|
|
|
|
|
|
23
|
6
|
50
|
33
|
|
|
65
|
if ($env_hr->{PERL_CORE} and $config_hr->{'extensions'} !~ /\bSocket\b/) { |
24
|
0
|
|
|
|
|
0
|
$ERROR_MESSAGE = 'Socket extension unavailable.'; |
25
|
0
|
|
|
|
|
0
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
6
|
50
|
33
|
|
|
31
|
if ($env_hr->{PERL_CORE} and $config_hr->{'extensions'} !~ /\bIO\b/) { |
29
|
0
|
|
|
|
|
0
|
$ERROR_MESSAGE = 'IO extension unavailable.'; |
30
|
0
|
|
|
|
|
0
|
return 0; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
6
|
50
|
|
|
|
21
|
if ($os eq 'os2') { |
34
|
0
|
0
|
|
|
|
0
|
eval { IO::Socket::pack_sockaddr_un('/foo/bar') || 1 }; |
|
0
|
|
|
|
|
0
|
|
35
|
0
|
0
|
|
|
|
0
|
if ($@ =~ /not implemented/) { |
36
|
0
|
|
|
|
|
0
|
$ERROR_MESSAGE = "$os: Compiled without TCP/IP stack v4."; |
37
|
0
|
|
|
|
|
0
|
return 0; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
6
|
100
|
|
|
|
42
|
if ($os =~ m/^(?:qnx|nto|vos)$/ ) { |
42
|
3
|
|
|
|
|
10
|
$ERROR_MESSAGE = "$os: UNIX domain sockets not implemented."; |
43
|
3
|
|
|
|
|
10
|
return 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
3
|
100
|
|
|
|
11
|
if ($os eq 'MSWin32') { |
47
|
1
|
50
|
|
|
|
4
|
if ($env_hr->{CONTINUOUS_INTEGRATION}) { |
48
|
|
|
|
|
|
|
# https://github.com/Perl/perl5/issues/17429 |
49
|
1
|
|
|
|
|
4
|
$ERROR_MESSAGE = "$os: Skip sockets on CI."; |
50
|
1
|
|
|
|
|
3
|
return 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# https://github.com/Perl/perl5/issues/17575 |
54
|
0
|
0
|
|
|
|
0
|
if (! eval { socket(my $sock, PF_UNIX, SOCK_STREAM, 0) }) { |
|
0
|
|
|
|
|
0
|
|
55
|
0
|
|
|
|
|
0
|
$ERROR_MESSAGE = "$os: AF_UNIX unavailable or disabled."; |
56
|
0
|
|
|
|
|
0
|
return 0; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
6
|
return 1; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |