all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: 22946-done@debbugs.gnu.org
Subject: bug#22946: 25.1.50; NON_BLOCKING_CONNECT is obsolete
Date: Tue, 22 Mar 2016 01:21:18 -0700	[thread overview]
Message-ID: <56F1007E.20204@cs.ucla.edu> (raw)
In-Reply-To: <m3egbkj2be.fsf@gnus.org>

[-- Attachment #1: Type: text/plain, Size: 64 bytes --]

I installed the attached patch, to assume NON_BLOCKING_CONNECT.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Assume-NON_BLOCKING_CONNECT-Bug-22946.patch --]
[-- Type: text/x-diff; name="0001-Assume-NON_BLOCKING_CONNECT-Bug-22946.patch", Size: 7890 bytes --]

From d8c3ca9353343726b202e260bca0fd03e298578f Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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=UTF-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’s defined.
(connect_network_socket): Assume EINPROGRESS is defined,
as that’s 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;
 
-/* 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;
 
 static fd_set write_mask;
 
-#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;
 
 /* Number of bits set in connect_wait_mask.  */
 static int num_pending_connects;
-#endif	/* NON_BLOCKING_CONNECT */
 
 /* The largest descriptor currently in use for a process object; -1 if none.  */
 static int max_process_desc;
@@ -3133,7 +3121,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
 	break;
 #endif /* DATAGRAM_SOCKETS */
 
-#ifdef NON_BLOCKING_CONNECT
       if (p->is_non_blocking_client)
 	{
 	  ret = fcntl (s, F_SETFL, O_NONBLOCK);
@@ -3145,7 +3132,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
 	      continue;
 	    }
 	}
-#endif
 
       /* 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_Object ip_addresses)
 	  break;
 	}
 
-#ifdef NON_BLOCKING_CONNECT
-#ifdef EINPROGRESS
       if (p->is_non_blocking_client && xerrno == EINPROGRESS)
 	break;
-#else
-#ifdef EWOULDBLOCK
-      if (p->is_non_blocking_client && xerrno == EWOULDBLOCK)
-	break;
-#endif
-#endif
-#endif
 
 #ifndef WINDOWSNT
       if (xerrno == EINTR)
@@ -3366,7 +3343,6 @@ connect_network_socket (Lisp_Object proc, Lisp_Object ip_addresses)
 		     BUF_ZV (XBUFFER (p->buffer)),
 		     BUF_ZV_BYTE (XBUFFER (p->buffer)));
 
-#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_Object 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 = 0;
   p->backlog = 5;
-  p->is_non_blocking_client = 0;
-  p->is_server = 0;
+  p->is_non_blocking_client = false;
+  p->is_server = false;
   p->port = port;
   p->socktype = socktype;
   p->ai_protocol = 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 = 1;
+      p->is_server = true;
       if (TYPE_RANGED_INTEGERP (int, tem))
 	p->backlog = XINT (tem);
     }
 
   /* :nowait BOOL */
   if (!p->is_server && socktype != SOCK_DGRAM
-      && (tem = Fplist_get (contact, QCnowait), !NILP (tem)))
-    {
-#ifndef NON_BLOCKING_CONNECT
-      error ("Non-blocking connect not supported");
-#else
-      p->is_non_blocking_client = 1;
-#endif
-    }
+      && !NILP (Fplist_get (contact, QCnowait)))
+    p->is_non_blocking_client = true;
 
 #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] = 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 == 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 = 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)
 	       <= 0))
 	    {
@@ -5495,7 +5458,6 @@ wait_reading_process_output (intmax_t time_limit, int 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, int nsecs, int read_kbd,
 		    }
 		}
 	    }
-#endif /* NON_BLOCKING_CONNECT */
 	}			/* End for each file descriptor.  */
     }				/* End while exit conditions not met.  */
 
@@ -7780,10 +7741,8 @@ init_process_emacs (void)
   max_process_desc = max_input_desc = -1;
   memset (fd_callback_info, 0, sizeof (fd_callback_info));
 
-#ifdef NON_BLOCKING_CONNECT
   FD_ZERO (&connect_wait_mask);
   num_pending_connects = 0;
-#endif
 
   process_output_delay_count = 0;
   process_output_skip = 0;
@@ -8036,9 +7995,7 @@ The variable takes effect when `start-process' is called.  */);
 #define ADD_SUBFEATURE(key, val) \
   subfeatures = pure_cons (pure_cons (key, pure_cons (val, Qnil)), subfeatures)
 
-#ifdef NON_BLOCKING_CONNECT
    ADD_SUBFEATURE (QCnowait, Qt);
-#endif
 #ifdef DATAGRAM_SOCKETS
    ADD_SUBFEATURE (QCtype, Qdatagram);
 #endif
-- 
2.5.5


  parent reply	other threads:[~2016-03-22  8:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08 17:40 bug#22946: 25.1.50; NON_BLOCKING_CONNECT is obsolete Lars Magne Ingebrigtsen
2016-03-08 17:48 ` Eli Zaretskii
2016-03-08 17:51   ` Lars Magne Ingebrigtsen
2016-03-08 17:56     ` Eli Zaretskii
2016-03-22  8:21 ` Paul Eggert [this message]
2016-03-22 16:10   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56F1007E.20204@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=22946-done@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.