Check socket using select prior to call channel_read

This commit is contained in:
Kazuki Sakamoto
2016-06-06 23:17:46 -07:00
parent 6de757a83c
commit 4b15c68164
+8 -1
View File
@@ -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