return err;
}
+#if 0
static void free_hostent(struct hostent *h){
int i;
free(h);
}
}
+#endif
struct asyn_result {
char *host;
};
/* ares callback handler for ares_getnameinfo() */
-void callback_handler(void *arg, int status, char *node, char *service)
+#if ARES_VERSION >= 0x010500
+void callback_ares_getnameinfo(void *arg, int status, int timeouts, char *node, char *service)
+#else
+void callback_ares_getnameinfo(void *arg, int status, char *node, char *service)
+#endif
{
struct asyn_result *arp = (struct asyn_result *) arg;
struct timeval tv, *tvp;
struct timeval start_time,check_time;
int flags = 0;
+ int err = NETDB_INTERNAL;
/* start timer */
gettimeofday(&start_time,0);
/* query DNS server asynchronously */
if (name) flags |= ARES_NI_LOOKUPHOST | ( numeric? ARES_NI_NUMERICHOST : 0);
if (service) flags |= ARES_NI_LOOKUPSERVICE | ( numeric? ARES_NI_NUMERICSERV : 0);
- ares_getnameinfo(channel, addr, len, flags, (ares_nameinfo_callback)callback_handler, (void *) &ar);
+ ares_getnameinfo(channel, addr, len, flags, (ares_nameinfo_callback)callback_ares_getnameinfo, (void *) &ar);
/* wait for result */
while (1) {
}
-
- ares_destroy(channel);
-
if (ar.err == NETDB_SUCCESS) {
if (name) *name = ar.host;
if (service) *service = ar.service;
}
- return (ar.err);
+ err = ar.err;
+
+ ares_destroy(channel);
+ return err;
}
static int add_root(edg_wll_Context ctx, char *root)
/* ares callback handler for ares_gethostbyname() */
#if ARES_VERSION >= 0x010500
-static void callback_handler(void *arg, int status, int timeouts, struct hostent *h)
+static void callback_ares_gethostbyname(void *arg, int status, int timeouts, struct hostent *h)
#else
-static void callback_handler(void *arg, int status, struct hostent *h)
+static void callback_ares_gethostbyname(void *arg, int status, struct hostent *h)
#endif
{
struct asyn_result *arp = (struct asyn_result *) arg;
fd_set readers, writers;
struct timeval tv, *tvp;
struct timeval start_time,check_time;
+ int err = NETDB_INTERNAL;
/* start timer */
gettimeofday(&start_time,0);
ar.ent = (struct hostent *) calloc (sizeof(*ar.ent),1);
/* query DNS server asynchronously */
- ares_gethostbyname(channel, name, AF_INET6, callback_handler,
+ ares_gethostbyname(channel, name, AF_INET6, callback_ares_gethostbyname,
(void *) &ar);
/* wait for result */
}
}
- ares_destroy(channel);
-
if (ar.err == NETDB_SUCCESS) {
struct sockaddr_in *p4 = (struct sockaddr_in *)addrOut;
struct sockaddr_in6 *p6 = (struct sockaddr_in6 *)addrOut;
break;
}
}
+ free_hostent(ar.ent); ar.ent = NULL;
+ err = ar.err;
+
+ ares_destroy(channel);
- free_hostent(ar.ent);
- return(ar.err);
+ return err;
}
static int