return -1;
}
+/*
+ * Set an fd's events.
+ */
+int compat_epoll_mod(struct lttng_poll_event *events, int fd, uint32_t req_events)
+{
+ int ret;
+ struct epoll_event ev;
+
+ if (events == NULL || fd < 0 || events->nb_fd == 0) {
+ goto error;
+ }
+
+ /*
+ * Zero struct epoll_event to ensure all representations of its
+ * union are zeroed.
+ */
+ memset(&ev, 0, sizeof(ev));
+ ev.events = req_events;
+ ev.data.fd = fd;
+
+ ret = epoll_ctl(events->epfd, EPOLL_CTL_MOD, fd, &ev);
+ if (ret < 0) {
+ switch (errno) {
+ case ENOENT:
+ case EPERM:
+ /* Print PERROR and goto end not failing. Show must go on. */
+ PERROR("epoll_ctl MOD");
+ goto end;
+ default:
+ PERROR("epoll_ctl MOD fatal");
+ goto error;
+ }
+ }
+
+end:
+ return 0;
+
+error:
+ return -1;
+}
+
/*
* Wait on epoll set. This is a blocking call of timeout value.
*/
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/time.h>
+#include <stdbool.h>
#include <common/defaults.h>
#include <common/error.h>
return -1;
}
+/*
+ * Modify an fd's events..
+ */
+int compat_poll_mod(struct lttng_poll_event *events, int fd,
+ uint32_t req_events)
+{
+ int ret, i;
+ bool fd_found = false;
+ struct compat_poll_event_array *current;
+
+ if (events == NULL || events->current.events == NULL || fd < 0) {
+ ERR("Bad compat poll mod arguments");
+ goto error;
+ }
+
+ current = &events->current;
+
+ for (i = 0; i < current->nb_fd; i++) {
+ if (current->events[i].fd == fd) {
+ fd_found = true;
+ current->events[i].events = req_events;
+ events->need_update = 1;
+ break;
+ }
+ }
+
+ if (!fd_found) {
+ goto error;
+ }
+
+ return 0;
+
+error:
+ return -1;
+}
+
/*
* Remove a fd from the pollfd structure.
*/
#define lttng_poll_del(events, fd) \
compat_epoll_del(events, fd)
+/*
+ * Modify an fd's events in the epoll set.
+ */
+extern int compat_epoll_mod(struct lttng_poll_event *events,
+ int fd, uint32_t req_events);
+#define lttng_poll_mod(events, fd, req_events) \
+ compat_epoll_add(events, fd, req_events)
+
/*
* Set up the poll set limits variable poll_max_size
*/
#define lttng_poll_del(events, fd) \
compat_poll_del(events, fd)
+/*
+ * Modify an fd's events in the epoll set.
+ */
+extern int compat_poll_mod(struct lttng_poll_event *events,
+ int fd, uint32_t req_events);
+#define lttng_poll_mod(events, fd, req_events) \
+ compat_poll_add(events, fd, req_events)
+
/*
* Set up the poll set limits variable poll_max_size
*/