X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Fcompat-poll.c;h=b45b39dc6bdbd45daf69944316b1d663f1744867;hb=8a2827515ad2b019753b84bcc3cb726af4ae428d;hp=32bcce8e4643fdf2c3d858da9273147537a39a06;hpb=dbe23f452a025e8f42bdbb41e30a4a6257aa821c;p=lttng-tools.git diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c index 32bcce8e4..b45b39dc6 100644 --- a/src/common/compat/compat-poll.c +++ b/src/common/compat/compat-poll.c @@ -15,12 +15,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include #include #include +#include #include #include @@ -112,8 +112,9 @@ int compat_poll_create(struct lttng_poll_event *events, int size) } if (!poll_max_size) { - ERR("poll_max_size not initialized yet"); - goto error; + if (lttng_poll_set_max_size()) { + goto error; + } } /* Don't bust the limit here */ @@ -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. */ @@ -269,7 +306,9 @@ int compat_poll_wait(struct lttng_poll_event *events, int timeout) } } - ret = poll(events->wait.events, events->wait.nb_fd, timeout); + do { + ret = poll(events->wait.events, events->wait.nb_fd, timeout); + } while (ret == -1 && errno == EINTR); if (ret < 0) { /* At this point, every error is fatal */ PERROR("poll wait");