MtPolicyd.pm

filter: Statementstmt 14.5% 38 / 262 Branchbran 0.0% 0 / 76 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 36.3% 12 / 33 Podpod 38.4% 5 / 13 totaltotal 13.1% 55 / 418 CC 48 SCAR 37.3
CC
48
Cov
11%
configure
156.0
process_request
72.0
get_virtual_host
42.0
CRAP 41.5
« MtPolicyd/Plugin/SqlList.pm ↑ Summary MtPolicyd/Plugin/SPF.pm »
1 package Mail::MtPolicyd;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw(Net::Server::PreFork);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.12'; # VERSION
7 # ABSTRACT: the Mailteam policy daemon for postfix
8  
9 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Mail::MtPolicyd::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Mail::MtPolicyd::VirtualHost;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Cache::Memcached;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Time::HiRes qw( usleep tv_interval gettimeofday );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Tie::IxHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Config::General qw(ParseConfig);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
19
20  
21 sub _preload_modules {
22 # PRELOAD some modules
23 0 ▶ my @modules = (
Subroutine _preload_modules: not called CC=2 SCAR=17.9
24 'BerkeleyDB',
25 'BerkeleyDB::Hash',
26 'DBI',
27 'DBD::mysql',
28 'HTTP::Request::Common',
29 'JSON',
30 'LWP::UserAgent',
31 'Mail::RBL',
32 'Moose',
33 'Moose::Role',
34 'MooseX::Getopt',
35 'MooseX::Role::Parameterized',
36 'namespace::autoclean',
37 );
38  
39 0 foreach my $module (@modules) {
40 0 $module =~ s/::/\//g;
41 0 $module .= '.pm';
42 0 require $module;
43 }
44 }
45  
46 sub _apply_values_from_config {
47 0 ▶ my ( $self, $target, $config ) = ( shift, shift, shift );
Subroutine _apply_values_from_config: not called CC=3 SCAR=24.8
48  
49 0 ▶ while ( my $key = shift ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $key = shift()) 0 0 0
50 0 ▶ if(! defined $config->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $config->{$key}) 0 0 0
51 0 next;
52 }
53 0 $target->{$key} = $config->{$key};
54 }
55  
56 0 return;
57 }
58  
59 sub _apply_array_from_config {
60 0 ▶ my ( $self, $target, $config ) = ( shift, shift, shift );
Subroutine _apply_array_from_config: not called CC=3 SCAR=24.8
61  
62 0 ▶ while ( my $key = shift ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $key = shift()) 0 0 0
63 0 ▶ if(! defined $config->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $config->{$key}) 0 0 0
64 0 next;
65 }
66 0 $target->{$key} = [ split(/\s*,\s*/, $config->{$key}) ];
67 }
68  
69 0 return;
70 }
71  
72 sub print_usage {
73 0 ▶ print "mtpolicyd [-h|--help] [-c|--config=<file>] [-f|--foreground] [-l|--loglevel=<level>] [-d|--dump_vhosts]\n";
Subroutine print_usage: not called CC=1 SCAR=6.9
Pod undocumented
74 0 return;
75 }
76  
77 sub configure {
78 0 ▶ my $self = shift;
Subroutine configure: not called CC=12 SCAR=50.5
Pod documented
79 0 my $server = $self->{'server'};
80 0 my $cmdline;
81
82 0 ▶ return if(@_);
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
83  
84 0 $server->{'config_file'} = '/etc/mtpolicyd/mtpolicyd.conf';
85 0 $server->{'background'} = 1;
86 0 $server->{'setsid'} = 1;
87 0 $server->{'no_close_by_child'} = 1;
88  
89 # Parse command line params
90 0 %{$cmdline} = ();
91 GetOptions(
92 0 \%{$cmdline},
93 "help|h",
94 "dump_config|d",
95 "config|c:s",
96 "foreground|f",
97 "loglevel|l:i",
98 );
99 0 ▶ if ($cmdline->{'help'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdline->{"help"}) 0 0 0
100 0 $self->print_usage;
101 0 exit 0;
102 }
103 0 ▶ if (defined($cmdline->{'config'}) && $cmdline->{'config'} ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cmdline->{"config"} and $cmdline->{"config"} ne "") 0 0 0
Condition0%0/3
defined $cmdline->{"config"} and $cmdline->{"config"} ne ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $cmdline->{"config"} and $cmdline->{"config"} ne ""
defined $cmdline->{"config"} $cmdline->{"config"} ne ""
Truth table0%0/3
A and B
A= defined $cmdline->{"config"}B= $cmdline->{"config"} ne ""
ABresult
0X0
100
111
104 0 $server->{'config_file'} = $cmdline->{'config'};
105 }
106 0 ▶ if( ! -f $server->{'config_file'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $server->{"config_file"}) 0 0 0
107 0 print(STDERR 'configuration file '.$server->{'config_file'}.' does not exist!\n');
108 0 exit 1;
109 }
110  
111 # DEFAULTS
112 0 $server->{'user'} = 'nobody';
113 0 $server->{'group'} = 'nobody';
114  
115 0 $server->{'log_level'} = 2;
116 0 ▶ if( ! $cmdline->{'foreground'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cmdline->{"foreground"}) 0 0 0
117 0 $server->{'log_file'} = 'Sys::Syslog';
118 }
119 0 $server->{'syslog_ident'} = 'mtpolicyd';
120 0 $server->{'syslog_facility'} = 'mail';
121  
122 0 $server->{'proto'} = 'tcp';
123 0 $server->{'host'} = '127.0.0.1';
124 0 $server->{'port'} = [
125 '127.0.0.1:12345',
126 '127.0.0.1:12346',
127 '127.0.0.1:12347',
128 '127.0.0.1:12348',
129 ];
130  
131 0 $server->{'min_servers'} = 4;
132 0 $server->{'min_spare_servers'} = 4;
133 0 $server->{'max_spare_servers'} = 12;
134 0 $server->{'max_servers'} = 25;
135 0 $server->{'max_requests'} = 1000;
136  
137 0 $self->{'request_timeout'} = 20;
138  
139 0 $self->{'keepalive_timeout'} = 60;
140 0 $self->{'max_keepalive'} = 0;
141  
142 0 $self->{'db_dsn'} = 'dbi:mysql:mail';
143 0 $self->{'db_user'} = '';
144 0 $self->{'db_password'} = '';
145  
146 0 $self->{'memcached_servers'} = [ '127.0.0.1:11211' ];
147 0 $self->{'memcached_namespace'} = 'mt-';
148 0 $self->{'memcached_expire'} = 5 * 60;
149  
150 # will be incremented in linear steps 50, 100, 150...
151 0 $self->{'session_lock_wait'} = 50; # usec
152 0 $self->{'session_lock_max_retry'} = 50; # times
153 0 $self->{'session_lock_timeout'} = 10; # sec
154  
155 0 $self->{'program_name'} = $0;
156  
157 # APPLY values from configuration file
158 0 tie my %config_hash, "Tie::IxHash";
159 %config_hash = ParseConfig(
160 -AllowMultiOptions => 'no',
161 0 -ConfigFile => $server->{'config_file'},
162 -Tie => "Tie::IxHash"
163 );
164 0 my $config = \%config_hash;
165  
166 0 $self->_apply_values_from_config($server, $config,
167 'user', 'group', 'pid_file',
168 'log_level', 'log_file', 'syslog_ident', 'syslog_facility',
169 'host',
170 'min_servers', 'min_spare_servers', 'max_spare_servers',
171 'max_servers', 'max_requests',
172 'chroot',
173 );
174 0 $self->_apply_array_from_config($server, $config, 'port');
175  
176 0 $self->_apply_values_from_config($self, $config,
177 'request_timeout', 'keepalive_timeout', 'max_keepalive',
178 'db_dsn', 'db_user', 'db_password',
179 'memcached_namespace', 'memcached_expire',
180 'session_lock_wait', 'session_lock_max_retry', 'session_lock_timeout',
181 'program_name',
182 );
183 0 $self->_apply_array_from_config($self, $config, 'memcached_servers');
184  
185 # LOAD VirtualHosts
186 0 ▶ if( ! defined $config->{'VirtualHost'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $config->{"VirtualHost"}) 0 0 0
187 0 print(STDERR 'no virtual hosts configured!\n');
188 0 exit 1;
189 }
190 0 my $vhosts = $config->{'VirtualHost'};
191  
192 0 $self->{'virtual_hosts'} = {};
193 0 foreach my $vhost_port (keys %$vhosts) {
194 0 my $vhost = $vhosts->{$vhost_port};
195 0 $self->{'virtual_hosts'}->{$vhost_port} =
196 Mail::MtPolicyd::VirtualHost->new_from_config($vhost_port, $vhost)
197 }
198 0 ▶ if ($cmdline->{'dump_config'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdline->{"dump_config"}) 0 0 0
199 0 print "----- Virtual Hosts -----\n";
200 0 print Dumper( $self->{'virtual_hosts'} );
201 0 exit 0;
202 }
203  
204 # foreground mode (cmdline)
205 0 ▶ if ($cmdline->{'foreground'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdline->{"foreground"}) 0 0 0
206 0 $server->{'background'} = undef;
207 0 $server->{'setsid'} = undef;
208 }
209 0 ▶ if( $cmdline->{'loglevel'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmdline->{"loglevel"}) 0 0 0
210 0 $server->{'log_level'} = $cmdline->{'loglevel'};
211 }
212  
213  
214 # change processname in top/ps
215 0 $self->_set_process_stat('master');
216  
217 0 return;
218 }
219  
220 sub pre_loop_hook {
221 0 ▶ my $self = shift;
Subroutine pre_loop_hook: not called CC=1 SCAR=6.9
Pod documented
222  
223 0 $self->_preload_modules;
224  
225 0 return;
226 }
227  
228 sub child_init_hook {
229 0 ▶ my $self = shift;
Subroutine child_init_hook: not called CC=3 SCAR=24.8
Pod documented
230  
231 0 $self->_set_process_stat('virgin child');
232  
233 0 ▶ if( defined $self->{'db_dsn'} && $self->{'db_dsn'} !~ /^\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"db_dsn"} and not $self->{"db_dsn"} =~ /^\s*$/) 0 0 0
Condition0%0/3
defined $self->{"db_dsn"} and not $self->{"db_dsn"} =~ /^\s*$/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"db_dsn"} and not $self->{"db_dsn"} =~ /^\s*$/
defined $self->{"db_dsn"} not $self->{"db_dsn"} =~ /^\s*$/
Truth table0%0/3
A and not(B)
A= defined $self->{"db_dsn"}B= not $self->{"db_dsn"} =~ /^\s*$/
ABresult
0X0
100
111
234 $self->{'dbh'} = DBI->connect($self->{'db_dsn'},
235 0 $self->{'db_user'}, $self->{'db_password'}, {
236 RaiseError => 1,
237 AutoCommit => 1,
238 mysql_auto_reconnect => 1,
239 },
240 );
241 }
242  
243 $self->{'memcached'} = Cache::Memcached->new( {
244 'servers' => $self->{'memcached_servers'},
245 'debug' => 0,
246 0 'namespace' => $self->{'memcached_namespace'},
247 } );
248  
249 0 return;
250 }
251  
252 sub child_finish_hook {
253 0 ▶ my $self = shift;
Subroutine child_finish_hook: not called CC=2 SCAR=17.9
Pod documented
254 0 $self->_set_process_stat('finish');
255  
256 0 ▶ if( defined $self->{'dbh'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"dbh"}) 0 0 0
257 0 $self->{'dbh'}->disconnect;
258 }
259 0 return;
260 }
261  
262 sub memcached {
263 0 ▶ my $self = shift;
Subroutine memcached: not called CC=2 SCAR=17.9
Pod undocumented
264 0 ▶ if( ! defined $self->{'memcached'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"memcached"}) 0 0 0
265 0 die('no memcached connection available!');
266 }
267 0 return( $self->{'memcached'} );
268 }
269  
270 sub acquire_session_lock {
271 0 ▶ my ( $self, $instance ) = @_;
Subroutine acquire_session_lock: not called CC=3 SCAR=24.8
Pod undocumented
272 0 my $lock = 'lock_'.$instance;
273 0 my $wait = $self->{'session_lock_wait'};
274 0 my $max_retry = $self->{'session_lock_max_retry'};
275 0 my $lock_ttl = $self->{'session_lock_timeout'};
276  
277 0 ▶ for( my $try = 1 ; $try < $max_retry ; $try++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($try < $max_retry) 0 0 0
278 0 ▶ if( $self->{'memcached'}->add($lock, 1, $lock_ttl) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"memcached"}->add($lock, 1, $lock_ttl)) 0 0 0
279 0 return; # lock created
280 }
281 0 usleep( $wait * $try );
282 }
283  
284 0 die('could not acquire lock for session '.$instance);
285 0 return;
286 }
287  
288 sub release_session_lock {
289 0 ▶ my ( $self, $instance ) = @_;
Subroutine release_session_lock: not called CC=1 SCAR=6.9
Pod undocumented
290 0 my $lock = 'lock_'.$instance;
291  
292 0 $self->{'memcached'}->delete($lock);
293  
294 0 return;
295 }
296  
297 sub retrieve_session {
298 0 ▶ my ($self, $instance ) = @_;
Subroutine retrieve_session: not called CC=3 SCAR=24.8
Pod undocumented
299  
300 0 ▶ if( ! defined $instance ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $instance) 0 0 0
301 0 return;
302 }
303  
304 0 $self->acquire_session_lock( $instance );
305  
306 0 ▶ if( my $session = $self->{'memcached'}->get($instance) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $session = $self->{"memcached"}->get($instance)) 0 0 0
307 0 return($session);
308 }
309
310 0 return( { '_instance' => $instance } );
311 }
312  
313 sub store_session {
314 0 ▶ my ($self, $session ) = @_;
Subroutine store_session: not called CC=4 SCAR=30.0
Pod undocumented
315 0 my $instance = $session->{'_instance'};
316 0 ▶ my $expire = defined $self->{'memcached_expire'} ? $self->{'memcached_expire'} : 300;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'memcached_expire'} ? : 0 0 0
317  
318 0 ▶ if( ! defined $session || ! defined $instance ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $session and defined $instance) 0 0 0
Condition0%0/3
defined $session and defined $instance
!ll&&!rl&&r
000
MC/DC0%0/2
defined $session and defined $instance
defined $session defined $instance
Truth table0%0/3
A and B
A= defined $sessionB= defined $instance
ABresult
0X0
100
111
319 0 return;
320 }
321
322 0 $self->{'memcached'}->set($instance, $session, $expire);
323  
324 0 $self->release_session_lock($instance);
325  
326 0 return;
327 }
328  
329 sub get_virtual_host {
330 0 ▶ my $self = shift;
Subroutine get_virtual_host: not called CC=6 SCAR=37.4
Pod undocumented
331 0 my $server = $self->{server};
332 0 my $client = $server->{client};
333 0 my $vhost_port;
334 0 ▶ my $is_socket = $client && $client->UNIVERSAL::can('NS_proto') &&
Condition0%0/6
$client && $client->UNIVERSAL::can('NS_proto') && $client->NS_proto eq 'UNIX'
!ll&&!rl&&r
000
$client and $client->UNIVERSAL::can("NS_proto")
!ll&&!rl&&r
000
MC/DC0%0/3
$client && $client->UNIVERSAL::can('NS_proto') && $client->NS_proto eq 'UNIX'
$client $client->UNIVERSAL::can("NS_proto") $client->NS_proto eq 'UNIX'
Truth table0%0/4
A and B && C
A= $clientB= $client->UNIVERSAL::can("NS_proto")C= $client->NS_proto eq 'UNIX'
ABCresult
0XX0
10X0
1100
1111
335 $client->NS_proto eq 'UNIX';
336  
337 0 ▶ if( $is_socket ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_socket) { } 0 0 0
338 0 ▶ $vhost_port = Net::Server->VERSION >= 2 ? $client->NS_port
Branch: 1 branch
BranchTrueFalseTotal
'Net::Server'->VERSION >= 2 ? : 0 0 0
339 : $client->NS_unix_path;
340 } else {
341 0 $vhost_port = $self->{'server'}->{'sockport'};
342 }
343 0 my $vhost = $self->{'virtual_hosts'}->{$vhost_port};
344 0 ▶ if( ! defined $vhost ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $vhost) 0 0 0
345 0 die('no virtual host defined for port '.$vhost_port);
346 }
347 0 return($vhost);
348 }
349  
350 sub get_dbh {
351 0 ▶ my $self = shift;
Subroutine get_dbh: not called CC=2 SCAR=17.9
Pod undocumented
352 0 ▶ if( ! defined $self->{'dbh'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"dbh"}) 0 0 0
353 0 die('no database connection available (no configured?)');
354 }
355 0 return( $self->{'dbh'} );
356 }
357  
358 sub _is_debug {
359 0 ▶ my $self = shift;
Subroutine _is_debug: not called CC=3 SCAR=24.8
360 0 ▶ if( $self->{'server'}->{'log_level'} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"server"}{"log_level"} and $self->{"server"}{"log_level"} >= 4) 0 0 0
Condition0%0/3
$self->{"server"}{"log_level"} and $self->{"server"}{"log_level"} >= 4
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"server"}{"log_level"} and $self->{"server"}{"log_level"} >= 4
$self->{"server"}{"log_level"} $self->{"server"}{"log_level"} >= 4
Truth table0%0/3
A and B
A= $self->{"server"}{"log_level"}B= $self->{"server"}{"log_level"} >= 4
ABresult
0X0
100
111
361 $self->{'server'}->{'log_level'} >= 4 ) {
362 0 return(1);
363 }
364 0 return(0);
365 }
366  
367 sub _process_one_request {
368 0 ▶ my ( $self, $conn, $vhost, $r ) = @_;
Subroutine _process_one_request: not called CC=6 SCAR=37.4
369 0 my $port = $vhost->port;
370 0 my $s;
371 my $error;
372  
373 0 eval {
374 0 my $start_t = [gettimeofday];
375 0 ▶ local $SIG{'ALRM'} = sub { die "Request timeout!" };
Subroutine __ANON__: not called CC=1 SCAR=6.9
376 0 my $timeout = $self->{'request_timeout'};
377 0 alarm($timeout);
378  
379 0 ▶ if( $self->_is_debug ) { $self->log(4, 'request: '.$r->dump_attr); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_debug) 0 0 0
380 0 my $instance = $r->attr('instance');
381  
382 0 $s = $self->retrieve_session($instance);
383 0 ▶ if( $self->_is_debug ) { $self->log(4, 'session: '.Dumper($s)); }
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_debug) 0 0 0
384 0 $r->session($s);
385  
386 0 my $result = $vhost->run($r);
387  
388 0 my $response = $result->as_policyd_response;
389 0 $conn->print($response);
390 0 $conn->flush;
391  
392 # convert to ms and round by 0.5/int
393 0 my $elapsed = int(tv_interval( $start_t, [gettimeofday] ) * 100 + 0.5);
394 0 $self->log(1, $vhost->name.': instance='.$instance.', type='.$r->type.', t='.$elapsed.'ms, result='.$result->as_log);
395 };
396 0 ▶ if ( $@ ) { $error = $@; }
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
397  
398 0 ▶ if( defined $s ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $s) 0 0 0
399 0 $self->store_session($s);
400 }
401  
402 0 ▶ if( defined $error ) { die( $error ); }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $error) 0 0 0
403  
404 0 return;
405 }
406  
407 sub process_request {
408 0 ▶ my ( $self, $conn ) = @_;
Subroutine process_request: not called CC=8 SCAR=42.8
Pod documented
409 0 my $max_keepalive = $self->{'max_keepalive'};
410  
411 0 my $vhost = $self->get_virtual_host;
412 0 my $port = $vhost->port;
413 0 $self->log(4, 'accepted connection on port '.$port );
414  
415 0 ▶ for( my $alive_count = 0
Branch: 1 branch
BranchTrueFalseTotal
if ($max_keepalive == 0 or $alive_count < $max_keepalive) 0 0 0
Condition0%0/3
$max_keepalive == 0 or $alive_count < $max_keepalive
l!l&&r!l&&!r
000
MC/DC0%0/2
$max_keepalive == 0 or $alive_count < $max_keepalive
$max_keepalive == 0 $alive_count < $max_keepalive
Truth table0%0/3
A or B
A= $max_keepalive == 0B= $alive_count < $max_keepalive
ABresult
1X1
011
000
416 ; $max_keepalive == 0 || $alive_count < $max_keepalive
417 ; $alive_count++ ) {
418 0 my $r;
419 0 $self->_set_process_stat($vhost->name.', waiting request');
420 0 eval {
421 0 ▶ local $SIG{'ALRM'} = sub { die "Keepalive connection timeout" };
Subroutine __ANON__: not called CC=1 SCAR=6.9
422 0 my $timeout = $self->{'keepalive_timeout'};
423 0 alarm($timeout);
424 0 $r = Mail::MtPolicyd::Request->new_from_fh( $conn, 'server' => $self );
425 };
426 0 ▶ if ( $@ =~ /Keepalive connection timeout/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($@ =~ /Keepalive connection timeout/) { } 0 0 0
elsif ($@ =~ /connection closed by peer/) { } 0 0 0
elsif ($@) { } 0 0 0
427 0 $self->log(3, '['.$port.']: keepalive timeout: closing connection');
428 0 last;
429 } elsif($@ =~ /connection closed by peer/) {
430 0 $self->log(3, '['.$port.']: connection closed by peer');
431 0 last;
432 } elsif($@) {
433 0 $self->log(0, '['.$port.']: error while reading request: '.$@);
434 0 last;
435
436 }
437 0 $self->_set_process_stat($vhost->name.', processing request');
438 0 eval {
439 0 $self->_process_one_request( $conn, $vhost, $r );
440 };
441 0 ▶ if ( $@ =~ /Request timeout!/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@ =~ /Request timeout!/) { } 0 0 0
elsif ($@) { } 0 0 0
442 0 $self->log(1, '['.$port.']: request timed out');
443 0 last;
444 } elsif($@) {
445 0 $self->log(0, 'error while processing request: '.$@);
446 0 last;
447 }
448 }
449  
450 0 $self->log(3, '['.$port.']: closing connection');
451 0 $self->_set_process_stat('idle');
452  
453 0 return;
454 }
455  
456 sub _set_process_stat {
457 0 ▶ my ( $self, $stat ) = @_;
Subroutine _set_process_stat: not called CC=1 SCAR=6.9
458 0 $0 = $self->{'program_name'}.' ('.$stat.')'
459 };
460  
461 1 1;
462  
463  
464 __END__
465 =pod
466  
467 =head1 NAME
468  
469 Mail::MtPolicyd - the Mailteam policy daemon for postfix
470  
471 =head1 VERSION
472  
473 version 1.12
474  
475 =head1 DESCRIPTION
476  
477 The mailteams postfix policy daemon
478  
479 =head2 SYNOPSIS
480  
481 use Mail::MtPolicyd;
482 Mail::MtPolicyd->run;
483  
484 =head1 AUTHOR
485  
486 Markus Benning <ich@markusbenning.de>
487  
488 =head1 COPYRIGHT AND LICENSE
489  
490 This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
491  
492 This is free software, licensed under:
493  
494 The GNU General Public License, Version 2, June 1991
495  
496 =cut
497  
« MtPolicyd/Plugin/SqlList.pm ↑ Summary MtPolicyd/Plugin/SPF.pm »