@@ -1301,45 +1301,56 @@ typedef enum
13011301 MODE_JS
13021302} ch_mode_T ;
13031303
1304- struct channel_S {
1305- channel_T * ch_next ;
1306- channel_T * ch_prev ;
1307-
1308- int ch_id ; /* ID of the channel */
1304+ /* Ordering matters: IN is last, only SOCK/OUT/ERR are polled */
13091305
1310- sock_T ch_sock ; /* the socket, -1 for a closed channel */
1306+ #define CHAN_SOCK 0
1307+ #define CH_SOCK ch_pfd[CHAN_SOCK].ch_fd
13111308
13121309#ifdef UNIX
13131310# define CHANNEL_PIPES
1314- int ch_in ; /* stdin of the job, -1 if not used */
1315- int ch_out ; /* stdout of the job, -1 if not used */
1316- int ch_err ; /* stderr of the job, -1 if not used */
13171311
1318- # if defined( UNIX ) && !defined( HAVE_SELECT )
1319- int ch_sock_idx ; /* used by channel_poll_setup() */
1320- int ch_in_idx ; /* used by channel_poll_setup() */
1321- int ch_out_idx ; /* used by channel_poll_setup() */
1322- int ch_err_idx ; /* used by channel_poll_setup() */
1323- # endif
1312+ # define CHAN_OUT 1
1313+ # define CHAN_ERR 2
1314+ # define CHAN_IN 3
1315+ # define CH_OUT ch_pfd[CHAN_OUT].ch_fd
1316+ # define CH_ERR ch_pfd[CHAN_ERR].ch_fd
1317+ # define CH_IN ch_pfd[CHAN_IN].ch_fd
13241318#endif
13251319
1326- readq_T ch_head ; /* dummy node, header for circular queue */
1320+ /* The per-fd info for a channel. */
1321+ typedef struct {
1322+ sock_T ch_fd ; /* socket/stdin/stdout/stderr, -1 if not used */
1323+
1324+ # if defined(UNIX ) && !defined(HAVE_SELECT )
1325+ int ch_poll_idx ; /* used by channel_poll_setup() */
1326+ # endif
13271327
1328- int ch_error ; /* When TRUE an error was reported. Avoids
1329- * giving pages full of error messages when
1330- * the other side has exited, only mention the
1331- * first error until the connection works
1332- * again. */
13331328#ifdef FEAT_GUI_X11
13341329 XtInputId ch_inputHandler ; /* Cookie for input */
13351330#endif
13361331#ifdef FEAT_GUI_GTK
13371332 gint ch_inputHandler ; /* Cookie for input */
13381333#endif
13391334#ifdef WIN32
1340- int ch_inputHandler ; /* simply ret.value of WSAAsyncSelect() */
1335+ int ch_inputHandler ; /* ret.value of WSAAsyncSelect() */
13411336#endif
1337+ } chan_fd_T ;
1338+
1339+ struct channel_S {
1340+ channel_T * ch_next ;
1341+ channel_T * ch_prev ;
1342+
1343+ int ch_id ; /* ID of the channel */
1344+
1345+ chan_fd_T ch_pfd [4 ]; /* info for socket, in, out and err */
13421346
1347+ readq_T ch_head ; /* dummy node, header for circular queue */
1348+
1349+ int ch_error ; /* When TRUE an error was reported. Avoids
1350+ * giving pages full of error messages when
1351+ * the other side has exited, only mention the
1352+ * first error until the connection works
1353+ * again. */
13431354 void (* ch_close_cb )(void ); /* callback for when channel is closed */
13441355
13451356 int ch_block_id ; /* ID that channel_read_json_block() is
0 commit comments