line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MogileFS::Connection::Mogstored; |
2
|
21
|
|
|
21
|
|
88
|
use strict; |
|
21
|
|
|
|
|
33
|
|
|
21
|
|
|
|
|
649
|
|
3
|
21
|
|
|
21
|
|
103
|
use IO::Socket::INET; |
|
21
|
|
|
|
|
33
|
|
|
21
|
|
|
|
|
197
|
|
4
|
21
|
|
|
21
|
|
11458
|
use Socket qw(SO_KEEPALIVE); |
|
21
|
|
|
|
|
40
|
|
|
21
|
|
|
|
|
3679
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
0
|
|
|
0
|
0
|
|
my ($class, $ip, $port) = @_; |
8
|
0
|
|
|
|
|
|
return bless { |
9
|
|
|
|
|
|
|
sock => undef, # undef if not yet connected, else socket to host |
10
|
|
|
|
|
|
|
ip => $ip, |
11
|
|
|
|
|
|
|
port => $port, |
12
|
|
|
|
|
|
|
}, $class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# returns (or connects to & returns) raw socket to mogstored. |
16
|
|
|
|
|
|
|
sub sock { |
17
|
0
|
|
|
0
|
0
|
|
my ($self, $timeout) = @_; |
18
|
0
|
0
|
|
|
|
|
return $self->{sock} if $self->{sock}; |
19
|
0
|
0
|
|
|
|
|
$self->{sock} = IO::Socket::INET->new(PeerAddr => $self->{ip}, |
20
|
|
|
|
|
|
|
PeerPort => $self->{port}, |
21
|
|
|
|
|
|
|
Timeout => $timeout) or die "Could not connect to mogstored on ".$self->{ip}.":".$self->{port}; |
22
|
0
|
|
|
|
|
|
$self->{sock}->sockopt(SO_KEEPALIVE, 1); |
23
|
0
|
|
|
|
|
|
return $self->{sock}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub mark_dead { |
27
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
28
|
0
|
|
|
|
|
|
$self->{sock} = undef; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |