Re: [libopendkim] dkim_init() and dkim_close() thread problems

From: Dino Ciuffetti <dino_at_tuxweb.it>
Date: Sat, 1 May 2010 02:47:31 +0200 (CEST)

> You need to call dkim_init() once before your program becomes
> multi-threaded, and dkim_close() once when the application is shutting
> down. Then, in each thread, you call dkim_sign() or dkim_verify() to set
> up one of those operations, and dkim_free() to terminate them.

> Let me know if that works.
>

Wow... now that's woking perfectly!
I call dkim_init on module load and dkim_close on module unload. That's
before the program become threaded. To do that now I use contructor and
destructor:

DKIM_LIB *dkim_libh = NULL;

void __attribute__ ((constructor)) module_init() { // module constructor
        // setup dkim library
        dkim_libh = dkim_init(NULL, NULL);
}

void __attribute__ ((destructor)) module_fini() { // module destructor
        // cleanup things
        dkim_close(dkim_libh);
}

Now it is much more clean! Thank you!!!
Dino.

-- 
Dino Ciuffetti
Linux System Administrator and Architect
TuxWeb S.r.l. - http://www.tuxweb.it/
Received on Sat May 01 2010 - 00:47:44 PST

This archive was generated by hypermail 2.3.0 : Mon Oct 29 2012 - 23:19:47 PST