X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fcompat-poll.c;h=b45b39dc6bdbd45daf69944316b1d663f1744867;hb=18710679a8ac57fda5dbd26cf16bb180dce9e286;hp=7d4d0e1334ef1dc2abba28f9e694d2ce8052d1ea;hpb=c607fe035ea8821a8f4c6ab6f3467ec726e36a63;p=lttng-tools.git diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c index 7d4d0e133..b45b39dc6 100644 --- a/src/common/compat/compat-poll.c +++ b/src/common/compat/compat-poll.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -196,6 +197,42 @@ error: return -1; } +/* + * Modify an fd's events.. + */ +int compat_poll_mod(struct lttng_poll_event *events, int fd, + uint32_t req_events) +{ + int 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. */