mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 11:42:27 +00:00
Unify all the res_ninit patches
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2778 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
21
dns.c
21
dns.c
@@ -151,24 +151,25 @@ static int dns_parse_answer(void *context,
|
|||||||
return 0;
|
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,
|
int ast_search_dns(void *context,
|
||||||
const char *dname, int class, int type,
|
const char *dname, int class, int type,
|
||||||
int (*callback)(void *context, u_char *answer, int len, u_char *fullanswer))
|
int (*callback)(void *context, u_char *answer, int len, u_char *fullanswer))
|
||||||
{
|
{
|
||||||
#ifdef linux
|
#ifdef HAS_RES_NINIT
|
||||||
struct __res_state dnsstate;
|
struct __res_state dnsstate;
|
||||||
#endif
|
#endif
|
||||||
char answer[MAX_SIZE];
|
char answer[MAX_SIZE];
|
||||||
int res, ret = -1;
|
int res, ret = -1;
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef HAS_RES_NINIT
|
||||||
#ifndef __UCLIBC__
|
|
||||||
res_ninit(&dnsstate);
|
res_ninit(&dnsstate);
|
||||||
res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
|
res = res_nsearch(&dnsstate, dname, class, type, answer, sizeof(answer));
|
||||||
#else
|
|
||||||
res_init();
|
|
||||||
res = res_search(dname, class, type, answer, sizeof(answer));
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
res_init();
|
res_init();
|
||||||
res = res_search(dname, class, type, answer, sizeof(answer));
|
res = res_search(dname, class, type, answer, sizeof(answer));
|
||||||
@@ -185,12 +186,8 @@ int ast_search_dns(void *context,
|
|||||||
else
|
else
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
#if defined(linux)
|
#ifdef HAS_RES_NINIT
|
||||||
#ifndef __UCLIBC__
|
|
||||||
res_nclose(&dnsstate);
|
res_nclose(&dnsstate);
|
||||||
#else
|
|
||||||
res_close();
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
res_close();
|
res_close();
|
||||||
|
Reference in New Issue
Block a user