From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alain Schneble Newsgroups: gmane.emacs.devel Subject: Re: Asynchronous DNS Date: Sun, 14 Feb 2016 00:47:27 +0100 Message-ID: <86y4ao5g1c.fsf@realize.ch> References: <87si1gx6wz.fsf@gnus.org> <86y4b5zvzt.fsf@gmail.com> <8760y9kwrk.fsf@gnus.org> <87wpqpjgwy.fsf@gnus.org> <83a8nk1cxk.fsf@gnu.org> <87h9hrnc8x.fsf@gnus.org> <83powfzsqt.fsf@gnu.org> <87y4b393hl.fsf@gnus.org> <83io27ytu3.fsf@gnu.org> <87k2mmzkry.fsf@gnus.org> <83k2mlyet8.fsf@gnu.org> <87lh71nriy.fsf@gnus.org> <8637t8opla.fsf@realize.ch> <871t8skg6c.fsf@gnus.org> <86y4b0n5q2.fsf@realize.ch> <87fux7gb7o.fsf@gnus.org> <83wpqjvd2f.fsf@gnu.org> <87zivfobn4.fsf@gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1455415117 30568 80.91.229.3 (14 Feb 2016 01:58:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Feb 2016 01:58:37 +0000 (UTC) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Feb 14 02:58:33 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aUlxH-0006DR-K1 for ged-emacs-devel@m.gmane.org; Sun, 14 Feb 2016 02:58:31 +0100 Original-Received: from localhost ([::1]:46446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUlxG-0005Kd-QC for ged-emacs-devel@m.gmane.org; Sat, 13 Feb 2016 20:58:30 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUjvB-0002ss-9c for emacs-devel@gnu.org; Sat, 13 Feb 2016 18:48:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUjv7-0007I5-I2 for emacs-devel@gnu.org; Sat, 13 Feb 2016 18:48:13 -0500 Original-Received: from clientmail.realize.ch ([46.140.89.53]:2479) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1aUjv2-0007GY-Ak; Sat, 13 Feb 2016 18:48:04 -0500 Original-Received: from rintintin.hq.realize.ch.lan.rit ([192.168.0.105]) by clientmail.realize.ch ; Sun, 14 Feb 2016 00:47:51 +0100 Original-Received: from MYNGB (192.168.66.64) by rintintin.hq.realize.ch.lan.rit (192.168.0.105) with Microsoft SMTP Server (TLS) id 15.0.516.32; Sun, 14 Feb 2016 00:47:26 +0100 In-Reply-To: <87zivfobn4.fsf@gnus.org> (Lars Ingebrigtsen's message of "Fri, 05 Feb 2016 18:32:31 +1100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt) X-ClientProxiedBy: rintintin.hq.realize.ch.lan.rit (192.168.0.105) To rintintin.hq.realize.ch.lan.rit (192.168.0.105) X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] X-Received-From: 46.140.89.53 X-Mailman-Approved-At: Sat, 13 Feb 2016 20:58:16 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:199901 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Eli Zaretskii writes: > >>> From: Lars Ingebrigtsen >>> >>> Is there a process list somewhere? >> >> See Vprocess_alist. > > Thanks. I don't know how I missed it.. It's even the next-to-last > statement in make_process, that I thought I had read: > > Vprocess_alist = Fcons (Fcons (name, val), Vprocess_alist); The following patch removes the separate dns_processes list in favour of reusing Vprocess_alist. The latter list is now used to loop over all processes -- to check if pending DNS requests have completed. Do you agree whith this change? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename="0001-Get-rid-of-separate-dns_processes-list.patch" Content-Description: Patch -- Get rid of separate dns_processes list >From 4967cb5b9f8b9342cae02ae9e2949474606a7fb3 Mon Sep 17 00:00:00 2001 From: Alain Schneble Date: Sun, 14 Feb 2016 00:21:22 +0100 Subject: [PATCH] Get rid of separate dns_processes 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 | 90 ++++++++++++++++++++++------------------------------------- 1 file changed, 34 insertions(+), 56 deletions(-) diff --git a/src/process.c b/src/process.c index 497b069..ec123e9 100644 --- a/src/process.c +++ b/src/process.c @@ -281,10 +281,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; -#endif /* Alist of elements (NAME . PROCESS). */ static Lisp_Object Vprocess_alist; @@ -3881,7 +3877,6 @@ usage: (make-network-process &rest ARGS) */) { p->dns_requests = dns_requests; p->status = Qconnect; - dns_processes = Fcons (proc, dns_processes); } else { @@ -4778,51 +4773,41 @@ 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); + + 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)); - } - } + /* 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. */ @@ -7684,9 +7669,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 @@ -7774,10 +7756,6 @@ syms_of_process (void) staticpro (&Vprocess_alist); staticpro (&deleted_pid_list); -#ifdef HAVE_GETADDRINFO_A - staticpro (&dns_processes); -#endif - #endif /* subprocesses */ DEFSYM (QCname, ":name"); -- 2.6.2.windows.1 --=-=-=--