socket polling / handle more error case such as hanged socket

This commit is contained in:
Benjamin Sergeant 2020-01-09 12:26:57 -08:00
parent a844dbc587
commit ce9db42c23

View File

@ -54,11 +54,12 @@ namespace ix
// to ::poll does fix that.
//
// However poll isn't as portable as select and has bugs on Windows, so we
// should write a shim to fallback to select on those platforms. See
// have a shim to fallback to select on those platforms. See
// https://github.com/mpv-player/mpv/pull/5203/files for such a select wrapper.
//
nfds_t nfds = 1;
struct pollfd fds[2];
memset(fds, 0 , sizeof(fds));
fds[0].fd = sockfd;
fds[0].events = (readyToRead) ? POLLIN : POLLOUT;
@ -132,6 +133,10 @@ namespace ix
}
#endif
}
else if (sockfd != -1 && (fds[0].revents & POLLERR || fds[0].revents & POLLHUP))
{
pollResult = PollResultType::Error;
}
return pollResult;
}