line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Check::Socket; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
76053
|
use base qw(Exporter); |
|
5
|
|
|
|
|
31
|
|
|
5
|
|
|
|
|
663
|
|
4
|
5
|
|
|
5
|
|
32
|
use strict; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
95
|
|
5
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
173
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
64
|
use Config; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
335
|
|
8
|
5
|
|
|
5
|
|
2936
|
use Readonly; |
|
5
|
|
|
|
|
20634
|
|
|
5
|
|
|
|
|
295
|
|
9
|
5
|
|
|
5
|
|
2946
|
use Socket; |
|
5
|
|
|
|
|
24886
|
|
|
5
|
|
|
|
|
3627
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $ERROR_MESSAGE; |
12
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(check_socket $ERROR_MESSAGE); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.03; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub check_socket { |
17
|
6
|
|
|
6
|
1
|
3653
|
my ($config_hr, $os, $env_hr) = @_; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
100
|
|
|
27
|
$config_hr ||= \%Config; |
20
|
6
|
|
66
|
|
|
20
|
$os ||= $^O; |
21
|
6
|
|
100
|
|
|
18
|
$env_hr ||= \%ENV; |
22
|
|
|
|
|
|
|
|
23
|
6
|
50
|
33
|
|
|
22
|
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
|
|
|
24
|
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
|
|
|
|
22
|
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
|
|
|
|
29
|
if ($os =~ m/^(?:qnx|nto|vos)$/ ) { |
42
|
3
|
|
|
|
|
10
|
$ERROR_MESSAGE = "$os: UNIX domain sockets not implemented."; |
43
|
3
|
|
|
|
|
8
|
return 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
3
|
100
|
|
|
|
10
|
if ($os eq 'MSWin32') { |
47
|
1
|
50
|
|
|
|
3
|
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__ |