Re: [exim] Exim 4.71 on netBSD pthreads

Top Page
Delete this message
Reply to this message
Author: Niels Dettenbach
Date:  
To: Jasper Wallace, Phil Pennock
CC: exim-users
Subject: Re: [exim] Exim 4.71 on netBSD pthreads
On Wednesday 24 March 2010 23:13:06 Jasper Wallace wrote:
> Niels Dettenbach wrote:
> > SMTP on [w.x.y.z]:26 [127.0.0.1]:26 [127.0.0.1]:10026
> > _res is not supported for multi-threaded programs.
> >
> > this seems not new and so i found and followed this thread:
> > http://mail-index.netbsd.org/pkgsrc-users/2009/11/18/msg011153.html
> http://www.exim.org/lurker/message/20060731.232742.72a0ed78.en.html


Yes, thanks.
Modified to exim 4.71 this seems to work as required (even with exim-sa)

May be someone can bring this into exim upstream here?

--- snip ---
--- /var/backups/soft/exim-sa-471/tmp/exim-4.71/src/dns.c       2009-11-16 
20:50:36.000000000 +0100
+++ exim-4.71/src/dns.c 2010-03-25 14:25:25.000000000 +0100
@@ -168,18 +168,26 @@ Returns:            nothing
 void
 dns_init(BOOL qualify_single, BOOL search_parents)
 {
-if ((_res.options & RES_INIT) == 0)
+ struct __res_state *rs;
+
+ rs = __res_get_state();
+
+if ((rs->options & RES_INIT) == 0)
+
   {
-  DEBUG(D_resolver) _res.options |= RES_DEBUG;     /* For Cygwin */
+DEBUG(D_resolver) rs->options |= RES_DEBUG; /* For Cygwin */
+ __res_put_state(rs);
   res_init();
-  DEBUG(D_resolver) _res.options |= RES_DEBUG;
+DEBUG(D_resolver) rs->options |= RES_DEBUG;
+ __res_put_state(rs);
   }


-_res.options &= ~(RES_DNSRCH | RES_DEFNAMES);
-_res.options |= (qualify_single? RES_DEFNAMES : 0) |
+rs->options &= ~(RES_DNSRCH | RES_DEFNAMES);
+rs->options |= (qualify_single? RES_DEFNAMES : 0) |
                 (search_parents? RES_DNSRCH : 0);
-if (dns_retrans > 0) _res.retrans = dns_retrans;
-if (dns_retry > 0) _res.retry = dns_retry;
+if (dns_retrans > 0) rs->retrans = dns_retrans;
+if (dns_retry > 0) rs->retry = dns_retry;
+__res_put_state(rs);
 }



@@ -424,9 +432,11 @@ Returns:     the return code
 static int
 dns_return(uschar *name, int type, int rc)
 {
+struct __res_state *rs;
 tree_node *node = store_get_perm(sizeof(tree_node) + 290);
+rs = __res_get_state();
 sprintf(CS node->name, "%.255s-%s-%lx", name, dns_text_type(type),
-  _res.options);
+rs->options);
 node->data.val = rc;
 (void)tree_insertnode(&tree_dns_fails, node);
 return rc;
@@ -466,6 +476,9 @@ dns_basic_lookup(dns_answer *dnsa, uscha
 int rc = -1;
 uschar *save;
 #endif
+struct __res_state *rs;
+rs = __res_get_state();
+


tree_node *previous;
uschar node_name[290];
@@ -476,7 +489,7 @@ have many addresses in the same domain.
caching for successful lookups. */

sprintf(CS node_name, "%.255s-%s-%lx", name, dns_text_type(type),
- _res.options);
+rs->options);
previous = tree_search(tree_dns_fails, node_name);
if (previous != NULL)
{

--- snap ---

best regards and
cheers,


Niels.
--

---

Niels Dettenbach
---
Syndicat IT&Internet
http://www.syndicat.com
T.-Muentzer.-Str. 2, 37308 Heilbad Heiligenstadt - DE
---
Kryptoinfo:
PGP public key ID 651CA20D
Fingerprint: 55E0 4DCD B04C 4A49 1586 88AE 54DC 4465 651C A20D
https://syndicat.com/pub_key.asc
---