Commit df911734 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Ensure we always free DNS resources when deleting a process

* src/process.c (free_dns_request): Factor out into own function.
(Fdelete_process): When deleting a process, free any DNS
structures associated with it.
(check_for_dns): Always free all DNS resources.
parent e4324bdf
...@@ -743,6 +743,23 @@ remove_process (register Lisp_Object proc) ...@@ -743,6 +743,23 @@ remove_process (register Lisp_Object proc)
deactivate_process (proc); deactivate_process (proc);
} }
#ifdef HAVE_GETADDRINFO_A
static void
free_dns_request (Lisp_Object proc)
{
struct Lisp_Process *p = XPROCESS (proc);
if (p->dns_requests[0]->ar_result)
freeaddrinfo (p->dns_requests[0]->ar_result);
xfree ((void *)p->dns_requests[0]->ar_request);
xfree ((void *)p->dns_requests[0]->ar_name);
xfree ((void *)p->dns_requests[0]->ar_service);
xfree (p->dns_requests[0]);
xfree (p->dns_requests);
p->dns_requests = NULL;
}
#endif
DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0,
doc: /* Return t if OBJECT is a process. */) doc: /* Return t if OBJECT is a process. */)
...@@ -833,6 +850,14 @@ nil, indicating the current buffer's process. */) ...@@ -833,6 +850,14 @@ nil, indicating the current buffer's process. */)
process = get_process (process); process = get_process (process);
p = XPROCESS (process); p = XPROCESS (process);
#ifdef HAVE_GETADDRINFO_A
if (p->dns_requests)
{
gai_cancel (p->dns_requests[0]);
free_dns_request (process);
}
#endif
p->raw_status_new = 0; p->raw_status_new = 0;
if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p)) if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p))
{ {
...@@ -4652,10 +4677,6 @@ check_for_dns (Lisp_Object proc) ...@@ -4652,10 +4677,6 @@ check_for_dns (Lisp_Object proc)
if (! p->dns_requests) if (! p->dns_requests)
return Qnil; return Qnil;
/* This process should not already be connected (or killed). */
if (!EQ (p->status, Qconnect))
return Qnil;
ret = gai_error (p->dns_requests[0]); ret = gai_error (p->dns_requests[0]);
if (ret == EAI_INPROGRESS) if (ret == EAI_INPROGRESS)
return Qt; return Qt;
...@@ -4673,10 +4694,9 @@ check_for_dns (Lisp_Object proc) ...@@ -4673,10 +4694,9 @@ check_for_dns (Lisp_Object proc)
} }
ip_addresses = Fnreverse (ip_addresses); ip_addresses = Fnreverse (ip_addresses);
freeaddrinfo (p->dns_requests[0]->ar_result);
} }
/* The DNS lookup failed. */ /* The DNS lookup failed. */
else else if (!EQ (p->status, Qconnect))
{ {
deactivate_process (proc); deactivate_process (proc);
pset_status (p, (list2 pset_status (p, (list2
...@@ -4686,12 +4706,11 @@ check_for_dns (Lisp_Object proc) ...@@ -4686,12 +4706,11 @@ check_for_dns (Lisp_Object proc)
build_string (" failed"))))); build_string (" failed")))));
} }
xfree ((void *)p->dns_requests[0]->ar_request); free_dns_request (proc);
xfree ((void *)p->dns_requests[0]->ar_name);
xfree ((void *)p->dns_requests[0]->ar_service); /* This process should not already be connected (or killed). */
xfree (p->dns_requests[0]); if (!EQ (p->status, Qconnect))
xfree (p->dns_requests); return Qnil;
p->dns_requests = NULL;
return ip_addresses; return ip_addresses;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment