mirror of
https://github.com/NixOS/nix
synced 2024-09-19 10:50:24 -04:00
select() -> poll() for Windows compat
This commit is contained in:
parent
ce7cf4a2d3
commit
270c8469d7
|
@ -165,15 +165,20 @@ bool FdSource::hasData()
|
||||||
if (BufferedSource::hasData()) return true;
|
if (BufferedSource::hasData()) return true;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
struct pollfd fds[1];
|
fd_set fds;
|
||||||
fds[0].fd = fd;
|
FD_ZERO(&fds);
|
||||||
fds[0].events = POLLIN;
|
FD_SET(fd, &fds);
|
||||||
auto n = poll(fds, 1, 0);
|
|
||||||
|
struct timeval timeout;
|
||||||
|
timeout.tv_sec = 0;
|
||||||
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
|
auto n = select(fd + 1, &fds, nullptr, nullptr, &timeout);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if (errno == EINTR) continue;
|
if (errno == EINTR) continue;
|
||||||
throw SysError("polling file descriptor");
|
throw SysError("polling file descriptor");
|
||||||
}
|
}
|
||||||
return n == 1 && (fds[0].events & POLLIN);
|
return FD_ISSET(fd, &fds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue