From owner-freebsd-ports-bugs@FreeBSD.ORG Fri Jun 25 16:11:32 2004 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D65416A4CF for ; Fri, 25 Jun 2004 16:11:32 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 71F4F43D3F for ; Fri, 25 Jun 2004 16:11:32 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i5PGAUnE084962 for ; Fri, 25 Jun 2004 16:10:30 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i5PGAUIM084961; Fri, 25 Jun 2004 16:10:30 GMT (envelope-from gnats) Date: Fri, 25 Jun 2004 16:10:30 GMT Message-Id: <200406251610.i5PGAUIM084961@freefall.freebsd.org> To: freebsd-ports-bugs@FreeBSD.org From: Hajimu UMEMOTO Subject: ports/68281: add SPF support for milter-greylist X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Hajimu UMEMOTO List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jun 2004 16:11:32 -0000 The following reply was made to PR ports/68281; it has been noted by GNATS. From: Hajimu UMEMOTO To: freebsd-gnats-submit@freebsd.org Cc: Cyril Guibourg Subject: ports/68281: add SPF support for milter-greylist Date: Sat, 26 Jun 2004 01:05:44 +0900 Hi, >>>>> On Fri, 25 Jun 2004 14:21:53 +0200 >>>>> Cyril Guibourg said: plonk-o-matic> I've been told that libspf_alt needs a reentrant version of libbind in plonk-o-matic> order to work fine. Are the available res_* libc routines thread safe ? Oops, I didn't notice this issue. The recent 5-CURRENT's resolver is thread_safe. But, 4-STABLE's one is not. How about adding attached patch for now? It does giant locking around SPF call. Index: spf.c diff -u -p spf.c.orig spf.c --- spf.c.orig Wed May 5 05:50:33 2004 +++ spf.c Sat Jun 26 00:27:41 2004 @@ -52,6 +52,22 @@ __RCSID("$Id: spf.c,v 1.13 2004/05/04 20 #include "spf.h" #include "except.h" +#if defined(__FreeBSD__) +#include +#if __FreeBSD_version < 502105 +#define RESOLVER_NEED_LOCK 1 +#endif +#endif + +#if (defined(HAVE_SPF) || defined(HAVE_SPF_ALT)) && defined(RESOLVER_NEED_LOCK) +static pthread_mutex_t spf_mutex_lock = PTHREAD_MUTEX_INITIALIZER; +#define RESOLVER_LOCK() pthread_mutex_lock(&spf_mutex_lock) +#define RESOLVER_UNLOCK() pthread_mutex_unlock(&spf_mutex_lock) +#else +#define RESOLVER_LOCK() +#define RESOLVER_UNLOCK() +#endif + #ifdef HAVE_SPF #include @@ -71,6 +87,7 @@ spf_check(in, helo, from) inet_ntop(AF_INET, in, addr, IPADDRLEN); + RESOLVER_LOCK(); if ((p = SPF_init("milter-greylist", addr, NULL, NULL, NULL, FALSE, FALSE)) == NULL) { syslog(LOG_ERR, "SPF_Init failed"); @@ -89,6 +106,7 @@ spf_check(in, helo, from) SPF_close(p); out1: + RESOLVER_UNLOCK(); if (conf.c_debug) { gettimeofday(&tv2, NULL); timersub(&tv2, &tv1, &tv3); @@ -126,6 +144,7 @@ spf_alt_check(in, helo, fromp) if (conf.c_debug) gettimeofday(&tv1, NULL); + RESOLVER_LOCK(); if ((spfconf = SPF_create_config()) == NULL) { syslog(LOG_ERR, "SPF_create_config failed"); goto out1; @@ -188,6 +207,7 @@ out3: out2: SPF_destroy_config(spfconf); out1: + RESOLVER_UNLOCK(); if (conf.c_debug) { gettimeofday(&tv2, NULL); timersub(&tv2, &tv1, &tv3); Sincerely, -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan ume@mahoroba.org ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/