diff options
| author | Paul Eggert | 2016-03-09 16:24:59 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-03-09 16:25:41 -0800 |
| commit | f0b31080140217bf90772a39c66088069f466d8b (patch) | |
| tree | 28df375e48a86b597f4a972c0804ecbf3d8b2397 /src | |
| parent | 7801999f79519326e1073be878f7ada50a492542 (diff) | |
| download | emacs-f0b31080140217bf90772a39c66088069f466d8b.tar.gz emacs-f0b31080140217bf90772a39c66088069f466d8b.zip | |
Minor fixes for getaddrinfo_a usage
* src/process.c (Fdelete_process): Check gai_cancel return value.
That way, there’s no need to invoke gai_error. Check gai_suspend
return value.
(Fmake_network_process): Don’t assume gai_strerror returns a UTF-8
string. Simplify call to connect_network_socket.
(check_for_dns): Avoid unnecessary initialization of local.
Diffstat (limited to 'src')
| -rw-r--r-- | src/process.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/src/process.c b/src/process.c index 359cd2195aa..56f036cd7d2 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -845,23 +845,19 @@ nil, indicating the current buffer's process. */) | |||
| 845 | #ifdef HAVE_GETADDRINFO_A | 845 | #ifdef HAVE_GETADDRINFO_A |
| 846 | if (p->dns_request) | 846 | if (p->dns_request) |
| 847 | { | 847 | { |
| 848 | int ret; | 848 | /* Cancel the request. Unless shutting down, wait until |
| 849 | completion. Free the request if completely canceled. */ | ||
| 849 | 850 | ||
| 850 | gai_cancel (p->dns_request); | 851 | bool canceled = gai_cancel (p->dns_request) != EAI_NOTCANCELED; |
| 851 | ret = gai_error (p->dns_request); | 852 | if (!canceled && !inhibit_sentinels) |
| 852 | if (ret == EAI_CANCELED || ret == 0) | ||
| 853 | free_dns_request (process); | ||
| 854 | else | ||
| 855 | { | 853 | { |
| 856 | /* If we're called during shutdown, we don't really about | 854 | struct gaicb const *req = p->dns_request; |
| 857 | freeing all the resources. Otherwise wait until | 855 | while (gai_suspend (&req, 1, NULL) != 0) |
| 858 | completion, and then free the request. */ | 856 | continue; |
| 859 | if (! inhibit_sentinels) | 857 | canceled = true; |
| 860 | { | ||
| 861 | gai_suspend ((struct gaicb const **) &p->dns_request, 1, NULL); | ||
| 862 | free_dns_request (process); | ||
| 863 | } | ||
| 864 | } | 858 | } |
| 859 | if (canceled) | ||
| 860 | free_dns_request (process); | ||
| 865 | } | 861 | } |
| 866 | #endif | 862 | #endif |
| 867 | 863 | ||
| @@ -3814,7 +3810,14 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3814 | ret = getaddrinfo (SSDATA (host), portstring, &hints, &res); | 3810 | ret = getaddrinfo (SSDATA (host), portstring, &hints, &res); |
| 3815 | if (ret) | 3811 | if (ret) |
| 3816 | #ifdef HAVE_GAI_STRERROR | 3812 | #ifdef HAVE_GAI_STRERROR |
| 3817 | error ("%s/%s %s", SSDATA (host), portstring, gai_strerror (ret)); | 3813 | { |
| 3814 | synchronize_system_messages_locale (); | ||
| 3815 | char const *str = gai_strerror (ret); | ||
| 3816 | if (! NILP (Vlocale_coding_system)) | ||
| 3817 | str = SSDATA (code_convert_string_norecord | ||
| 3818 | (build_string (str), Vlocale_coding_system, 0)); | ||
| 3819 | error ("%s/%s %s", SSDATA (host), portstring, str); | ||
| 3820 | } | ||
| 3818 | #else | 3821 | #else |
| 3819 | error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret); | 3822 | error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret); |
| 3820 | #endif | 3823 | #endif |
| @@ -3932,21 +3935,17 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3932 | } | 3935 | } |
| 3933 | 3936 | ||
| 3934 | #ifdef HAVE_GETADDRINFO_A | 3937 | #ifdef HAVE_GETADDRINFO_A |
| 3935 | /* If we're doing async address resolution, the list of addresses | 3938 | /* With async address resolution, the list of addresses is empty, so |
| 3936 | here will be nil, so we postpone connecting to the server. */ | 3939 | postpone connecting to the server. */ |
| 3937 | if (!p->is_server && NILP (ip_addresses)) | 3940 | if (!p->is_server && NILP (ip_addresses)) |
| 3938 | { | 3941 | { |
| 3939 | p->dns_request = dns_request; | 3942 | p->dns_request = dns_request; |
| 3940 | p->status = Qconnect; | 3943 | p->status = Qconnect; |
| 3944 | return proc; | ||
| 3941 | } | 3945 | } |
| 3942 | else | ||
| 3943 | { | ||
| 3944 | connect_network_socket (proc, ip_addresses); | ||
| 3945 | } | ||
| 3946 | #else /* HAVE_GETADDRINFO_A */ | ||
| 3947 | connect_network_socket (proc, ip_addresses); | ||
| 3948 | #endif | 3946 | #endif |
| 3949 | 3947 | ||
| 3948 | connect_network_socket (proc, ip_addresses); | ||
| 3950 | return proc; | 3949 | return proc; |
| 3951 | } | 3950 | } |
| 3952 | 3951 | ||
| @@ -4657,13 +4656,12 @@ check_for_dns (Lisp_Object proc) | |||
| 4657 | { | 4656 | { |
| 4658 | struct Lisp_Process *p = XPROCESS (proc); | 4657 | struct Lisp_Process *p = XPROCESS (proc); |
| 4659 | Lisp_Object ip_addresses = Qnil; | 4658 | Lisp_Object ip_addresses = Qnil; |
| 4660 | int ret = 0; | ||
| 4661 | 4659 | ||
| 4662 | /* Sanity check. */ | 4660 | /* Sanity check. */ |
| 4663 | if (! p->dns_request) | 4661 | if (! p->dns_request) |
| 4664 | return Qnil; | 4662 | return Qnil; |
| 4665 | 4663 | ||
| 4666 | ret = gai_error (p->dns_request); | 4664 | int ret = gai_error (p->dns_request); |
| 4667 | if (ret == EAI_INPROGRESS) | 4665 | if (ret == EAI_INPROGRESS) |
| 4668 | return Qt; | 4666 | return Qt; |
| 4669 | 4667 | ||