summaryrefslogtreecommitdiff
path: root/src/structs.h
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-10-09 17:28:01 +0200
committerBram Moolenaar <Bram@vim.org>2016-10-09 17:28:01 +0200
commitdc0ccaee68ca24d10050117fbec757ad33590a17 (patch)
tree8a98b130b1cd6b91b209c8163220da3f6c5ae440 /src/structs.h
parent9b4579481892a62e7e002498b9eddaaf75bbda49 (diff)
downloadvim-git-dc0ccaee68ca24d10050117fbec757ad33590a17.tar.gz
patch 8.0.0027v8.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)
Diffstat (limited to 'src/structs.h')
-rw-r--r--src/structs.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/structs.h b/src/structs.h
index 2a4284ac5..7a4d7fbe4 100644
--- 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