[git commit] inet: Fix threaded res_init

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Fri Dec 20 14:53:01 UTC 2013


commit: http://git.uclibc.org/uClibc/commit/?id=1c8d287e58a3199213b5533136a7a04c8eb231bb
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

In a multi-threaded application where res_init() was called either
directly or implicitly, getaddrinfo() and others failed to add the
DNS search domain to hostnames.

This problem made it not possible to look up a hostname without its
domain appended.

The problem is caused by res_sync_func() overwriting the configuration
read by __open_nameservers() immediately after it is read.

The suggested solutin is to disable res_sync_func() while reading name
server configuration in res_init().

Signed-off-by: Kenneth Soerensen <kenneth.sorensen at spectralink.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/inet/resolv.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index f334d05..154734d 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -3575,6 +3575,7 @@ res_init(void)
 	if (!_res.id)
 		_res.id = res_randomid();
 
+	__res_sync = NULL;
 	__res_vinit(&_res, 1);
 	__res_sync = res_sync_func;
 


More information about the uClibc-cvs mailing list