From 4b15c681647b59979a9ede515083fa7974e4e8df Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Mon, 6 Jun 2016 23:17:46 -0700 Subject: [PATCH] Check socket using select prior to call channel_read --- src/MacVim/MMBackend.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index 7ecdc2d61a..1e8d26e35b 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -3463,7 +3463,14 @@ static void socketReadCallback(CFSocketRef s, - (void)read { - channel_read(channel, part, "MMChannel_read"); + int fd = channel->ch_part[part].ch_fd; + fd_set fds; + FD_ZERO(&fds); + FD_SET(fd, &fds); + struct timeval t; + memset(&t, 0, sizeof(t)); + if (select(FD_SETSIZE, &fds, NULL, NULL, &t) > 0) + channel_read(channel, part, "MMChannel_read"); } @end