From 3b64c4830f47b36418704dda3e608f05c7a09e6f Mon Sep 17 00:00:00 2001
From: Mark Spencer <markster@digium.com>
Date: Mon, 26 Apr 2004 13:32:57 +0000
Subject: [PATCH] Unify all the res_ninit patches

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2778 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 dns.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/dns.c b/dns.c
index c45314950b..33974aa14f 100755
--- a/dns.c
+++ b/dns.c
@@ -151,24 +151,25 @@ static int dns_parse_answer(void *context,
 	return 0;
 }
 
+#if defined(res_ninit)
+#define HAS_RES_NINIT
+#else
+#warning "Warning, res_ninit is missing...  Could have reentrancy issues"
+#endif
+
 int ast_search_dns(void *context,
 				   const char *dname, int class, int type,
 				   int (*callback)(void *context, u_char *answer, int len, u_char *fullanswer))
 {
-#ifdef linux
+#ifdef HAS_RES_NINIT
 	struct __res_state dnsstate;
 #endif
 	char answer[MAX_SIZE];
 	int res, ret = -1;
 
-#ifdef linux
-	#ifndef __UCLIBC__
-		res_ninit(&dnsstate);
-		res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
-	#else
-	        res_init();
-	        res = res_search(dname, class, type, answer, sizeof(answer));
-	#endif
+#ifdef HAS_RES_NINIT
+	res_ninit(&dnsstate);
+	res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
 #else
 	res_init();
 	res = res_search(dname, class, type, answer, sizeof(answer));
@@ -185,12 +186,8 @@ int ast_search_dns(void *context,
 		else
 			ret = 1;
 	}
-#if defined(linux)
-	#ifndef __UCLIBC__
-		res_nclose(&dnsstate);
-	#else
-		res_close();
-	#endif
+#ifdef HAS_RES_NINIT
+	res_nclose(&dnsstate);
 #else
 #ifndef __APPLE__
 	res_close();
-- 
GitLab