[Mimedefang] Suggestion: "slave exiting" callback

Brian Landers brian at bluecoat93.org
Mon Jan 27 16:06:01 EST 2003


This may already be possible, but if not...

It would be useful be able to define a function that would be
called when a slave exits, for example:  open a DBI connection
when the slave starts up (at the head of mimedefang-filter.pl,
then when the slave is killed off by the multiplexor after it
processes its number of requests, the slave_exiting function
gets called to close the connection.

I guess this could be implemented using an END{} block inside
the filter, but that seems kind of like it's stepping on the
actual mimedefang.pl app's toes by adding functionality that
runs outside the filter's "sphere of influence."

Maybe something like this? (in mimedefang.pl)

$SIG{TERM} = sub {
  if( defined( &slave_exiting ) ) {
    &slave_exiting();
    exit(0);
  }
};

Although you'd probably want to do it with the %SIG handler
setting a flag to interrupt the serverloop instead, since
signal handlers aren't necessarily safe until 5.8.0.

*b


-- 
Brian Landers                     |  packetslave at sapient.com
Network System Exorcist           |  vox://404/439.4117
Sapient Information Technology    |  aim://Bluecoat93
CCNA, SCSA, EIEIO                 |  yim://brian_landers

"Well, I'm not an expert but wouldn't we have a better chance of 
getting re-elected if we could say there were four million fewer 
poor people? Hang on, wait, I am an expert." -- Josh Lyman 




More information about the MIMEDefang mailing list