line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Signalet::Client; |
2
|
4
|
|
|
4
|
|
204132
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
224
|
|
3
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
127
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
1832
|
use parent qw(Net::Signalet); |
|
4
|
|
|
|
|
660
|
|
|
4
|
|
|
|
|
24
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
167
|
use Carp(); |
|
4
|
|
|
|
|
37
|
|
|
4
|
|
|
|
|
1241
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
2
|
|
|
2
|
0
|
5367
|
my ($class, @args) = @_; |
11
|
2
|
50
|
33
|
|
|
98
|
my %args = @args == 1 && ref($args[0]) eq 'HASH' ? %{$args[0]} : @args; |
|
0
|
|
|
|
|
0
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
|
|
127
|
$class->SUPER::_init(%args); |
14
|
|
|
|
|
|
|
|
15
|
2
|
100
|
50
|
|
|
203
|
my $sock = IO::Socket::INET->new( |
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
16
|
|
|
|
|
|
|
Proto => 'tcp', |
17
|
|
|
|
|
|
|
PeerAddr => $args{daddr}, |
18
|
|
|
|
|
|
|
PeerPort => $args{dport} || 14550, |
19
|
|
|
|
|
|
|
LocalAddr => $args{saddr} || undef, |
20
|
|
|
|
|
|
|
LocalPort => $args{sport} || undef, |
21
|
|
|
|
|
|
|
Timeout => $args{timeout} || 5, |
22
|
|
|
|
|
|
|
) or Carp::croak "Can't connect to server: $!"; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
7847
|
my $self = bless { |
25
|
|
|
|
|
|
|
worker_pid => undef, |
26
|
|
|
|
|
|
|
sock => $sock |
27
|
|
|
|
|
|
|
}, $class; |
28
|
1
|
|
|
|
|
12
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub run { |
33
|
0
|
|
|
0
|
0
|
|
my ($self, %params) = @_; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
0
|
|
|
|
if (!exists $params{command} && !exists $params{code}) { |
36
|
0
|
|
|
|
|
|
Carp::croak "Required command or code"; |
37
|
|
|
|
|
|
|
} |
38
|
0
|
0
|
|
|
|
|
if (my $command = $params{command}) { |
|
|
0
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
my $command = join ' ', @{$params{command}} if ref($params{command}) eq 'ARRAY'; |
|
0
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
system($command); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ($params{code}) { |
43
|
0
|
|
|
|
|
|
my $pid = fork; |
44
|
0
|
0
|
|
|
|
|
unless ($pid) { |
45
|
|
|
|
|
|
|
# child process |
46
|
0
|
|
|
|
|
|
$params{code}->(); |
47
|
|
|
|
|
|
|
} |
48
|
0
|
0
|
|
|
|
|
$self->{worker_pid} = $pid if $pid > 0; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |