| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::FDkeeper ; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
47306
|
use strict ; |
|
|
5
|
|
|
|
|
13
|
|
|
|
5
|
|
|
|
|
186
|
|
|
4
|
5
|
|
|
5
|
|
7272
|
use IO::Handle ; |
|
|
5
|
|
|
|
|
53642
|
|
|
|
5
|
|
|
|
|
310
|
|
|
5
|
5
|
|
|
5
|
|
43
|
use Carp ; |
|
|
5
|
|
|
|
|
17
|
|
|
|
5
|
|
|
|
|
3045
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$File::FDkeeper::VERSION = '0.06' ; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
12
|
|
|
12
|
1
|
25657
|
my $class = shift ; |
|
13
|
12
|
|
|
|
|
158
|
my %args = @_ ; |
|
14
|
|
|
|
|
|
|
|
|
15
|
12
|
|
|
|
|
45
|
my $this = undef ; |
|
16
|
12
|
100
|
|
|
|
69
|
if ($args{'Local'}){ |
|
|
|
100
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# server mode |
|
18
|
6
|
|
|
|
|
41
|
my $path = delete $args{'Local'} ; |
|
19
|
6
|
|
|
|
|
5320
|
require File::FDkeeper::Server ; |
|
20
|
0
|
|
|
|
|
0
|
$this = new File::FDkeeper::Server($path, %args) ; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
elsif ($args{'Peer'}){ |
|
23
|
|
|
|
|
|
|
# client mode |
|
24
|
4
|
|
|
|
|
24
|
my $path = delete $args{'Peer'} ; |
|
25
|
4
|
|
|
|
|
5326
|
require File::FDkeeper::Client ; |
|
26
|
0
|
|
|
|
|
0
|
$this = new File::FDkeeper::Client($path, %args) ; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
else { |
|
29
|
2
|
|
|
|
|
412
|
croak("You must specify either 'Local' or 'Peer' when creating an instance of File::FDkeeper") ; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return $this ; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _read_resp_code { |
|
37
|
0
|
|
|
0
|
|
|
my $this = shift ; |
|
38
|
0
|
|
|
|
|
|
my $h = shift ; |
|
39
|
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return _read_n_from($h, 3, 1) ; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _read_command { |
|
45
|
0
|
|
|
0
|
|
|
my $this = shift ; |
|
46
|
0
|
|
|
|
|
|
my $h = shift ; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return _read_n_from($h, 3, 0) ; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _read_n_from { |
|
53
|
0
|
|
|
0
|
|
|
my $h = shift ; |
|
54
|
0
|
|
|
|
|
|
my $len = shift ; |
|
55
|
0
|
|
|
|
|
|
my $hard = shift ; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $buf = '' ; |
|
58
|
0
|
|
|
|
|
|
my $left = $len ; |
|
59
|
0
|
|
|
|
|
|
while ($left > 0){ |
|
60
|
0
|
|
|
|
|
|
my $b = _read_from($h, $left) ; |
|
61
|
0
|
0
|
|
|
|
|
if (! defined($b)){ |
|
62
|
0
|
0
|
0
|
|
|
|
if (($left > $len)||($hard)){ |
|
63
|
0
|
|
|
|
|
|
croak("Unexpected EOF ($left bytes missing)") ; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
else { |
|
66
|
|
|
|
|
|
|
# Nothing read yet... |
|
67
|
0
|
|
|
|
|
|
return undef ; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$buf .= $b ; |
|
72
|
0
|
|
|
|
|
|
$left -= length($b) ; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return $buf ; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _read_from { |
|
80
|
0
|
|
|
0
|
|
|
my $h = shift ; |
|
81
|
0
|
|
|
|
|
|
my $bufsize = shift ; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $buf = '' ; |
|
84
|
0
|
|
|
|
|
|
my $res = $h->sysread($buf, $bufsize) ; |
|
85
|
0
|
0
|
|
|
|
|
if ($res < 0){ |
|
|
|
0
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
croak("I/O Error: $!") ; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
elsif ($res == 0){ |
|
89
|
0
|
|
|
|
|
|
return undef ; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
else { |
|
92
|
0
|
|
|
|
|
|
return $buf ; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1 ; |