diff src/structs.h @ 10259:a09db7a4afe0 v8.0.0027

commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 9 17:28:01 2016 +0200 patch 8.0.0027 Problem: A channel is closed when reading on stderr or stdout fails, but there may still be something to read on another part. Solution: Turn ch_to_be_closed into a bitfield. (Ozaki Kiichi)
author Christian Brabandt <cb@256bit.org>
date Sun, 09 Oct 2016 17:30:04 +0200
parents 65afd399ffa7
children 179794481db4
line wrap: on
line diff
--- a/src/structs.h
+++ b/src/structs.h
@@ -1499,19 +1499,21 @@ typedef enum {
 
 /* Ordering matters, it is used in for loops: IN is last, only SOCK/OUT/ERR
  * are polled. */
-#define PART_SOCK   0
+typedef enum {
+    PART_SOCK = 0,
 #define CH_SOCK_FD	ch_part[PART_SOCK].ch_fd
-
 #ifdef FEAT_JOB_CHANNEL
-# define INVALID_FD  (-1)
-
-# define PART_OUT   1
-# define PART_ERR   2
-# define PART_IN    3
+    PART_OUT,
 # define CH_OUT_FD	ch_part[PART_OUT].ch_fd
+    PART_ERR,
 # define CH_ERR_FD	ch_part[PART_ERR].ch_fd
+    PART_IN,
 # define CH_IN_FD	ch_part[PART_IN].ch_fd
 #endif
+    PART_COUNT
+} ch_part_T;
+
+#define INVALID_FD	(-1)
 
 /* The per-fd info for a channel. */
 typedef struct {
@@ -1566,14 +1568,14 @@ struct channel_S {
     int		ch_id;		/* ID of the channel */
     int		ch_last_msg_id;	/* ID of the last message */
 
-    chanpart_T	ch_part[4];	/* info for socket, out, err and in */
+    chanpart_T	ch_part[PART_COUNT]; /* info for socket, out, err and in */
 
     char	*ch_hostname;	/* only for socket, allocated */
     int		ch_port;	/* only for socket */
 
-    int		ch_to_be_closed; /* When TRUE reading or writing failed and
-				  * the channel must be closed when it's safe
-				  * to invoke callbacks. */
+    int		ch_to_be_closed; /* bitset of readable fds to be closed.
+				  * When all readable fds have been closed,
+				  * set to (1 << PART_COUNT). */
     int		ch_to_be_freed; /* When TRUE channel must be freed when it's
 				 * safe to invoke callbacks. */
     int		ch_error;	/* When TRUE an error was reported.  Avoids