ts.tv_sec = timeout / 1000;
ts.tv_nsec = (timeout % 1000) * 1000000;
- int ret = kevent(d_kqueuefd, 0, 0, d_kevents.data(), d_kevents.size(), &ts);
+ int ret = kevent(d_kqueuefd, 0, 0, d_kevents.data(), d_kevents.size(), timeout != -1 ? &ts : nullptr);
if (ret < 0 && errno != EINTR) {
throw FDMultiplexerException("kqueue returned error: " + stringerror());
ts.tv_sec = timeout / 1000;
ts.tv_nsec = (timeout % 1000) * 1000000;
- int ret = kevent(d_kqueuefd, 0, 0, d_kevents.data(), d_kevents.size(), &ts);
+ int ret = kevent(d_kqueuefd, 0, 0, d_kevents.data(), d_kevents.size(), timeout != -1 ? &ts : nullptr);
gettimeofday(now, nullptr); // MANDATORY!
if (ret < 0 && errno != EINTR) {
static FDMultiplexer* getMultiplexerSilent(unsigned int maxEventsHint = s_maxevents);
/* tv will be updated to 'now' before run returns */
- /* timeout is in ms */
+ /* timeout is in ms, 0 will return immediately, -1 will block until at
+ least one descriptor is ready */
/* returns 0 on timeout, -1 in case of error (but all implementations
actually throw in that case) and the number of ready events otherwise.
Note that We might have two events (read AND write) for the same descriptor */
timeoutspec.tv_sec = timeout / 1000;
timeoutspec.tv_nsec = (timeout % 1000) * 1000000;
unsigned int numevents = 1;
- int ret = port_getn(d_portfd, d_pevents.data(), min(PORT_MAX_LIST, static_cast<int>(d_pevents.size())), &numevents, &timeoutspec);
+ int ret = port_getn(d_portfd, d_pevents.data(), min(PORT_MAX_LIST, static_cast<int>(d_pevents.size())), &numevents, timeout != -1 ? &timeoutspec : nullptr);
/* port_getn has an unusual API - (ret == -1, errno == ETIME) can
mean partial success; you must check (*numevents) in this case
timeoutspec.tv_sec = timeout / 1000;
timeoutspec.tv_nsec = (timeout % 1000) * 1000000;
unsigned int numevents = 1;
- int ret = port_getn(d_portfd, d_pevents.data(), min(PORT_MAX_LIST, static_cast<int>(d_pevents.size())), &numevents, &timeoutspec);
+ int ret = port_getn(d_portfd, d_pevents.data(), min(PORT_MAX_LIST, static_cast<int>(d_pevents.size())), &numevents, timeout != -1 ? &timeoutspec : nullptr);
/* port_getn has an unusual API - (ret == -1, errno == ETIME) can
mean partial success; you must check (*numevents) in this case
BOOST_REQUIRE_EQUAL(readyFDs.size(), 1U);
BOOST_CHECK_EQUAL(readyFDs.at(0), pipes[1]);
- ready = mplexer->run(&now, 100);
+ /* wait until we have at least one descriptor ready */
+ ready = mplexer->run(&now, -1);
BOOST_CHECK_EQUAL(ready, 1);
BOOST_CHECK_EQUAL(writeCBCalled, true);