timeout is configurable

This commit is contained in:
Benjamin Sergeant
2019-01-03 18:33:08 -08:00
parent 3021ac4b95
commit bce5ef2dca
9 changed files with 54 additions and 24 deletions

View File

@ -182,6 +182,17 @@ namespace ix
else if (ret < 0 && (getErrno() == EWOULDBLOCK ||
getErrno() == EAGAIN))
{
// Wait with a timeout until something is written.
// This way we are not busy looping
fd_set rfds;
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 1 * 1000; // 1ms
FD_ZERO(&rfds);
FD_SET(_sockfd, &rfds);
select(_sockfd + 1, &rfds, nullptr, nullptr, &timeout);
continue;
}
// There was an error during the read, abort