EndCustomFunctions when the batch finish

Alvaro Marin alvaro at hostalia.com
Thu Mar 3 13:50:35 GMT 2011


Hi,

I've a CustomFunction to insert messages into a database. The plugin is 
just:

sub InitDBPlug {
	$dbh = DBI->connect("DBI:mysql:database=...
}

sub DBPlug {
	$sth = $dbh->prepare("INSERT INTO...
	$sth->execute(...
}

sub EndDBPlug {
	$dbh->commit;
	$dbh->disconnect;
}


The problem is that as I see in bin/Mailscanner, the End functions of 
the "plugins" are called (with 
MailScanner::Config::EndCustomFunctions()) only when the child has to be 
restarted by "restartevery" variable:

(time>=$StartTime && time<$RestartTime && !$BayesRebuild)

The default value for "Restart Every" is 7200, so the MySQL connection 
is kept open until that time without any use.

So, Can I add safely :

   # Close down all the user's custom functions
   MailScanner::Config::EndCustomFunctions();

inside that "while" to be executed every time that a Batch finish to 
close the DB connection?

Thank you!

Regards,

-- 
Alvaro Marín Illera
Hostalia Internet
www.hostalia.com



More information about the MailScanner mailing list