SOCKETMAP performace (was Re: [Mimedefang] sendmail 8.13.0)
Mark
admin at asarian-host.net
Thu Jul 29 12:15:54 EDT 2004
David F. Skoll wrote:
>> Question, though, how will you keep a persistent, say, MySQL
>> connection in Perl, for the backend socketmap functionality?
>
> Keep a global variable called $DBH. Write code like this:
>
> # Put this at the top of your filter
> undef $DBH;
>
> sub get_dbh {
> # Re-use if we already have one
> return $DBH if defined($DBH);
>
> # Get and cache a connection
> $DBH = DBI->connect(....);
> return $DBH;
> }
>
> Then in your filter routines, whenever you need the handle:
>
> sub blah {
> my $dbh = get_dbh();
> # Now use dbh here...
> }
So, basically, you cache per-child, right? That is what I figured.
Everything I read about it says a child should never try and share the $dbh
object with the parent (as parent and kids might inadvertently be using the
same channel at the same time). Too bad, though. The real time-safer would
have been in not having to initialize a connection for each new child.
Thanks anyway,
- Mark
More information about the MIMEDefang
mailing list