Fix: undefined operation on last_relay_viewer_session_id
[lttng-tools.git] / src / bin / lttng-relayd / live.c
index b0d53dfc8548d76c05f0c4df7588ca3992fb6dae..81b90939c9e713570ef34670ce3524d3cd9c8bc1 100644 (file)
@@ -514,6 +514,11 @@ restart:
                        revents = LTTNG_POLL_GETEV(&events, i);
                        pollfd = LTTNG_POLL_GETFD(&events, i);
 
+                       if (!revents) {
+                               /* No activity for this FD (poll implementation). */
+                               continue;
+                       }
+
                        /* Thread quit pipe has been closed. Killing thread. */
                        ret = check_thread_quit_pipe(pollfd, revents);
                        if (ret) {
@@ -727,7 +732,12 @@ int viewer_connect(struct relay_connection *conn)
        reply.major = htobe32(reply.major);
        reply.minor = htobe32(reply.minor);
        if (conn->type == RELAY_VIEWER_COMMAND) {
-               reply.viewer_session_id = htobe64(++last_relay_viewer_session_id);
+               /*
+                * Increment outside of htobe64 macro, because can be used more than once
+                * within the macro, and thus the operation may be undefined.
+                */
+               last_relay_viewer_session_id++;
+               reply.viewer_session_id = htobe64(last_relay_viewer_session_id);
        }
 
        health_code_update();
@@ -1319,7 +1329,7 @@ int viewer_get_next_index(struct relay_connection *conn)
        ret = check_index_status(vstream, rstream, ctf_trace, &viewer_index);
        pthread_mutex_unlock(&rstream->viewer_stream_rotation_lock);
        if (ret < 0) {
-               goto end;
+               goto end_unlock;
        } else if (ret == 1) {
                /*
                 * This means the viewer index data structure has been populated by the
@@ -1947,6 +1957,11 @@ restart:
 
                        health_code_update();
 
+                       if (!revents) {
+                               /* No activity for this FD (poll implementation). */
+                               continue;
+                       }
+
                        /* Thread quit pipe has been closed. Killing thread. */
                        ret = check_thread_quit_pipe(pollfd, revents);
                        if (ret) {
This page took 0.024342 seconds and 4 git commands to generate.