Jeremy,

> > In my current code I moved the custom hook initialization call
> > (the Amavis::Custom->new) slightly earlier, so that loading
> > a policy bank from there can influence a few more things, just
> > in case someone would need it (like OS fingerprinting settings,
> > local_domains).
>
> Nice.  Not sure I need it, but good to know.
>
> Speaking of the init call, I couldn't get it to run only once.
> It seems to run on every email.

Indeed. A fresh custom object is created with every mail.
This makes it less of a chance that come custom hook would
forget to reset some state and leak information from
one message to the next.

> Although I don't use it this way, I can see it being 
> useful for opening a persistent database handle, inherited by every child.
> What I do is load some data from a config file and I'd rather not have to
> do that for every email.

If you need persistent data, there are two options:

To have some variable which may be declared at amavisd startup time
in a parent process and forked into children, just declare it
with my() or own() or use 'vars' in amavisd.conf, and you have it.

If each child process should have its own (e.g. a connection to
a database), declare some variable globally (in amavisd.conf)
and leave it undefined, then at the first call for a custom
hook's new() it can be initialized, e.g. a socket created
or an SQL connection made. A DESTROY method could be declared
for a clean shutdown.

  Mark 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to