File Coverage

blib/lib/Apache/ASP/Application.pm
Criterion Covered Total %
statement 30 53 56.6
branch 4 20 20.0
condition 2 6 33.3
subroutine 10 12 83.3
pod 0 5 0.0
total 46 96 47.9


line stmt bran cond sub pod time code
1              
2             package Apache::ASP::Application;
3              
4 6     6   82 use Apache::ASP::State;
  6         56  
  6         108  
5 6     6   120 use Apache::ASP::Collection;
  6         53  
  6         140  
6              
7 6     6   91 use strict;
  6         55  
  6         88  
8 6     6   118 no strict qw(refs);
  6         86  
  6         108  
9 6     6   87 use vars qw(@ISA);
  6         56  
  6         97  
10             @ISA = qw(Apache::ASP::Collection Apache::ASP::State);
11 6     6   99 use Fcntl qw(:flock O_RDWR O_CREAT );
  6         54  
  6         126  
12              
13             sub new {
14 7     7 0 73     my($asp) = @_;
15 7         64     my(%self);
16              
17 7 50       84     unless(
18             tie(
19             %self,'Apache::ASP::State', $asp,
20             'application', 'server',
21             )
22             )
23                 {
24 0         0 $asp->Error("can't tie to application state");
25 0         0 return;
26                 }
27              
28 7         471     bless \%self;
29             }
30              
31 2     2 0 55 sub Lock { shift->SUPER::LOCK };
32 12     12 0 240 sub UnLock { shift->SUPER::UNLOCK };
33              
34             sub SessionCount {
35 0     0 0 0     my $asp = tied(%{$_[0]})->{asp};
  0         0  
36 0 0       0     if($asp->{session_count}) {
37 0         0 $asp->{Internal}{SessionCount};
38                 } else {
39 0         0 undef;
40                 }
41             }
42              
43             sub GetSession {
44 1     1 0 36     my($self, $id) = @_;
45 1         15     my $asp = tied(%$self)->{'asp'};
46 1 50 33     18     unless(defined $id and $id) {
47 0         0 $asp->Warn("session id not defined");
48 0         0 return;
49                 }
50 1 50       14     unless(length($id) >= 8) {
51 0         0 $asp->Warn("session id must be of at least 8 in length");
52 0         0 return;
53                 }
54              
55 1 50 33     17     if($asp->{Session} and $asp->{Session}->SessionID() eq $id) {
56 1         15 return $asp->{Session};
57                 } else {
58 0           my $new_session = Apache::ASP::Session::new($asp, $id, O_RDWR, 'NOERR');
59 0 0         if($new_session) {
60 0 0         if ($asp->{get_session_last}) {
61 0           my $session_obj = tied %{$asp->{get_session_last}};
  0            
62 0 0         $asp->{dbg} && $asp->Debug("freeing last session $asp->{get_session_last} $session_obj");
63 0 0         $session_obj && $session_obj->DESTROY;
64             }
65 0           $asp->{get_session_last} = $new_session;
66             $asp->RegisterCleanup(sub {
67 0     0     my $session_obj = tied %$new_session;
68 0 0         $session_obj && $session_obj->DESTROY;
69 0           });
70             }
71 0           $new_session;
72                 }
73             }
74              
75             1;
76