| 1 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2 | package Mail::Audit::KillDups; | ||||||||||||||||||||||||||||||||||
| 3 | { | ||||||||||||||||||||||||||||||||||
| 4 | 1 | $Mail::Audit::KillDups::VERSION = '2.228'; | |||||||||||||||||||||||||||||||||
| 5 | } | ||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Mail::Audit plugin for duplicate suppression | ||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Mail::Audit; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 1 | our $dupfile = ".msgid-cache"; | |||||||||||||||||||||||||||||||||
| 9 | 1 | our $cache_bytes = 10000; | |||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | package Mail::Audit; | ||||||||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||||||||
| 13 | 1 | $Mail::Audit::VERSION = '2.228'; | |||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Fcntl; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub killdups { | ||||||||||||||||||||||||||||||||
|
Subroutine
killdups: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 19 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $mid = shift || $self->get("Message-Id"); | ||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->get('Message-Id')
MC/DC0%0/2
shift() || $self->get('Message-Id')
shift()
$self->get('Message-Id')
Truth table0%0/3
A || B
A= shift()B= $self->get('Message-Id')
| |||||||||||||||||||||||||||||||||||
| 21 | 0 | my $end_of_ring = 0; | |||||||||||||||||||||||||||||||||
| 22 | 0 | my $current_pos; | |||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | unless (length $mid) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 25 | 0 | $self->_log(1, "message has no message-id; skipping duplicate check"); | |||||||||||||||||||||||||||||||||
| 26 | 0 | return; | |||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | unless (sysopen MSGID, $Mail::Audit::KillDups::dupfile, O_RDWR | O_CREAT) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 30 | 0 | $self->_log(1, "Error opening $Mail::Audit::KillDups::dupfile: $!"); | |||||||||||||||||||||||||||||||||
| 31 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | 0 | chomp $mid; | |||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | while (<MSGID>) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 36 | 0 | chomp; | |||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ($_ eq $mid) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 38 | 0 | $self->_log(1, "Duplicate, ignoring"); | |||||||||||||||||||||||||||||||||
| 39 | 0 | $self->ignore; | |||||||||||||||||||||||||||||||||
| 40 | 0 | return -1; | |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 0 | $current_pos = tell MSGID; | |||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($current_pos > $Mail::Audit::KillDups::cache_bytes && $end_of_ring == 0) | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$current_pos > $Mail::Audit::KillDups::cache_bytes and $end_of_ring == 0
MC/DC0%0/2
$current_pos > $Mail::Audit::KillDups::cache_bytes and $end_of_ring == 0
$current_pos > $Mail::Audit::KillDups::cache_bytes
$end_of_ring == 0
Truth table0%0/3
A and B
A= $current_pos > $Mail::Audit::KillDups::cache_bytesB= $end_of_ring == 0
| |||||||||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||||||||
| 46 | # we've gotten too big, write this mid back at the top of the file | ||||||||||||||||||||||||||||||||||
| 47 | 0 | last; | |||||||||||||||||||||||||||||||||
| 48 | ▶ | } elsif ($_ eq "" && $end_of_ring == 0 && $current_pos > 0) { | |||||||||||||||||||||||||||||||||
|
Condition0%0/6
$_ eq "" and $end_of_ring == 0 and $current_pos > 0
$_ eq "" and $end_of_ring == 0
MC/DC0%0/3
$_ eq "" and $end_of_ring == 0 and $current_pos > 0
$_ eq ""
$end_of_ring == 0
$current_pos > 0
Truth table0%0/4
A and B and C
A= $_ eq ""B= $end_of_ring == 0C= $current_pos > 0
| |||||||||||||||||||||||||||||||||||
| 49 | # Found the end of the ring buffer, so save position. | ||||||||||||||||||||||||||||||||||
| 50 | 0 | $end_of_ring = $current_pos - 1; | |||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | # Didn't find mid, so write it to the end of the ring buffer | ||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | unless (seek MSGID, $end_of_ring, 0) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 56 | 0 | $self->_log(1, "seek to position $end_of_ring failed: $!"); | |||||||||||||||||||||||||||||||||
| 57 | 0 | close MSGID; | |||||||||||||||||||||||||||||||||
| 58 | 0 | return 1; | |||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | 0 | print MSGID "$mid\n\n"; | |||||||||||||||||||||||||||||||||
| 62 | 0 | close MSGID; | |||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | 0 | return; | |||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||||||||