Introduce select_wrapper_t

select_wrapper_t wraps up the annoying bits of using select(): keeping
track of the max fd, passing null for boring parameters, and
constructing the timeout. Introduce a wrapper struct for this and
replace the existing uses of select() with the wrapper.
This commit is contained in:
ridiculousfish
2021-04-10 16:45:26 -07:00
parent 0dd24c8f74
commit e8a61ef4aa
11 changed files with 119 additions and 99 deletions

View File

@@ -1437,12 +1437,7 @@ class universal_notifier_named_pipe_t final : public universal_notifier_t {
// We are polling, so we are definitely going to sync.
// See if this is still readable.
fd_set fds;
FD_ZERO(&fds);
FD_SET(pipe_fd.fd(), &fds);
struct timeval timeout = {};
select(pipe_fd.fd() + 1, &fds, nullptr, nullptr, &timeout);
if (!FD_ISSET(pipe_fd.fd(), &fds)) {
if (!select_wrapper_t::poll_fd_readable(pipe_fd.fd())) {
// No longer readable, no longer polling.
polling_due_to_readable_fd = false;
drain_if_still_readable_time_usec = 0;