File Coverage

blib/lib/Mail/SpamAssassin/Locker.pm
Criterion Covered Total %
statement 23 31 74.1
branch n/a
condition 1 3 33.3
subroutine 7 11 63.6
pod 0 5 0.0
total 31 50 62.0


line stmt bran cond sub pod time code
1             # <@LICENSE>
2             # Licensed to the Apache Software Foundation (ASF) under one or more
3             # contributor license agreements. See the NOTICE file distributed with
4             # this work for additional information regarding copyright ownership.
5             # The ASF licenses this file to you under the Apache License, Version 2.0
6             # (the "License"); you may not use this file except in compliance with
7             # the License. You may obtain a copy of the License at:
8             #
9             # http://www.apache.org/licenses/LICENSE-2.0
10             #
11             # Unless required by applicable law or agreed to in writing, software
12             # distributed under the License is distributed on an "AS IS" BASIS,
13             # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14             # See the License for the specific language governing permissions and
15             # limitations under the License.
16             # </@LICENSE>
17              
18             package Mail::SpamAssassin::Locker;
19              
20 25     25   160 use strict;
  25         63  
  25         806  
21 25     25   155 use warnings;
  25         42  
  25         803  
22             # use bytes;
23 25     25   165 use re 'taint';
  25         75  
  25         1045  
24 25     25   160 use Fcntl;
  25         52  
  25         10634  
25 25     25   226 use Time::HiRes ();
  25         39  
  25         465  
26              
27 25     25   138 use Mail::SpamAssassin;
  25         52  
  25         6147  
28              
29             our @ISA = qw();
30              
31             ###########################################################################
32              
33             sub new {
34 91     91 0 258 my $class = shift;
35 91   33     580 $class = ref($class) || $class;
36 91         212 my $self = { };
37 91         227 bless ($self, $class);
38 91         265 $self;
39             }
40              
41             ###########################################################################
42              
43             sub safe_lock {
44 0     0 0   my ($self, $path, $max_retries, $mode) = @_;
45             # max_retries is optional, should default to about 30
46             # mode is UNIX-style and optional, should default to 0700,
47             # callers must specify --x bits
48 0           die "locker: safe_lock not implemented by Locker subclass";
49             }
50              
51             ###########################################################################
52              
53             sub safe_unlock {
54 0     0 0   my ($self, $path) = @_;
55 0           die "locker: safe_unlock not implemented by Locker subclass";
56             }
57              
58             ###########################################################################
59              
60             sub refresh_lock {
61 0     0 0   my ($self, $path) = @_;
62 0           die "locker: refresh_lock not implemented by Locker subclass";
63             }
64              
65             ###########################################################################
66              
67             sub jittery_one_second_sleep {
68 0     0 0   my ($self) = @_;
69 0           Time::HiRes::sleep(rand(1.0) + 0.5);
70             }
71              
72             ###########################################################################
73              
74             1;