From: David Goulet Date: Mon, 17 Dec 2012 17:37:42 +0000 (-0500) Subject: Fix: use the poll wait ret value when iterating on fd(s) X-Git-Tag: v2.1.0~38 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=0d9c5d7750202aa5f46cd7c6f642fb31fe1556c4;p=lttng-tools.git Fix: use the poll wait ret value when iterating on fd(s) Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 204207d21..41afccabd 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -514,11 +514,6 @@ void *relay_thread_listener(void *data) while (1) { DBG("Listener accepting connections"); - /* Zeroed the events structure */ - lttng_poll_reset(&events); - - nb_fd = LTTNG_POLL_GETNB(&events); - restart: ret = lttng_poll_wait(&events, -1); if (ret < 0) { @@ -531,6 +526,8 @@ restart: goto error; } + nb_fd = ret; + DBG("Relay new connection received"); for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ @@ -1877,11 +1874,6 @@ void *relay_thread_worker(void *data) } while (1) { - /* Zeroed the events structure */ - lttng_poll_reset(&events); - - nb_fd = LTTNG_POLL_GETNB(&events); - /* Infinite blocking call, waiting for transmission */ restart: DBG3("Relayd worker thread polling..."); @@ -1896,6 +1888,8 @@ void *relay_thread_worker(void *data) goto error; } + nb_fd = ret; + for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ revents = LTTNG_POLL_GETEV(&events, i); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 7e9f9dc64..f2cf2856a 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -728,12 +728,7 @@ static void *thread_manage_kernel(void *data) update_poll_flag = 0; } - nb_fd = LTTNG_POLL_GETNB(&events); - - DBG("Thread kernel polling on %d fds", nb_fd); - - /* Zeroed the poll events */ - lttng_poll_reset(&events); + DBG("Thread kernel polling on %d fds", events.nb_fd); /* Poll infinite value of time */ restart: @@ -755,6 +750,8 @@ static void *thread_manage_kernel(void *data) continue; } + nb_fd = ret; + for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ revents = LTTNG_POLL_GETEV(&events, i); @@ -886,8 +883,6 @@ static void *thread_manage_consumer(void *data) goto error; } - nb_fd = LTTNG_POLL_GETNB(&events); - health_code_update(&consumer_data->health); /* Inifinite blocking call, waiting for transmission */ @@ -910,6 +905,8 @@ restart: goto error; } + nb_fd = ret; + for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ revents = LTTNG_POLL_GETEV(&events, i); @@ -987,9 +984,6 @@ restart: health_code_update(&consumer_data->health); - /* Update number of fd */ - nb_fd = LTTNG_POLL_GETNB(&events); - /* Inifinite blocking call, waiting for transmission */ restart_poll: health_poll_update(&consumer_data->health); @@ -1005,6 +999,8 @@ restart_poll: goto error; } + nb_fd = ret; + for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ revents = LTTNG_POLL_GETEV(&events, i); @@ -1126,12 +1122,7 @@ static void *thread_manage_apps(void *data) health_code_update(&health_thread_app_manage); while (1) { - /* Zeroed the events structure */ - lttng_poll_reset(&events); - - nb_fd = LTTNG_POLL_GETNB(&events); - - DBG("Apps thread polling on %d fds", nb_fd); + DBG("Apps thread polling on %d fds", events.nb_fd); /* Inifinite blocking call, waiting for transmission */ restart: @@ -1148,6 +1139,8 @@ static void *thread_manage_apps(void *data) goto error; } + nb_fd = ret; + for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ revents = LTTNG_POLL_GETEV(&events, i); @@ -1405,8 +1398,6 @@ static void *thread_registration_apps(void *data) while (1) { DBG("Accepting application registration"); - nb_fd = LTTNG_POLL_GETNB(&events); - /* Inifinite blocking call, waiting for transmission */ restart: health_poll_update(&health_thread_app_reg); @@ -1422,6 +1413,8 @@ static void *thread_registration_apps(void *data) goto error; } + nb_fd = ret; + for (i = 0; i < nb_fd; i++) { health_code_update(&health_thread_app_reg); @@ -2982,8 +2975,6 @@ static void *thread_manage_health(void *data) while (1) { DBG("Health check ready"); - nb_fd = LTTNG_POLL_GETNB(&events); - /* Inifinite blocking call, waiting for transmission */ restart: ret = lttng_poll_wait(&events, -1); @@ -2997,6 +2988,8 @@ restart: goto error; } + nb_fd = ret; + for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ revents = LTTNG_POLL_GETEV(&events, i); @@ -3181,8 +3174,6 @@ static void *thread_manage_clients(void *data) while (1) { DBG("Accepting client command ..."); - nb_fd = LTTNG_POLL_GETNB(&events); - /* Inifinite blocking call, waiting for transmission */ restart: health_poll_update(&health_thread_cmd); @@ -3198,6 +3189,8 @@ static void *thread_manage_clients(void *data) goto error; } + nb_fd = ret; + for (i = 0; i < nb_fd; i++) { /* Fetch once the poll data */ revents = LTTNG_POLL_GETEV(&events, i); diff --git a/src/common/consumer.c b/src/common/consumer.c index 16521a8b8..0df073523 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -2101,17 +2101,13 @@ void *consumer_thread_metadata_poll(void *data) DBG("Metadata main loop started"); while (1) { - lttng_poll_reset(&events); - - nb_fd = LTTNG_POLL_GETNB(&events); - /* Only the metadata pipe is set */ - if (nb_fd == 0 && consumer_quit == 1) { + if (events.nb_fd == 0 && consumer_quit == 1) { goto end; } restart: - DBG("Metadata poll wait with %d fd(s)", nb_fd); + DBG("Metadata poll wait with %d fd(s)", events.nb_fd); ret = lttng_poll_wait(&events, -1); DBG("Metadata event catched in thread"); if (ret < 0) { @@ -2122,6 +2118,8 @@ restart: goto error; } + nb_fd = ret; + /* From here, the event is a metadata wait fd */ for (i = 0; i < nb_fd; i++) { revents = LTTNG_POLL_GETEV(&events, i);