emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] feature/async-dns d1fc5a5 1/3: Loop over the process list


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] feature/async-dns d1fc5a5 1/3: Loop over the process list instead of maintaining a separate list
Date: Tue, 16 Feb 2016 04:57:19 +0000

branch: feature/async-dns
commit d1fc5a548e5b49df40b0a8dad1f962cd01593da4
Author: Alain Schneble <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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.
---
 src/process.c |   86 ++++++++++++++++++++++-----------------------------------
 1 files changed, 33 insertions(+), 53 deletions(-)

diff --git a/src/process.c b/src/process.c
index b4a2de9..fec2f5a 100644
--- a/src/process.c
+++ b/src/process.c
@@ -282,8 +282,6 @@ static int max_input_desc;
 /* Indexed by descriptor, gives the process (if any) for that descriptor.  */
 static Lisp_Object chan_process[FD_SETSIZE];
 #ifdef HAVE_GETADDRINFO_A
-/* Pending DNS requests. */
-static Lisp_Object dns_processes;
 static void wait_for_socket_fds (Lisp_Object process, char *name);
 #endif
 
@@ -3959,7 +3957,6 @@ usage: (make-network-process &rest ARGS)  */)
     {
       p->dns_requests = dns_requests;
       p->status = Qconnect;
-      dns_processes = Fcons (proc, dns_processes);
     }
   else
     {
@@ -4885,51 +4882,40 @@ wait_reading_process_output (intmax_t time_limit, int 
nsecs, int read_kbd,
        break;
 
 #ifdef HAVE_GETADDRINFO_A
-      if (!NILP (dns_processes))
-       {
-         Lisp_Object dns_list = dns_processes, dns, ip_addresses,
-           answers = Qnil, answer, new = Qnil;
-         struct Lisp_Process *p;
-
-         /* This is programmed in a somewhat awkward fashion because
-         calling connect_network_socket might make us end up back
-         here again, and we would have a race condition with
-         segfaults.  So first go through all pending requests and see
-         whether we got any answers. */
-         while (!NILP (dns_list))
-           {
-             dns = XCAR (dns_list);
-             dns_list = XCDR (dns_list);
-             p = XPROCESS (dns);
-             if (p && p->dns_requests)
-               {
-                 if (! wait_proc || p == wait_proc)
-                   {
-                     ip_addresses = check_for_dns (dns);
-                     if (EQ (ip_addresses, Qt))
-                       new = Fcons (dns, new);
-                     else
-                       answers = Fcons (Fcons (dns, ip_addresses), answers);
-                   }
-                 else
-                   new = Fcons (dns, new);
-               }
-           }
-
-         /* Replace with the list of DNS requests still not responded
-            to. */
-         dns_processes = new;
+      {
+       Lisp_Object ip_addresses, answers = Qnil, answer;
+       Lisp_Object process_list_head, async_dns_process_candidate;
+       struct Lisp_Process *p;
+
+       /* This is programmed in a somewhat awkward fashion because
+          calling connect_network_socket might make us end up back
+          here again, and we would have a race condition with
+          segfaults.  So first go through all pending requests and see
+          whether we got any answers. */
+       FOR_EACH_PROCESS(process_list_head, async_dns_process_candidate)
+         {
+           p = XPROCESS (async_dns_process_candidate);
 
-         /* Then continue the connection for the successful
-            requests. */
-         while (!NILP (answers))
-           {
-             answer = XCAR (answers);
-             answers = XCDR (answers);
-             if (!NILP (XCDR (answer)))
-               connect_network_socket (XCAR (answer), XCDR (answer));
-           }
-       }
+           if (p->dns_requests)
+             {
+               if (! wait_proc || p == wait_proc)
+                 {
+                   ip_addresses = check_for_dns (async_dns_process_candidate);
+                   if (!EQ (ip_addresses, Qt))
+                     answers = Fcons (Fcons (async_dns_process_candidate, 
ip_addresses), answers);
+                 }
+             }
+         }
+       /* Then continue the connection for the successful
+          requests. */
+       while (!NILP (answers))
+         {
+           answer = XCAR (answers);
+           answers = XCDR (answers);
+           if (!NILP (XCDR (answer)))
+             connect_network_socket (XCAR (answer), XCDR (answer));
+         }
+      }
 #endif /* HAVE_GETADDRINFO_A */
 
       /* Compute time from now till when time limit is up.  */
@@ -7811,9 +7797,6 @@ init_process_emacs (void)
 #ifdef DATAGRAM_SOCKETS
   memset (datagram_address, 0, sizeof datagram_address);
 #endif
-#ifdef HAVE_GETADDRINFO_A
-  dns_processes = Qnil;
-#endif
 
 #if defined (DARWIN_OS)
   /* PTYs are broken on Darwin < 6, but are sometimes useful for interactive
@@ -7901,9 +7884,6 @@ syms_of_process (void)
 
   staticpro (&Vprocess_alist);
   staticpro (&deleted_pid_list);
-#ifdef HAVE_GETADDRINFO_A
-  staticpro (&dns_processes);
-#endif
 
 #endif /* subprocesses */
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]