Don't throw an exception if epoll_wait is interrupted

This commit is contained in:
Fred Nicolson 2018-11-19 16:02:07 +00:00
parent 252a4788b5
commit 697573cbaf
2 changed files with 6 additions and 1 deletions

View File

@ -39,7 +39,8 @@ namespace fr
*
* @throws An std::exception on failure
* @param timeout The maximum time in milliseconds to wait for. Default/-1 for no timeout.
* @return A list of sockets which either are ready, or have disconnected.
* @return A list of sockets which either are ready, or have disconnected. This can be empty
* if there is a timeout, or the wait is interrupted.
*/
std::vector<std::pair<std::shared_ptr<fr::SocketDescriptor>, void*>> wait(std::chrono::milliseconds timeout = std::chrono::milliseconds(-1));

View File

@ -57,6 +57,10 @@ namespace fr
int event_count = epoll_wait(epoll_fd, events, 100, timeout.count());
if(event_count < 0)
{
if(errno == EINTR)
{
return {};
}
throw std::runtime_error("epoll_wait returned: " + std::to_string(errno));
}