line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Check::Socket; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
61247
|
use base qw(Exporter); |
|
5
|
|
|
|
|
26
|
|
|
5
|
|
|
|
|
590
|
|
4
|
5
|
|
|
5
|
|
30
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
89
|
|
5
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
168
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
52
|
use Config; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
209
|
|
8
|
5
|
|
|
5
|
|
2702
|
use IO::Socket; |
|
5
|
|
|
|
|
95854
|
|
|
5
|
|
|
|
|
17
|
|
9
|
5
|
|
|
5
|
|
4048
|
use Readonly; |
|
5
|
|
|
|
|
16300
|
|
|
5
|
|
|
|
|
1614
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $ERROR_MESSAGE; |
12
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(check_socket $ERROR_MESSAGE); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.02; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub check_socket { |
17
|
6
|
|
|
6
|
1
|
3081
|
my ($config_hr, $os, $env_hr) = @_; |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
100
|
|
|
21
|
$config_hr ||= \%Config; |
20
|
6
|
|
66
|
|
|
15
|
$os ||= $^O; |
21
|
6
|
|
100
|
|
|
14
|
$env_hr ||= \%ENV; |
22
|
|
|
|
|
|
|
|
23
|
6
|
50
|
33
|
|
|
20
|
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
|
|
|
19
|
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
|
|
|
|
17
|
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
|
|
|
|
27
|
if ($os =~ m/^(?:qnx|nto|vos)$/ ) { |
42
|
3
|
|
|
|
|
7
|
$ERROR_MESSAGE = "$os: UNIX domain sockets not implemented."; |
43
|
3
|
|
|
|
|
7
|
return 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
3
|
100
|
|
|
|
11
|
if ($os eq 'MSWin32') { |
47
|
1
|
50
|
|
|
|
3
|
if ($env_hr->{CONTINUOUS_INTEGRATION}) { |
48
|
|
|
|
|
|
|
# https://github.com/Perl/perl5/issues/17429 |
49
|
1
|
|
|
|
|
3
|
$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__ |