From 3628d5bd420ccb6e7937506a2dbadb95bd3d2d0b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 5 Jan 2015 16:43:07 -0500 Subject: [PATCH] Fix: poll: show the correct number of fds MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit LTTNG_POLL_GETNB() uses wait nb_fd, which is only updated after lttng_poll_wait returns. Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau Conflicts: src/bin/lttng-sessiond/ht-cleanup.c Conflicts: src/bin/lttng-sessiond/jul-thread.c --- src/bin/lttng-sessiond/ht-cleanup.c | 5 +++-- src/bin/lttng-sessiond/jul-thread.c | 5 +++-- src/bin/lttng-sessiond/main.c | 8 ++++++-- src/bin/lttng-sessiond/ust-thread.c | 5 +++-- src/common/consumer.c | 10 ++++++++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/bin/lttng-sessiond/ht-cleanup.c b/src/bin/lttng-sessiond/ht-cleanup.c index f343d620b..57d6aec11 100644 --- a/src/bin/lttng-sessiond/ht-cleanup.c +++ b/src/bin/lttng-sessiond/ht-cleanup.c @@ -60,13 +60,14 @@ void *thread_ht_cleanup(void *data) health_code_update(); while (1) { - DBG3("[ht-thread] Polling on %d fds.", - LTTNG_POLL_GETNB(&events)); + DBG3("[ht-thread] Polling."); /* Inifinite blocking call, waiting for transmission */ restart: health_poll_entry(); ret = lttng_poll_wait(&events, -1); + DBG3("[ht-thread] Returning from poll on %d fds.", + LTTNG_POLL_GETNB(&events)); health_poll_exit(); if (ret < 0) { /* diff --git a/src/bin/lttng-sessiond/jul-thread.c b/src/bin/lttng-sessiond/jul-thread.c index d6f07d869..ff6832f9f 100644 --- a/src/bin/lttng-sessiond/jul-thread.c +++ b/src/bin/lttng-sessiond/jul-thread.c @@ -284,12 +284,13 @@ void *jul_thread_manage_registration(void *data) } while (1) { - DBG3("[jul-thread] Manage JUL polling on %d fds", - LTTNG_POLL_GETNB(&events)); + DBG3("[jul-thread] Manage JUL polling"); /* Inifinite blocking call, waiting for transmission */ restart: ret = lttng_poll_wait(&events, -1); + DBG3("[jul-thread] Manage agent return from poll on %d fds", + LTTNG_POLL_GETNB(&events)); if (ret < 0) { /* * Restart interrupted system call. diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index cc880bacf..2cf749a50 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -999,12 +999,14 @@ static void *thread_manage_kernel(void *data) update_poll_flag = 0; } - DBG("Thread kernel polling on %d fds", LTTNG_POLL_GETNB(&events)); + DBG("Thread kernel polling"); /* Poll infinite value of time */ restart: health_poll_entry(); ret = lttng_poll_wait(&events, -1); + DBG("Thread kernel return from poll on %d fds", + LTTNG_POLL_GETNB(&events)); health_poll_exit(); if (ret < 0) { /* @@ -1467,12 +1469,14 @@ static void *thread_manage_apps(void *data) health_code_update(); while (1) { - DBG("Apps thread polling on %d fds", LTTNG_POLL_GETNB(&events)); + DBG("Apps thread polling"); /* Inifinite blocking call, waiting for transmission */ restart: health_poll_entry(); ret = lttng_poll_wait(&events, -1); + DBG("Apps thread return from poll on %d fds", + LTTNG_POLL_GETNB(&events)); health_poll_exit(); if (ret < 0) { /* diff --git a/src/bin/lttng-sessiond/ust-thread.c b/src/bin/lttng-sessiond/ust-thread.c index d0ea32480..35f82e391 100644 --- a/src/bin/lttng-sessiond/ust-thread.c +++ b/src/bin/lttng-sessiond/ust-thread.c @@ -64,13 +64,14 @@ void *ust_thread_manage_notify(void *data) health_code_update(); while (1) { - DBG3("[ust-thread] Manage notify polling on %d fds", - LTTNG_POLL_GETNB(&events)); + DBG3("[ust-thread] Manage notify polling"); /* Inifinite blocking call, waiting for transmission */ restart: health_poll_entry(); ret = lttng_poll_wait(&events, -1); + DBG3("[ust-thread] Manage notify return from poll on %d fds", + LTTNG_POLL_GETNB(&events)); health_poll_exit(); if (ret < 0) { /* diff --git a/src/common/consumer.c b/src/common/consumer.c index 72c5f3426..129203fa5 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -2189,9 +2189,12 @@ void *consumer_thread_metadata_poll(void *data) } restart: - DBG("Metadata poll wait with %d fd(s)", LTTNG_POLL_GETNB(&events)); + health_code_update(); health_poll_entry(); + DBG("Metadata poll wait"); ret = lttng_poll_wait(&events, -1); + DBG("Metadata poll return from wait with %d fd(s)", + LTTNG_POLL_GETNB(&events)); health_poll_exit(); DBG("Metadata event catched in thread"); if (ret < 0) { @@ -2764,9 +2767,12 @@ void *consumer_thread_channel_poll(void *data) } restart: - DBG("Channel poll wait with %d fd(s)", LTTNG_POLL_GETNB(&events)); + health_code_update(); + DBG("Channel poll wait"); health_poll_entry(); ret = lttng_poll_wait(&events, -1); + DBG("Channel poll return from wait with %d fd(s)", + LTTNG_POLL_GETNB(&events)); health_poll_exit(); DBG("Channel event catched in thread"); if (ret < 0) { -- 2.34.1