diff options
| author | Alain Schneble | 2016-02-16 13:50:23 +1100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-02-16 13:50:23 +1100 |
| commit | d1fc5a548e5b49df40b0a8dad1f962cd01593da4 (patch) | |
| tree | 32c139038a908af2744aeb07ca7835fd7a15cf18 /src | |
| parent | 9755b75300b7c451bc79984eed2e346ce0a4ffb5 (diff) | |
| download | emacs-d1fc5a548e5b49df40b0a8dad1f962cd01593da4.tar.gz emacs-d1fc5a548e5b49df40b0a8dad1f962cd01593da4.zip | |
Loop over the process list instead of maintaining a separate list
* src/process.c: Remove declaration/definition of dns_processes list.
* src/process.c (wait_reading_process_output): Loop over all processes in
Vprocess_alist instead of dns_processes, to check for completed DNS
requests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/process.c | 86 |
1 files changed, 33 insertions, 53 deletions
diff --git a/src/process.c b/src/process.c index b4a2de98e12..fec2f5a7ee4 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -282,8 +282,6 @@ static int max_input_desc; | |||
| 282 | /* Indexed by descriptor, gives the process (if any) for that descriptor. */ | 282 | /* Indexed by descriptor, gives the process (if any) for that descriptor. */ |
| 283 | static Lisp_Object chan_process[FD_SETSIZE]; | 283 | static Lisp_Object chan_process[FD_SETSIZE]; |
| 284 | #ifdef HAVE_GETADDRINFO_A | 284 | #ifdef HAVE_GETADDRINFO_A |
| 285 | /* Pending DNS requests. */ | ||
| 286 | static Lisp_Object dns_processes; | ||
| 287 | static void wait_for_socket_fds (Lisp_Object process, char *name); | 285 | static void wait_for_socket_fds (Lisp_Object process, char *name); |
| 288 | #endif | 286 | #endif |
| 289 | 287 | ||
| @@ -3959,7 +3957,6 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3959 | { | 3957 | { |
| 3960 | p->dns_requests = dns_requests; | 3958 | p->dns_requests = dns_requests; |
| 3961 | p->status = Qconnect; | 3959 | p->status = Qconnect; |
| 3962 | dns_processes = Fcons (proc, dns_processes); | ||
| 3963 | } | 3960 | } |
| 3964 | else | 3961 | else |
| 3965 | { | 3962 | { |
| @@ -4885,51 +4882,40 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4885 | break; | 4882 | break; |
| 4886 | 4883 | ||
| 4887 | #ifdef HAVE_GETADDRINFO_A | 4884 | #ifdef HAVE_GETADDRINFO_A |
| 4888 | if (!NILP (dns_processes)) | 4885 | { |
| 4889 | { | 4886 | Lisp_Object ip_addresses, answers = Qnil, answer; |
| 4890 | Lisp_Object dns_list = dns_processes, dns, ip_addresses, | 4887 | Lisp_Object process_list_head, async_dns_process_candidate; |
| 4891 | answers = Qnil, answer, new = Qnil; | 4888 | struct Lisp_Process *p; |
| 4892 | struct Lisp_Process *p; | 4889 | |
| 4893 | 4890 | /* This is programmed in a somewhat awkward fashion because | |
| 4894 | /* This is programmed in a somewhat awkward fashion because | 4891 | calling connect_network_socket might make us end up back |
| 4895 | calling connect_network_socket might make us end up back | 4892 | here again, and we would have a race condition with |
| 4896 | here again, and we would have a race condition with | 4893 | segfaults. So first go through all pending requests and see |
| 4897 | segfaults. So first go through all pending requests and see | 4894 | whether we got any answers. */ |
| 4898 | whether we got any answers. */ | 4895 | FOR_EACH_PROCESS(process_list_head, async_dns_process_candidate) |
| 4899 | while (!NILP (dns_list)) | 4896 | { |
| 4900 | { | 4897 | p = XPROCESS (async_dns_process_candidate); |
| 4901 | dns = XCAR (dns_list); | ||
| 4902 | dns_list = XCDR (dns_list); | ||
| 4903 | p = XPROCESS (dns); | ||
| 4904 | if (p && p->dns_requests) | ||
| 4905 | { | ||
| 4906 | if (! wait_proc || p == wait_proc) | ||
| 4907 | { | ||
| 4908 | ip_addresses = check_for_dns (dns); | ||
| 4909 | if (EQ (ip_addresses, Qt)) | ||
| 4910 | new = Fcons (dns, new); | ||
| 4911 | else | ||
| 4912 | answers = Fcons (Fcons (dns, ip_addresses), answers); | ||
| 4913 | } | ||
| 4914 | else | ||
| 4915 | new = Fcons (dns, new); | ||
| 4916 | } | ||
| 4917 | } | ||
| 4918 | |||
| 4919 | /* Replace with the list of DNS requests still not responded | ||
| 4920 | to. */ | ||
| 4921 | dns_processes = new; | ||
| 4922 | 4898 | ||
| 4923 | /* Then continue the connection for the successful | 4899 | if (p->dns_requests) |
| 4924 | requests. */ | 4900 | { |
| 4925 | while (!NILP (answers)) | 4901 | if (! wait_proc || p == wait_proc) |
| 4926 | { | 4902 | { |
| 4927 | answer = XCAR (answers); | 4903 | ip_addresses = check_for_dns (async_dns_process_candidate); |
| 4928 | answers = XCDR (answers); | 4904 | if (!EQ (ip_addresses, Qt)) |
| 4929 | if (!NILP (XCDR (answer))) | 4905 | answers = Fcons (Fcons (async_dns_process_candidate, ip_addresses), answers); |
| 4930 | connect_network_socket (XCAR (answer), XCDR (answer)); | 4906 | } |
| 4931 | } | 4907 | } |
| 4932 | } | 4908 | } |
| 4909 | /* Then continue the connection for the successful | ||
| 4910 | requests. */ | ||
| 4911 | while (!NILP (answers)) | ||
| 4912 | { | ||
| 4913 | answer = XCAR (answers); | ||
| 4914 | answers = XCDR (answers); | ||
| 4915 | if (!NILP (XCDR (answer))) | ||
| 4916 | connect_network_socket (XCAR (answer), XCDR (answer)); | ||
| 4917 | } | ||
| 4918 | } | ||
| 4933 | #endif /* HAVE_GETADDRINFO_A */ | 4919 | #endif /* HAVE_GETADDRINFO_A */ |
| 4934 | 4920 | ||
| 4935 | /* Compute time from now till when time limit is up. */ | 4921 | /* Compute time from now till when time limit is up. */ |
| @@ -7811,9 +7797,6 @@ init_process_emacs (void) | |||
| 7811 | #ifdef DATAGRAM_SOCKETS | 7797 | #ifdef DATAGRAM_SOCKETS |
| 7812 | memset (datagram_address, 0, sizeof datagram_address); | 7798 | memset (datagram_address, 0, sizeof datagram_address); |
| 7813 | #endif | 7799 | #endif |
| 7814 | #ifdef HAVE_GETADDRINFO_A | ||
| 7815 | dns_processes = Qnil; | ||
| 7816 | #endif | ||
| 7817 | 7800 | ||
| 7818 | #if defined (DARWIN_OS) | 7801 | #if defined (DARWIN_OS) |
| 7819 | /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive | 7802 | /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive |
| @@ -7901,9 +7884,6 @@ syms_of_process (void) | |||
| 7901 | 7884 | ||
| 7902 | staticpro (&Vprocess_alist); | 7885 | staticpro (&Vprocess_alist); |
| 7903 | staticpro (&deleted_pid_list); | 7886 | staticpro (&deleted_pid_list); |
| 7904 | #ifdef HAVE_GETADDRINFO_A | ||
| 7905 | staticpro (&dns_processes); | ||
| 7906 | #endif | ||
| 7907 | 7887 | ||
| 7908 | #endif /* subprocesses */ | 7888 | #endif /* subprocesses */ |
| 7909 | 7889 | ||