| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Apache::Session::Lock::Memorycached |
|
4
|
|
|
|
|
|
|
# Copyright(c) eric german |
|
5
|
|
|
|
|
|
|
# Distribute under the Artistic License |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
############################################################################ |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Apache::Session::Lock::Memorycached; |
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
80
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
10
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
891
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$VERSION = '1.0'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
|
19
|
2
|
|
|
2
|
0
|
5
|
my $class = shift; |
|
20
|
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
16
|
return bless { read => 0, write => 0, opened => 0, id => 0 }, $class; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub acquire_read_lock { |
|
25
|
1
|
|
|
1
|
0
|
58
|
my $self = shift; |
|
26
|
1
|
|
|
|
|
3
|
my $session = shift; |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
50
|
|
|
|
5
|
return if $self->{read}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
5
|
if (!$self->{opened}) { |
|
31
|
1
|
|
|
|
|
2
|
$self->{opened} = 1; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
1
|
|
|
|
|
5
|
$self->{read} = 1; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub acquire_write_lock { |
|
37
|
2
|
|
|
2
|
0
|
134
|
my $self = shift; |
|
38
|
2
|
|
|
|
|
5
|
my $session = shift; |
|
39
|
|
|
|
|
|
|
|
|
40
|
2
|
50
|
|
|
|
12
|
return if $self->{write}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
2
|
100
|
|
|
|
8
|
if (!$self->{opened}) { |
|
43
|
1
|
|
|
|
|
2
|
$self->{opened} = 1; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
2
|
|
|
|
|
17
|
$self->{write} = 1; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub release_read_lock { |
|
49
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
50
|
0
|
|
|
|
|
0
|
my $session = shift; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
0
|
die unless $self->{read}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
0
|
if (!$self->{write}) { |
|
55
|
0
|
|
|
|
|
0
|
$self->{opened} = 0; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
$self->{read} = 0; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub release_write_lock { |
|
62
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
63
|
0
|
|
|
|
|
0
|
my $session = shift; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
0
|
die unless $self->{write}; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
0
|
if ($self->{read}) { |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
else { |
|
70
|
0
|
|
|
|
|
0
|
$self->{opened} = 0; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
$self->{write} = 0; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub release_all_locks { |
|
77
|
4
|
|
|
4
|
0
|
23
|
my $self = shift; |
|
78
|
4
|
|
|
|
|
6
|
my $session = shift; |
|
79
|
|
|
|
|
|
|
|
|
80
|
4
|
100
|
|
|
|
12
|
if ($self->{opened}) { |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
4
|
|
|
|
|
6
|
$self->{opened} = 0; |
|
84
|
4
|
|
|
|
|
6
|
$self->{read} = 0; |
|
85
|
4
|
|
|
|
|
18
|
$self->{write} = 0; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub DESTROY { |
|
89
|
2
|
|
|
2
|
|
22
|
my $self = shift; |
|
90
|
|
|
|
|
|
|
|
|
91
|
2
|
|
|
|
|
6
|
$self->release_all_locks; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub clean { |
|
95
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
96
|
0
|
|
|
|
|
|
my $dir = shift; |
|
97
|
0
|
|
|
|
|
|
my $time = shift; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=pod |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 NAME |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Apache::Session::Lock::File - Provides mutual exclusion using flock |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
use Apache::Session::Lock::File; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
my $locker = new Apache::Session::Lock::File; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
$locker->acquire_read_lock($ref); |
|
117
|
|
|
|
|
|
|
$locker->acquire_write_lock($ref); |
|
118
|
|
|
|
|
|
|
$locker->release_read_lock($ref); |
|
119
|
|
|
|
|
|
|
$locker->release_write_lock($ref); |
|
120
|
|
|
|
|
|
|
$locker->release_all_locks($ref); |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
$locker->clean($dir, $age); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Apache::Session::Lock::Memorycached fulfills the locking interface of |
|
127
|
|
|
|
|
|
|
Apache::Session. NO locking is using . |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
none |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 NOTES |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This module was written by eric german |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L |