[Mimedefang] greylisting DB_File locking
Edoardo Giannoni
egiannoni at omniway.sm
Thu Apr 29 10:00:42 EDT 2004
Scrive -ray <ray at ops.selu.edu>:
>
> Andrea,
>
> Thanks for the info. I switched to DB_File::Lock and things seem to be
> running fine. How many records are in your greylistdb? I accumulated a
> little over 38,000 in the past 12 hours, and i'm wondering if i'm
> stretching the limitations of the DB_File format.
actually I have about 400,000 record. every night I clean the DB removing the records that are
over the grey period and that are seen only one time.
This is my script. The second condition never apply to me, I think it's wrong.
PS: I'm not a perl programmer. If you have some suggestion please let me know
Andrea
#!/usr/local/perl/bin/perl
use DB_File::Lock;
use Fcntl qw(:flock O_RDWR O_CREAT);
$tot_count = 0;
$del_grey_count = 0;
$del_old_count = 0;
$val_count = 0;
my $DBFilename = "/usr/local/etc/mail/spamassassin/greylistdb";
my %GDB;
my $db;
my $key;
my $value;
my $now = time();
$gdb_grey = 36*60*60;
$gdb_white = 36*24*60*60;
$db = tie %GDB, 'DB_File::Lock', $DBFilename, O_CREAT|O_RDWR, undef,
$DB_HASH, 'write';
if ($db) {
while (($key, $value) = each %GDB) {
my ($created,$modified,$reset,$accepted,$count,$ip,$sender,$recipient,$x) = split
(/;/,$value,9);
$tot_count++;
if ($accepted == 0 && $count == 0 && $now >= $created+$gdb_grey) {
$del_grey_count++;
$db->del($key);
next;
}
if ($now >= $modified+$gdb_white) {
$del_old_count++;
$db->del($key);
next;
}
}
}
undef $db;
untie %GDB;
$val_count = $tot_count - $del_grey_count - $del_old_count;
print "\n\t\tResoconto\n\n";
print "\tRecord \"grey\" eliminati:\t$del_grey_count\n";
print "\tRecord \"old\" eliminati:\t\t$del_old_count\n";
print "\tRecord validi:\t\t\t$val_count\n";
print "\tTotale record elaborati:\t$tot_count\n\n";
>
> ray
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Ray DeJean http://www.r-a-y.org
> Systems Engineer Southeastern Louisiana University
> IBM Certified Specialist AIX Administration, AIX Support
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>
> On Wed, 28 Apr 2004, Andrea Gabellini wrote:
>
> > I saw the same error few month ago. I changed the locking mechanism using:
> >
> > use DB_File::Lock;
> > use Fcntl qw(:flock O_RDWR O_CREAT);
> >
> > and opening the DB with the command:
> >
> > $db = tie %GDB, 'DB_File::Lock', $DBFilename, O_CREAT|O_RDWR, undef,
> > $DB_HASH, 'write';
> >
> > Andrea
>
> _______________________________________________
> Visit http://www.mimedefang.org and http://www.canit.ca
> MIMEDefang mailing list
> MIMEDefang at lists.roaringpenguin.com
> http://lists.roaringpenguin.com/mailman/listinfo/mimedefang
>
>
-----------------------------------------------------------------------------
Attiva la tua mail gratuita con Omnimail all'indirizzo http://www.omnimail.sm
Il servizio è offerto da Intelcom San Marino S.p.a. http://www.intelcom.sm
More information about the MIMEDefang
mailing list