X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fcompat-epoll.c;h=6a781c7ae04034f321f974c244df6e43e01e58b3;hb=18710679a8ac57fda5dbd26cf16bb180dce9e286;hp=9c2688d33e09c3c774b914b366226424504324e7;hpb=22dad56815ce0201c5ae7d5ef5d79cc0c6a42c5e;p=lttng-tools.git diff --git a/src/common/compat/compat-epoll.c b/src/common/compat/compat-epoll.c index 9c2688d33..6a781c7ae 100644 --- a/src/common/compat/compat-epoll.c +++ b/src/common/compat/compat-epoll.c @@ -197,6 +197,47 @@ error: 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. */ @@ -260,7 +301,15 @@ int compat_epoll_set_max_size(void) fd = open(COMPAT_EPOLL_PROC_PATH, O_RDONLY); if (fd < 0) { - retval = -1; + /* + * Failing on opening [1] is not an error per see. [1] was + * introduced in Linux 2.6.28 but epoll is available since + * 2.5.44. Hence, goto end and set a default value without + * setting an error return value. + * + * [1] /proc/sys/fs/epoll/max_user_watches + */ + retval = 0; goto end; }