#include <cynara-client-async.h>
#include <exception>
+#include <poll.h>
#include <unistd.h>
namespace CynaraTestClientAsync {
if (m_statusMonitor.getStatus() == DISCONNECTED)
return;
- int fd = m_statusMonitor.getFd();
- fd_set fds;
- timeval tv;
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
- tv.tv_sec = timeoutSeconds;
- tv.tv_usec = 0;
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wrestrict"
-
- int ret;
- if (m_statusMonitor.getStatus() == READ)
- ret = TEMP_FAILURE_RETRY(select(fd + 1, &fds, NULL, NULL, &tv));
- else
- ret = TEMP_FAILURE_RETRY(select(fd + 1, &fds, &fds, NULL, &tv));
+ pollfd fds[1];
+ fds->fd = m_statusMonitor.getFd();
+ fds->events = POLLIN | (m_statusMonitor.getStatus() == READ ? 0 : POLLOUT);
+ int ret = TEMP_FAILURE_RETRY(poll(fds, 1, timeoutSeconds * 1000));
if (ret == 0) {
RUNNER_ASSERT_MSG(timeoutExpectation != EXPECT_NO_TIMEOUT,
- "Unexpected select timeout."
+ "Unexpected poll timeout."
<< " ret = " << ret);
return;
}
-#pragma GCC diagnostic push
RUNNER_ASSERT_ERRNO_MSG(ret > 0,
- "Select returned error:"
+ "Poll returned error:"
<< " ret = " << ret);
RUNNER_ASSERT_MSG(timeoutExpectation != EXPECT_TIMEOUT,
- "Select returned positive value, when timeout was expected."
+ "Poll returned positive value, when timeout was expected."
<< " ret = " << ret);
RUNNER_DEFER_SCOPE(ret = cynara_async_process(m_cynara););