#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <stdbool.h>
#include <common/error.h>
#include <common/defaults.h>
/*
* Wait on epoll set. This is a blocking call of timeout value.
*/
-int compat_epoll_wait(struct lttng_poll_event *events, int timeout)
+int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
+ bool interruptible)
{
int ret;
uint32_t new_size;
do {
ret = epoll_wait(events->epfd, events->events, events->nb_fd, timeout);
- } while (ret == -1 && errno == EINTR);
+ } while (!interruptible && ret == -1 && errno == EINTR);
if (ret < 0) {
- /* At this point, every error is fatal */
- PERROR("epoll_wait");
+ if (errno != EINTR) {
+ PERROR("epoll_wait");
+ }
goto error;
}
/*
* Wait on poll() with timeout. Blocking call.
*/
-int compat_poll_wait(struct lttng_poll_event *events, int timeout)
+int compat_poll_wait(struct lttng_poll_event *events, int timeout,
+ bool interruptible)
{
int ret, active_fd_count;
int idle_pfd_index = 0;
do {
ret = poll(events->wait.events, events->wait.nb_fd, timeout);
- } while (ret == -1 && errno == EINTR);
+ } while (!interruptible && ret == -1 && errno == EINTR);
if (ret < 0) {
- /* At this point, every error is fatal */
- PERROR("poll wait");
+ if (errno != EINTR) {
+ PERROR("poll wait");
+ }
goto error;
}
* Wait on epoll set with the number of fd registered to the lttng_poll_event
* data structure (events).
*/
-extern int compat_epoll_wait(struct lttng_poll_event *events, int timeout);
+extern int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
+ bool interruptible);
#define lttng_poll_wait(events, timeout) \
- compat_epoll_wait(events, timeout)
+ compat_epoll_wait(events, timeout, false)
+#define lttng_poll_wait_interruptible(events, timeout) \
+ compat_epoll_wait(events, timeout, true)
/*
* Add a fd to the epoll set and resize the epoll_event structure if needed.
* Wait on poll(2) event with nb_fd registered to the lttng_poll_event data
* structure.
*/
-extern int compat_poll_wait(struct lttng_poll_event *events, int timeout);
+extern int compat_poll_wait(struct lttng_poll_event *events, int timeout,
+ bool interruptible);
#define lttng_poll_wait(events, timeout) \
- compat_poll_wait(events, timeout)
+ compat_poll_wait(events, timeout, false)
+#define lttng_poll_wait_interruptible(events, timeout) \
+ compat_poll_wait(events, timeout, true)
/*
* Add the fd to the pollfd structure. Resize if needed.