Fix: use the poll wait ret value when iterating on fd(s)
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 7e9f9dc643b3c3f97fa52f261f47f14c11bff9a7..f2cf2856a215d51406c8468f2fb1842b9c306067 100644 (file)
@@ -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);
This page took 0.02577 seconds and 4 git commands to generate.