* [PATCH lttng-tools 1/3] epoll/poll compat: expose interruptible API
@ 2019-05-16 19:08 Mathieu Desnoyers
0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2019-05-16 19:08 UTC (permalink / raw)
To: jgalar, joraj; +Cc: lttng-dev
Some use of the epoll/poll wrapper require interruption
by signals to make the poll call return -1, errno EINTR.
Expose a new lttng_poll_wait_interruptible API for this
purpose.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
---
src/common/compat/compat-epoll.c | 9 +++++----
src/common/compat/compat-poll.c | 9 +++++----
src/common/compat/poll.h | 12 ++++++++----
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/common/compat/compat-epoll.c b/src/common/compat/compat-epoll.c
index 6a781c7a..7108b717 100644
--- a/src/common/compat/compat-epoll.c
+++ b/src/common/compat/compat-epoll.c
@@ -241,7 +241,7 @@ error:
/*
* 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, int interruptible)
{
int ret;
uint32_t new_size;
@@ -273,10 +273,11 @@ int compat_epoll_wait(struct lttng_poll_event *events, int timeout)
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;
}
diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c
index 0220b278..dc507db5 100644
--- a/src/common/compat/compat-poll.c
+++ b/src/common/compat/compat-poll.c
@@ -291,7 +291,7 @@ 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, int interruptible)
{
int ret, active_fd_count;
int idle_pfd_index = 0;
@@ -320,10 +320,11 @@ int compat_poll_wait(struct lttng_poll_event *events, int timeout)
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;
}
diff --git a/src/common/compat/poll.h b/src/common/compat/poll.h
index d7020f36..da7d6970 100644
--- a/src/common/compat/poll.h
+++ b/src/common/compat/poll.h
@@ -152,9 +152,11 @@ static inline int compat_glibc_epoll_create(int size, int flags)
* 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, int interruptible);
#define lttng_poll_wait(events, timeout) \
- compat_epoll_wait(events, timeout)
+ compat_epoll_wait(events, timeout, 0)
+#define lttng_poll_wait_interruptible(events, timeout) \
+ compat_epoll_wait(events, timeout, 1)
/*
* Add a fd to the epoll set and resize the epoll_event structure if needed.
@@ -336,9 +338,11 @@ extern int compat_poll_create(struct lttng_poll_event *events, int size);
* 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, int interruptible);
#define lttng_poll_wait(events, timeout) \
- compat_poll_wait(events, timeout)
+ compat_poll_wait(events, timeout, 0)
+#define lttng_poll_wait_interruptible(events, timeout) \
+ compat_poll_wait(events, timeout, 1)
/*
* Add the fd to the pollfd structure. Resize if needed.
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH lttng-tools 1/3] epoll/poll compat: expose interruptible API
[not found] <20190516190852.16946-1-mathieu.desnoyers@efficios.com>
@ 2019-09-05 20:57 ` Jérémie Galarneau
0 siblings, 0 replies; 2+ messages in thread
From: Jérémie Galarneau @ 2019-09-05 20:57 UTC (permalink / raw)
To: Mathieu Desnoyers; +Cc: lttng-dev, jgalar, joraj
Series merged in master and stable-2.11.
Thanks,
Jérémie
On Thu, May 16, 2019 at 03:08:50PM -0400, Mathieu Desnoyers wrote:
> Some use of the epoll/poll wrapper require interruption
> by signals to make the poll call return -1, errno EINTR.
> Expose a new lttng_poll_wait_interruptible API for this
> purpose.
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> ---
> src/common/compat/compat-epoll.c | 9 +++++----
> src/common/compat/compat-poll.c | 9 +++++----
> src/common/compat/poll.h | 12 ++++++++----
> 3 files changed, 18 insertions(+), 12 deletions(-)
>
> diff --git a/src/common/compat/compat-epoll.c b/src/common/compat/compat-epoll.c
> index 6a781c7a..7108b717 100644
> --- a/src/common/compat/compat-epoll.c
> +++ b/src/common/compat/compat-epoll.c
> @@ -241,7 +241,7 @@ error:
> /*
> * 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, int interruptible)
> {
> int ret;
> uint32_t new_size;
> @@ -273,10 +273,11 @@ int compat_epoll_wait(struct lttng_poll_event *events, int timeout)
>
> 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;
> }
>
> diff --git a/src/common/compat/compat-poll.c b/src/common/compat/compat-poll.c
> index 0220b278..dc507db5 100644
> --- a/src/common/compat/compat-poll.c
> +++ b/src/common/compat/compat-poll.c
> @@ -291,7 +291,7 @@ 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, int interruptible)
> {
> int ret, active_fd_count;
> int idle_pfd_index = 0;
> @@ -320,10 +320,11 @@ int compat_poll_wait(struct lttng_poll_event *events, int timeout)
>
> 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;
> }
>
> diff --git a/src/common/compat/poll.h b/src/common/compat/poll.h
> index d7020f36..da7d6970 100644
> --- a/src/common/compat/poll.h
> +++ b/src/common/compat/poll.h
> @@ -152,9 +152,11 @@ static inline int compat_glibc_epoll_create(int size, int flags)
> * 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, int interruptible);
> #define lttng_poll_wait(events, timeout) \
> - compat_epoll_wait(events, timeout)
> + compat_epoll_wait(events, timeout, 0)
> +#define lttng_poll_wait_interruptible(events, timeout) \
> + compat_epoll_wait(events, timeout, 1)
>
> /*
> * Add a fd to the epoll set and resize the epoll_event structure if needed.
> @@ -336,9 +338,11 @@ extern int compat_poll_create(struct lttng_poll_event *events, int size);
> * 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, int interruptible);
> #define lttng_poll_wait(events, timeout) \
> - compat_poll_wait(events, timeout)
> + compat_poll_wait(events, timeout, 0)
> +#define lttng_poll_wait_interruptible(events, timeout) \
> + compat_poll_wait(events, timeout, 1)
>
> /*
> * Add the fd to the pollfd structure. Resize if needed.
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-05 20:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16 19:08 [PATCH lttng-tools 1/3] epoll/poll compat: expose interruptible API Mathieu Desnoyers
[not found] <20190516190852.16946-1-mathieu.desnoyers@efficios.com>
2019-09-05 20:57 ` Jérémie Galarneau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).