Commit b4029eaf authored by Scott Vokes's avatar Scott Vokes
Browse files

Handle poll(fds, 1, -1) returning 0 safely, not with an assert.

This should never return 0, but we're seeing it happen on OSX (with an errno of
ETIMEDOUT). We can safely handle it by logging, resetting errno, and resuming
polling, so we should.
parent ecaa60eb
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -104,9 +104,12 @@ bool BusPoll_OnCompletion(struct bus *b, int fd) {
                return false;
            }
        } else {
            BUS_LOG_SNPRINTF(b, 0, LOG_SENDING_REQUEST, b->udata, 64,
                "poll_on_completion, blocking forever returned 0, errno %d", errno);
            assert(false);
            /* This should never happen, but I have seen it occur on OSX.
             * If we log it, reset errno, and continue, it does not appear
             * to fall into busywaiting by always returning 0. */
            BUS_LOG_SNPRINTF(b, 1, LOG_SENDING_REQUEST, b->udata, 64,
                "poll_on_completion, blocking forever returned %d, errno %d", res, errno);
            errno = 0;
        }
    }
}