line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Session IDs: The data to maintain them, and accessors to get at them |
2
|
|
|
|
|
|
|
# sanely from other files. |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package POE::Resource::SIDs; |
5
|
|
|
|
|
|
|
|
6
|
175
|
|
|
175
|
|
848
|
use vars qw($VERSION); |
|
175
|
|
|
|
|
251
|
|
|
175
|
|
|
|
|
10037
|
|
7
|
|
|
|
|
|
|
$VERSION = '1.365'; # NOTE - Should be #.### (three decimal places) |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# These methods are folded into POE::Kernel; |
10
|
|
|
|
|
|
|
package POE::Kernel; |
11
|
|
|
|
|
|
|
|
12
|
175
|
|
|
175
|
|
832
|
use strict; |
|
175
|
|
|
|
|
441
|
|
|
175
|
|
|
|
|
54508
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
### Map session IDs to sessions. Map sessions to session IDs. |
15
|
|
|
|
|
|
|
### Maintain a sequence number for determining the next session ID. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my %kr_session_ids; |
18
|
|
|
|
|
|
|
# ( $session_id => $session_reference, |
19
|
|
|
|
|
|
|
# ..., |
20
|
|
|
|
|
|
|
# ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $kr_sid_seq = 0; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _data_sid_initialize { |
25
|
0
|
|
|
0
|
|
0
|
$poe_kernel->[KR_SESSION_IDS] = \%kr_session_ids; |
26
|
0
|
|
|
|
|
0
|
$poe_kernel->[KR_SID_SEQ] = \$kr_sid_seq; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _data_sid_relocate_kernel_id { |
30
|
4
|
|
|
4
|
|
29
|
my ($self, $old_id, $new_id) = @_; |
31
|
4
|
50
|
|
|
|
74
|
$kr_session_ids{$new_id} = delete $kr_session_ids{$old_id} |
32
|
|
|
|
|
|
|
if exists $kr_session_ids{$old_id}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
### End-run leak checking. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _data_sid_finalize { |
38
|
190
|
|
|
190
|
|
572
|
my $finalized_ok = 1; |
39
|
190
|
|
|
|
|
858
|
while (my ($sid, $ses) = each(%kr_session_ids)) { |
40
|
0
|
|
|
|
|
0
|
_warn "!!! Leaked session ID: $sid = $ses\n"; |
41
|
0
|
|
|
|
|
0
|
$finalized_ok = 0; |
42
|
|
|
|
|
|
|
} |
43
|
190
|
|
|
|
|
325
|
return $finalized_ok; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
### Allocate a new session ID. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _data_sid_allocate { |
49
|
807
|
|
|
807
|
|
3374
|
my $self = shift; |
50
|
807
|
|
|
|
|
2740
|
1 while exists $kr_session_ids{++$kr_sid_seq}; |
51
|
807
|
|
|
|
|
2218
|
return $kr_sid_seq; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
### Set a session ID. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _data_sid_set { |
57
|
1249
|
|
|
1249
|
|
2677
|
my ($self, $sid, $session) = @_; |
58
|
1249
|
|
|
|
|
3094
|
$kr_session_ids{$sid} = $session; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
### Clear a session ID. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _data_sid_clear { |
64
|
777
|
|
|
777
|
|
1591
|
my ($self, $sid) = @_; |
65
|
|
|
|
|
|
|
|
66
|
777
|
|
|
|
|
911
|
return delete $kr_session_ids{$sid} unless ASSERT_DATA; |
67
|
|
|
|
|
|
|
|
68
|
695
|
|
|
|
|
1613
|
my $removed = delete $kr_session_ids{$sid}; |
69
|
695
|
100
|
|
|
|
1735
|
_trap("unknown SID '$sid'") unless defined $removed; |
70
|
694
|
|
|
|
|
1248
|
$removed; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
### Resolve a session ID into its session. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _data_sid_resolve { |
76
|
212
|
|
|
212
|
|
318
|
my ($self, $sid) = @_; |
77
|
212
|
|
|
|
|
511
|
return $kr_session_ids{$sid}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |