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)
diff --git a/src/structs.h b/src/structs.h
index 2a4284a..7a4d7fb 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1499,19 +1499,21 @@
/* 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 @@
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