Re: Fwd: [milter-greylist] HEADS-UP: libspf2 causes milter-greylist memory leak?

Hajimu UMEMOTO <[email protected]> Thu, 30 Oct 2008 02:39:05 +0900
Newsgroups gmane.mail.spam.spf.devel
Organization Internet Mutual Aid Society, YOKOHAMA
Message-ID <yge63nbqp1i.wl%[email protected]>
Hi,

>>>>> On Mon, 27 Oct 2008 14:52:15 +0100
>>>>> Hannah Schroeter <[email protected]> said:

>@@ -615,7 +619,7 @@ SPF_dns_resolv_new(SPF_dns_server_t *lay
> #if HAVE_DECL_RES_NINIT
> 	pthread_once(&res_state_control, SPF_dns_resolv_init_key);
> #else
>-	if ( res_init() != 0 ) {
>+	if ((_res.options & RES_INIT) == 0 && res_init() != 0) {
> 		perror("res_init");
> 		return NULL;
> 	}

hannah> Why is that needed, and how portable is that in fact, compared to
hannah> calling res_init unconditionally in that place?

Because, the libspf2 is not only consumer of the resolver.  The
res_init() might be called already before calling it from libspf2.  It
is enough to call res_init() once.
Basically, res_init() is used in this manner on BSDs.  The impact of
calling res_init() again and again is unclear.
I'm not sure about portability, but the _res and RES_INIT is described
in resolver(8) on at least BSDs and CentOS.

Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
[email protected]  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/