From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#22946: 25.1.50; NON_BLOCKING_CONNECT is obsolete Date: Tue, 22 Mar 2016 01:21:18 -0700 Organization: UCLA Computer Science Department Message-ID: <56F1007E.20204@cs.ucla.edu> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060409000100010007000409" X-Trace: ger.gmane.org 1458634949 31989 80.91.229.3 (22 Mar 2016 08:22:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Mar 2016 08:22:29 +0000 (UTC) To: 22946-done@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Mar 22 09:22:18 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1aiHZx-0002RQ-Uy for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 Mar 2016 09:22:18 +0100 Original-Received: from localhost ([::1]:34436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiHZx-0000Om-1D for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 Mar 2016 04:22:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiHZp-0000Mt-09 for bug-gnu-emacs@gnu.org; Tue, 22 Mar 2016 04:22:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiHZj-0001VM-UD for bug-gnu-emacs@gnu.org; Tue, 22 Mar 2016 04:22:08 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiHZj-0001VB-Qj for bug-gnu-emacs@gnu.org; Tue, 22 Mar 2016 04:22:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1aiHZi-0008Nj-I9 for bug-gnu-emacs@gnu.org; Tue, 22 Mar 2016 04:22:02 -0400 In-Reply-To: Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Mar 2016 08:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 22946 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 22946@debbugs.gnu.org, eggert@cs.ucla.edu, larsi@gnus.org Original-Received: via spool by 22946-done@debbugs.gnu.org id=D22946.145863489232174 (code D ref 22946); Tue, 22 Mar 2016 08:22:02 +0000 Original-Received: (at 22946-done) by debbugs.gnu.org; 22 Mar 2016 08:21:32 +0000 Original-Received: from localhost ([127.0.0.1]:57670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aiHZD-0008Mr-Kh for submit@debbugs.gnu.org; Tue, 22 Mar 2016 04:21:31 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aiHZB-0008Me-LA for 22946-done@debbugs.gnu.org; Tue, 22 Mar 2016 04:21:30 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C63F8161211 for <22946-done@debbugs.gnu.org>; Tue, 22 Mar 2016 01:21:23 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 1mg6kWIA441E for <22946-done@debbugs.gnu.org>; Tue, 22 Mar 2016 01:21:22 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9CEC416122B for <22946-done@debbugs.gnu.org>; Tue, 22 Mar 2016 01:21:22 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 1R-3ROdhh0Ly for <22946-done@debbugs.gnu.org>; Tue, 22 Mar 2016 01:21:22 -0700 (PDT) Original-Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 7D29C161211 for <22946-done@debbugs.gnu.org>; Tue, 22 Mar 2016 01:21:22 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:115295 Archived-At: This is a multi-part message in MIME format. --------------060409000100010007000409 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I installed the attached patch, to assume NON_BLOCKING_CONNECT. --------------060409000100010007000409 Content-Type: text/x-diff; name="0001-Assume-NON_BLOCKING_CONNECT-Bug-22946.patch" Content-Disposition: attachment; filename="0001-Assume-NON_BLOCKING_CONNECT-Bug-22946.patch" Content-Transfer-Encoding: quoted-printable >From d8c3ca9353343726b202e260bca0fd03e298578f Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 22 Mar 2016 01:17:56 -0700 Subject: [PATCH] Assume NON_BLOCKING_CONNECT (Bug#22946) MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/proced.el (proced-signal-list): Omit comment about obsolete systems that do not support POSIX 1003.1-2001 signals. * src/process.c (NON_BLOCKING_CONNECT): Remove, since we can now assume POSIX 1003.1-2001 or better here. Assume it=E2=80=99s defined. (connect_network_socket): Assume EINPROGRESS is defined, as that=E2=80=99s portable too now. (Fmake_network_process): Use bool for boolean. --- lisp/proced.el | 3 --- src/process.c | 53 +++++-----------------------------------------------= - 2 files changed, 5 insertions(+), 51 deletions(-) diff --git a/lisp/proced.el b/lisp/proced.el index dee646c..db45e20 100644 --- a/lisp/proced.el +++ b/lisp/proced.el @@ -78,9 +78,6 @@ proced-signal-list ("KILL" . " (9. Kill - cannot be caught or ignored)") ("ALRM" . " (14. Alarm Clock)") ("TERM" . " (15. Termination)") - ;; POSIX 1003.1-2001 - ;; Which systems do not support these signals so that we can - ;; exclude them from `proced-signal-list'? ("CONT" . " (Continue executing)") ("STOP" . " (Stop executing / pause - cannot be caught or ignored)"= ) ("TSTP" . " (Terminal stop / pause)")) diff --git a/src/process.c b/src/process.c index a518c2b..198e7de 100644 --- a/src/process.c +++ b/src/process.c @@ -193,16 +193,6 @@ static EMACS_INT process_tick; /* Number of events for which the user or sentinel has been notified. *= / static EMACS_INT update_tick; =20 -/* Define NON_BLOCKING_CONNECT if we can support non-blocking connects. - The code can be simplified by assuming NON_BLOCKING_CONNECT once - Emacs starts assuming POSIX 1003.1-2001 or later. */ - -#if (defined HAVE_SELECT \ - && (defined GNU_LINUX || defined HAVE_GETPEERNAME) \ - && (defined EWOULDBLOCK || defined EINPROGRESS)) -# define NON_BLOCKING_CONNECT -#endif - /* Define DATAGRAM_SOCKETS if datagrams can be used safely on this system. We need to read full packets, so we need a "non-destructive" select. So we require either native select, @@ -262,7 +252,6 @@ static fd_set non_process_wait_mask; =20 static fd_set write_mask; =20 -#ifdef NON_BLOCKING_CONNECT /* Mask of bits indicating the descriptors that we wait for connect to complete on. Once they complete, they are removed from this mask and added to the input_wait_mask and non_keyboard_wait_mask. */ @@ -271,7 +260,6 @@ static fd_set connect_wait_mask; =20 /* Number of bits set in connect_wait_mask. */ static int num_pending_connects; -#endif /* NON_BLOCKING_CONNECT */ =20 /* The largest descriptor currently in use for a process object; -1 if n= one. */ static int max_process_desc; @@ -3133,7 +3121,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Obje= ct ip_addresses) break; #endif /* DATAGRAM_SOCKETS */ =20 -#ifdef NON_BLOCKING_CONNECT if (p->is_non_blocking_client) { ret =3D fcntl (s, F_SETFL, O_NONBLOCK); @@ -3145,7 +3132,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Obje= ct ip_addresses) continue; } } -#endif =20 /* Make us close S if quit. */ record_unwind_protect_int (close_file_unwind, s); @@ -3221,17 +3207,8 @@ connect_network_socket (Lisp_Object proc, Lisp_Obj= ect ip_addresses) break; } =20 -#ifdef NON_BLOCKING_CONNECT -#ifdef EINPROGRESS if (p->is_non_blocking_client && xerrno =3D=3D EINPROGRESS) break; -#else -#ifdef EWOULDBLOCK - if (p->is_non_blocking_client && xerrno =3D=3D EWOULDBLOCK) - break; -#endif -#endif -#endif =20 #ifndef WINDOWSNT if (xerrno =3D=3D EINTR) @@ -3366,7 +3343,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Obje= ct ip_addresses) BUF_ZV (XBUFFER (p->buffer)), BUF_ZV_BYTE (XBUFFER (p->buffer))); =20 -#ifdef NON_BLOCKING_CONNECT if (p->is_non_blocking_client) { /* We may get here if connect did succeed immediately. However, @@ -3381,7 +3357,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Obje= ct ip_addresses) } } else -#endif /* A server may have a client filter setting of Qt, but it must still listen for incoming connects unless it is stopped. */ if ((!EQ (p->filter, Qt) && !EQ (p->command, Qt)) @@ -3894,8 +3869,8 @@ usage: (make-network-process &rest ARGS) */) pset_command (p, Qt); p->pid =3D 0; p->backlog =3D 5; - p->is_non_blocking_client =3D 0; - p->is_server =3D 0; + p->is_non_blocking_client =3D false; + p->is_server =3D false; p->port =3D port; p->socktype =3D socktype; p->ai_protocol =3D ai_protocol; @@ -3918,21 +3893,15 @@ usage: (make-network-process &rest ARGS) */) { /* Don't support network sockets when non-blocking mode is not available, since a blocked Emacs is not useful. */ - p->is_server =3D 1; + p->is_server =3D true; if (TYPE_RANGED_INTEGERP (int, tem)) p->backlog =3D XINT (tem); } =20 /* :nowait BOOL */ if (!p->is_server && socktype !=3D SOCK_DGRAM - && (tem =3D Fplist_get (contact, QCnowait), !NILP (tem))) - { -#ifndef NON_BLOCKING_CONNECT - error ("Non-blocking connect not supported"); -#else - p->is_non_blocking_client =3D 1; -#endif - } + && !NILP (Fplist_get (contact, QCnowait))) + p->is_non_blocking_client =3D true; =20 #ifdef HAVE_GETADDRINFO_A /* With async address resolution, the list of addresses is empty, so @@ -4338,7 +4307,6 @@ deactivate_process (Lisp_Object proc) chan_process[inchannel] =3D Qnil; FD_CLR (inchannel, &input_wait_mask); FD_CLR (inchannel, &non_keyboard_wait_mask); -#ifdef NON_BLOCKING_CONNECT if (FD_ISSET (inchannel, &connect_wait_mask)) { FD_CLR (inchannel, &connect_wait_mask); @@ -4346,7 +4314,6 @@ deactivate_process (Lisp_Object proc) if (--num_pending_connects < 0) emacs_abort (); } -#endif if (inchannel =3D=3D max_process_desc) { /* We just closed the highest-numbered process input descriptor, @@ -4999,11 +4966,7 @@ wait_reading_process_output (intmax_t time_limit, = int nsecs, int read_kbd, timeout =3D make_timespec (0, 0); if ((pselect (max (max_process_desc, max_input_desc) + 1, &Atemp, -#ifdef NON_BLOCKING_CONNECT (num_pending_connects > 0 ? &Ctemp : NULL), -#else - NULL, -#endif NULL, &timeout, NULL) <=3D 0)) { @@ -5495,7 +5458,6 @@ wait_reading_process_output (intmax_t time_limit, i= nt nsecs, int read_kbd, list2 (Qexit, make_number (256))); } } -#ifdef NON_BLOCKING_CONNECT if (FD_ISSET (channel, &Writeok) && FD_ISSET (channel, &connect_wait_mask)) { @@ -5568,7 +5530,6 @@ wait_reading_process_output (intmax_t time_limit, i= nt nsecs, int read_kbd, } } } -#endif /* NON_BLOCKING_CONNECT */ } /* End for each file descriptor. */ } /* End while exit conditions not met. */ =20 @@ -7780,10 +7741,8 @@ init_process_emacs (void) max_process_desc =3D max_input_desc =3D -1; memset (fd_callback_info, 0, sizeof (fd_callback_info)); =20 -#ifdef NON_BLOCKING_CONNECT FD_ZERO (&connect_wait_mask); num_pending_connects =3D 0; -#endif =20 process_output_delay_count =3D 0; process_output_skip =3D 0; @@ -8036,9 +7995,7 @@ The variable takes effect when `start-process' is c= alled. */); #define ADD_SUBFEATURE(key, val) \ subfeatures =3D pure_cons (pure_cons (key, pure_cons (val, Qnil)), sub= features) =20 -#ifdef NON_BLOCKING_CONNECT ADD_SUBFEATURE (QCnowait, Qt); -#endif #ifdef DATAGRAM_SOCKETS ADD_SUBFEATURE (QCtype, Qdatagram); #endif --=20 2.5.5 --------------060409000100010007000409--