[Mimedefang] Mysql connections

David F. Skoll dfs at roaringpenguin.com
Thu Dec 14 07:13:56 EST 2006


Paul Murphy wrote:

> You can do anything you want, as long as you open the connection in
> filter_initialize(), and close it in filter_cleanup()

That's one strategy.  I prefer to "lazily" open and close the connection.
That is, have a wrapper function called "get_mysql_handle" that checks if
there is an existing handle, and returns it if so.  Otherwise, it opens
a connection and caches the handle in a global variable.

This function can also do a "ping" test and close and reopen the handle
if the ping test fails.  That way, if someone restarts the MySQL server,
the MIMEDefang slaves can react properly by closing and reopening the
connection automatically.

In filter_cleanup, you can (should) close any cached MySQL connection.

Regards,

David.



More information about the MIMEDefang mailing list