Fix: poll and epoll fd set reallocation
[lttng-tools.git] / src / common / consumer.c
index 16521a8b863788fd957b756d7c4882f6b3c5abbd..af99333c8d2ae1bacc73f7f4af5fcd231e79e104 100644 (file)
@@ -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 (LTTNG_POLL_GETNB(&events) == 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)", LTTNG_POLL_GETNB(&events));
                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);
@@ -3030,10 +3028,12 @@ int consumer_data_pending(uint64_t id)
                ret = relayd_end_data_pending(&relayd->control_sock,
                                relayd->relayd_session_id, &is_data_inflight);
                pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
-               if (ret < 0 || !is_data_inflight) {
-                       /* On error or if NO data inflight, no data is pending. */
+               if (ret < 0) {
                        goto data_not_pending;
                }
+               if (is_data_inflight) {
+                       goto data_pending;
+               }
        }
 
        /*
This page took 0.024295 seconds and 4 git commands to generate.