From 4876011820930e3f63c5129c432927a4b4600fab Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 30 Jan 2016 01:28:34 +0100 Subject: [PATCH] Clean up GETADDRINFO usage in make-network-process * process.c (Fmake_network_process): Clean up the GETADDRINFO handling. --- src/process.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/process.c b/src/process.c index 4f0c4e9bcdc..88441c91de6 100644 --- a/src/process.c +++ b/src/process.c @@ -3471,12 +3471,11 @@ usage: (make-network-process &rest ARGS) */) Lisp_Object proc; Lisp_Object contact; struct Lisp_Process *p; -#ifdef HAVE_GETADDRINFO - struct addrinfo ai, *res, *lres; +#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETADDRINFO_A) struct addrinfo *hints; const char *portstring; char portbuf[128]; -#endif /* HAVE_GETADDRINFO */ +#endif #ifdef HAVE_LOCAL_SOCKETS struct sockaddr_un address_un; #endif @@ -3527,12 +3526,6 @@ usage: (make-network-process &rest ARGS) */) CHECK_STRING (name); - /* Initialize addrinfo structure in case we don't use getaddrinfo. */ - ai.ai_socktype = socktype; - ai.ai_protocol = 0; - ai.ai_next = NULL; - res = &ai; - /* :local ADDRESS or :remote ADDRESS */ tem = Fplist_get (contact, QCserver); if (!NILP (tem)) @@ -3652,6 +3645,7 @@ usage: (make-network-process &rest ARGS) */) { struct gaicb **reqs = xmalloc (sizeof (struct gaicb*)); + printf("Async DNS for '%s'\n", SSDATA (host)); dns_request = xmalloc (sizeof (struct gaicb)); reqs[0] = dns_request; dns_request->ar_name = strdup (SSDATA (host)); @@ -3673,6 +3667,8 @@ usage: (make-network-process &rest ARGS) */) if (!NILP (host)) { + struct addrinfo *res, *lres; + immediate_quit = 1; QUIT; @@ -3699,6 +3695,8 @@ usage: (make-network-process &rest ARGS) */) } ip_addresses = Fnreverse (ip_addresses); + + freeaddrinfo (res); xfree (hints); goto open_socket; -- 2.39.5