@@ -3589,6 +3589,24 @@ channel_free_all(void)
35893589// Buffer size for reading incoming messages.
35903590#define MAXMSGSIZE 4096
35913591
3592+ /*
3593+ * Check if there are remaining data that should be written for "in_part".
3594+ */
3595+ static int
3596+ is_channel_write_remaining (chanpart_T * in_part )
3597+ {
3598+ buf_T * buf = in_part -> ch_bufref .br_buf ;
3599+
3600+ if (in_part -> ch_writeque .wq_next != NULL )
3601+ return TRUE;
3602+ if (buf == NULL )
3603+ return FALSE;
3604+ return in_part -> ch_buf_append
3605+ ? (in_part -> ch_buf_bot < buf -> b_ml .ml_line_count )
3606+ : (in_part -> ch_buf_top <= in_part -> ch_buf_bot
3607+ && in_part -> ch_buf_top <= buf -> b_ml .ml_line_count );
3608+ }
3609+
35923610#if defined(HAVE_SELECT )
35933611/*
35943612 * Add write fds where we are waiting for writing to be possible.
@@ -3604,8 +3622,7 @@ channel_fill_wfds(int maxfd_arg, fd_set *wfds)
36043622 chanpart_T * in_part = & ch -> ch_part [PART_IN ];
36053623
36063624 if (in_part -> ch_fd != INVALID_FD
3607- && (in_part -> ch_bufref .br_buf != NULL
3608- || in_part -> ch_writeque .wq_next != NULL ))
3625+ && is_channel_write_remaining (in_part ))
36093626 {
36103627 FD_SET ((int )in_part -> ch_fd , wfds );
36113628 if ((int )in_part -> ch_fd >= maxfd )
@@ -3629,8 +3646,7 @@ channel_fill_poll_write(int nfd_in, struct pollfd *fds)
36293646 chanpart_T * in_part = & ch -> ch_part [PART_IN ];
36303647
36313648 if (in_part -> ch_fd != INVALID_FD
3632- && (in_part -> ch_bufref .br_buf != NULL
3633- || in_part -> ch_writeque .wq_next != NULL ))
3649+ && is_channel_write_remaining (in_part ))
36343650 {
36353651 in_part -> ch_poll_idx = nfd ;
36363652 fds [nfd ].fd = in_part -> ch_fd ;
@@ -3865,8 +3881,6 @@ channel_read(channel_T *channel, ch_part_T part, char *func)
38653881 // Store the read message in the queue.
38663882 channel_save (channel , part , buf , len , FALSE, "RECV " );
38673883 readlen += len ;
3868- if (len < MAXMSGSIZE )
3869- break ; // did read everything that's available
38703884 }
38713885
38723886 // Reading a disconnection (readlen == 0), or an error.
0 commit comments