diff options
| author | Lars Ingebrigtsen | 2016-02-16 13:23:15 +1100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-02-16 13:23:15 +1100 |
| commit | df91173405f97075e939fa7072f941d7d59c785d (patch) | |
| tree | 3afa08b17b7f77e9d19a5393b99e50119daaf51f /src/process.c | |
| parent | e4324bdf565fd934afa7558d4356f040d3a66c6e (diff) | |
| download | emacs-df91173405f97075e939fa7072f941d7d59c785d.tar.gz emacs-df91173405f97075e939fa7072f941d7d59c785d.zip | |
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.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/process.c b/src/process.c index 9c09aeefa6b..02e19c3a84e 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -743,6 +743,23 @@ remove_process (register Lisp_Object proc) | |||
| 743 | deactivate_process (proc); | 743 | deactivate_process (proc); |
| 744 | } | 744 | } |
| 745 | 745 | ||
| 746 | #ifdef HAVE_GETADDRINFO_A | ||
| 747 | static void | ||
| 748 | free_dns_request (Lisp_Object proc) | ||
| 749 | { | ||
| 750 | struct Lisp_Process *p = XPROCESS (proc); | ||
| 751 | |||
| 752 | if (p->dns_requests[0]->ar_result) | ||
| 753 | freeaddrinfo (p->dns_requests[0]->ar_result); | ||
| 754 | xfree ((void *)p->dns_requests[0]->ar_request); | ||
| 755 | xfree ((void *)p->dns_requests[0]->ar_name); | ||
| 756 | xfree ((void *)p->dns_requests[0]->ar_service); | ||
| 757 | xfree (p->dns_requests[0]); | ||
| 758 | xfree (p->dns_requests); | ||
| 759 | p->dns_requests = NULL; | ||
| 760 | } | ||
| 761 | #endif | ||
| 762 | |||
| 746 | 763 | ||
| 747 | DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, | 764 | DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, |
| 748 | doc: /* Return t if OBJECT is a process. */) | 765 | doc: /* Return t if OBJECT is a process. */) |
| @@ -833,6 +850,14 @@ nil, indicating the current buffer's process. */) | |||
| 833 | process = get_process (process); | 850 | process = get_process (process); |
| 834 | p = XPROCESS (process); | 851 | p = XPROCESS (process); |
| 835 | 852 | ||
| 853 | #ifdef HAVE_GETADDRINFO_A | ||
| 854 | if (p->dns_requests) | ||
| 855 | { | ||
| 856 | gai_cancel (p->dns_requests[0]); | ||
| 857 | free_dns_request (process); | ||
| 858 | } | ||
| 859 | #endif | ||
| 860 | |||
| 836 | p->raw_status_new = 0; | 861 | p->raw_status_new = 0; |
| 837 | if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p)) | 862 | if (NETCONN1_P (p) || SERIALCONN1_P (p) || PIPECONN1_P (p)) |
| 838 | { | 863 | { |
| @@ -4652,10 +4677,6 @@ check_for_dns (Lisp_Object proc) | |||
| 4652 | if (! p->dns_requests) | 4677 | if (! p->dns_requests) |
| 4653 | return Qnil; | 4678 | return Qnil; |
| 4654 | 4679 | ||
| 4655 | /* This process should not already be connected (or killed). */ | ||
| 4656 | if (!EQ (p->status, Qconnect)) | ||
| 4657 | return Qnil; | ||
| 4658 | |||
| 4659 | ret = gai_error (p->dns_requests[0]); | 4680 | ret = gai_error (p->dns_requests[0]); |
| 4660 | if (ret == EAI_INPROGRESS) | 4681 | if (ret == EAI_INPROGRESS) |
| 4661 | return Qt; | 4682 | return Qt; |
| @@ -4673,10 +4694,9 @@ check_for_dns (Lisp_Object proc) | |||
| 4673 | } | 4694 | } |
| 4674 | 4695 | ||
| 4675 | ip_addresses = Fnreverse (ip_addresses); | 4696 | ip_addresses = Fnreverse (ip_addresses); |
| 4676 | freeaddrinfo (p->dns_requests[0]->ar_result); | ||
| 4677 | } | 4697 | } |
| 4678 | /* The DNS lookup failed. */ | 4698 | /* The DNS lookup failed. */ |
| 4679 | else | 4699 | else if (!EQ (p->status, Qconnect)) |
| 4680 | { | 4700 | { |
| 4681 | deactivate_process (proc); | 4701 | deactivate_process (proc); |
| 4682 | pset_status (p, (list2 | 4702 | pset_status (p, (list2 |
| @@ -4686,12 +4706,11 @@ check_for_dns (Lisp_Object proc) | |||
| 4686 | build_string (" failed"))))); | 4706 | build_string (" failed"))))); |
| 4687 | } | 4707 | } |
| 4688 | 4708 | ||
| 4689 | xfree ((void *)p->dns_requests[0]->ar_request); | 4709 | free_dns_request (proc); |
| 4690 | xfree ((void *)p->dns_requests[0]->ar_name); | 4710 | |
| 4691 | xfree ((void *)p->dns_requests[0]->ar_service); | 4711 | /* This process should not already be connected (or killed). */ |
| 4692 | xfree (p->dns_requests[0]); | 4712 | if (!EQ (p->status, Qconnect)) |
| 4693 | xfree (p->dns_requests); | 4713 | return Qnil; |
| 4694 | p->dns_requests = NULL; | ||
| 4695 | 4714 | ||
| 4696 | return ip_addresses; | 4715 | return ip_addresses; |
| 4697 | } | 4716 | } |