APM: Using threads in perl

Evan Harris eharris at puremagic.com
Mon May 12 14:06:45 CDT 2003


I'm using a threaded copy of perl 5.8.0 to write a sendmail milter using
Sendmail::Milter from cpan.  The milter interface creates a long-running
perl that spawns seperate threads to handle callbacks from the milter
interface.

According to the docs, those threads are periodically recycled and
respawned.  However, I've noticed that when that happens, the threads don't
seem to release/close a global dbi handle I'm using from within the milter
callbacks, and is over time creating dozens of connections to the database
that never go away unless I restart the milter, and it eventually exhausts
the db connection pool.

Does anyone know of something I can setup that is specific to perl threads
where I can register a function to be called immediately before a thread is
destroyed?  I would have that function explicitly close the db connection,
and hopefully that would solve my problem.

Thanks.

Evan




More information about the Austin mailing list