SOCKETMAP performace (was Re: [Mimedefang] sendmail 8.13.0)
Matthew.van.Eerde at hbinc.com
Matthew.van.Eerde at hbinc.com
Thu Jul 29 13:50:12 EDT 2004
> From: Mark [mailto:admin at asarian-host.net]
> 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;
> > }
> >
>
> 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
Well... you cache per-child nominally. It is not out of the realm of
possibility to have a thread-aware version of the DBI library that
handles the connect() and "unconnect()" requests in such a way as to be
real-time-safe but still cache. Win32 ODBC has a notion of "Connection
Pooling" which provides a server-level cache, so that the code
developers can call DBI->connect() and "unconnect()" all they want. The
server-level cache does not immediately honor the "unconnect" - it will
keep the open connection around for a few seconds or a minute to see if
any connect() commands come along. If they do then the connect() just
gets the old handle back (still open.) This is probably already being
done for some Linux-based DBM packages.
The more sophisticated the database, the more likely this is to be
useful.
Matthew.van.Eerde at hbinc.com 805.964.4554 x902
Hispanic Business Inc./HireDiversity.com Software Engineer
perl -e"map{y/a-z/l-za-k/;print}shift" "Jjhi pcdiwtg Ptga wprztg,"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2905 bytes
Desc: not available
URL: <https://lists.mimedefang.org/pipermail/mimedefang_lists.mimedefang.org/attachments/20040729/1fcadefc/attachment-0001.bin>
More information about the MIMEDefang
mailing list