line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Lemonldap::NG::Common::Apache::Session::Lock; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
246
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $VERSION = '1.4.1'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
10
|
0
|
|
|
|
|
|
my $session = shift; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my $self = {}; |
13
|
0
|
|
|
|
|
|
$self->{args} = $session->{args}; |
14
|
0
|
|
|
|
|
|
bless $self, $class; |
15
|
0
|
|
|
|
|
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub module { |
19
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
20
|
0
|
|
|
|
|
|
return $self->{args}->{lock_manager}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub cache { |
24
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
return $self->{cache} if $self->{cache}; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $module = $self->{args}->{localStorage}; |
29
|
0
|
|
|
|
|
|
eval "use $module;"; |
30
|
0
|
|
|
|
|
|
$self->{cache} = $module->new( $self->{args}->{localStorageOptions} ); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
return $self->{cache}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub acquire_read_lock { |
36
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
37
|
0
|
|
|
|
|
|
my $session = shift; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Get session from cache |
40
|
0
|
|
|
|
|
|
my $id = $session->{data}->{_session_id}; |
41
|
0
|
0
|
|
|
|
|
if ( $self->cache->get($id) ) { |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# got session from cache, no need to ask for locks |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
0
|
|
|
|
|
|
$self->module->acquire_read_lock($session); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub acquire_write_lock { |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
0
|
|
|
|
|
|
my $session = shift; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->module->acquire_write_lock($session); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub release_write_lock { |
58
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
59
|
0
|
|
|
|
|
|
my $session = shift; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->module->release_write_lock($session); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub release_all_locks { |
65
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
66
|
0
|
|
|
|
|
|
my $session = shift; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Get session from cache |
69
|
0
|
|
|
|
|
|
my $id = $session->{data}->{_session_id}; |
70
|
0
|
0
|
|
|
|
|
if ( $self->cache->get($id) ) { |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# got session from cache, no need to ask for locks |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else { |
75
|
0
|
|
|
|
|
|
$self->module->release_all_locks($session); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|