[Mimedefang] mysql problem

B. Tolka btolka at hsc.wvu.edu
Tue Aug 5 07:37:01 EDT 2003


Hello Everyone,

I have a sub routine called should_check_for_spam ($). This either returns a 1 or a 0. 1 means filter will check for spam 0 means its disabled.  In my test environment everything works fine. However when I implement it in higher volume production box, it seems to retain the variables from the database in memory. I have tried to do a $sth->finish; and $dbh->disconnect.   Below is a copy of the subroutine. Any help or ideas is very appreciated.


sub should_check_for_spam ($)
{
                                                                                                                                                                           
    my($recip) = @_;
    $recip = lc($recip);
    $recip =~ tr/<>//d;
                                                                                                                                                                           
    $Sender = lc($Sender);
    $Sender =~ tr/<>//d;
                                                                                                                                                                           
if ($use_database eq 1)
{
    $sth = $dbh->prepare("SELECT checkspam FROM userpref WHERE username = '$recip' && preference= 'rewrite_subject'");
    $sth->execute;
    $sth->bind_columns(\$checkspam);
    $sth->fetchrow_arrayref;
    if ($checkspam eq 0)
    {
    md_graphdefang_log('Recipient is equal to', $recip);
    md_graphdefang_log('Checkspam is equal to', $checkspam);
    $sth->finish;
    $dbh->disconnect;
    return 0;
    }
                                                                                                                                                                           
    $sth1 = $dbh->prepare("SELECT value FROM userpref WHERE username = '$recip' && preference= 'whitelist_from'");
    $sth1->execute;
    my (@whitelist);
    my $i = 0;
    my $count;
    my $j = $sth1->rows;
    my @rows;
        while (@row = $sth1->fetchrow())
        {
         $whitelist[$i] = @row[0];
                if ($whitelist[$i] eq $Sender)
                {
                        $sth->finish;
                        $sth1->finish;
                        $dbh->disconnect;
                        return 0;
                }
        $i++;
        }
                                                                                                                                                                           
### Remove if statement
    if ($checkspam eq 1)
    {
    $sth->finish;
    $sth1->finish;
    $dbh->disconnect;
    return 1;

    $sth1->finish;
    $sth->finish;
    $dbh->disconnect;
    $count = $i;
### change to 1
    return 0;
}
}




Bryan Tolka
Network Engineer
---------------------------------------
Robert C. Byrd Health Sciences Center
Morgantown, WV
304-293-4683
btolka at hsc.wvu.edu




More information about the MIMEDefang mailing list