ctf: allocate some structures with new
[babeltrace.git] / src / plugins / ctf / lttng-live / viewer-connection.cpp
index 41e81ec8e07c9e0e6255dc6350b0d27f0f9014cf..61b8a8cfc005c68ea59ac4922e2ba42a07446dfa 100644 (file)
@@ -5,25 +5,19 @@
  * Copyright 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  */
 
-#include <fcntl.h>
 #include <glib.h>
 #include <stdint.h>
 #include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
 
 #include <babeltrace2/babeltrace.h>
 
 #define BT_COMP_LOG_SELF_COMP (viewer_connection->self_comp)
-#define BT_LOG_OUTPUT_LEVEL   (viewer_connection->log_level)
+#define BT_LOG_OUTPUT_LEVEL   ((enum bt_log_level) viewer_connection->log_level)
 #define BT_LOG_TAG            "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"
 #include "logging/comp-logging.h"
 
 #include "common/common.h"
-#include "compat/compiler.h"
-#include "compat/endian.h"
-#include "compat/socket.h"
+#include "compat/endian.h" /* IWYU pragma: keep  */
 
 #include "data-stream.hpp"
 #include "lttng-live.hpp"
@@ -1417,6 +1411,14 @@ lttng_live_get_next_index(struct lttng_live_msg_iter *lttng_live_msg_iter,
     BT_COMP_LOGD("Received response from relay daemon: cmd=%s, response=%s",
                  lttng_viewer_command_string(LTTNG_VIEWER_GET_NEXT_INDEX),
                  lttng_viewer_next_index_return_code_string(rp_status));
+
+    if (flags & LTTNG_VIEWER_FLAG_NEW_STREAM) {
+        BT_COMP_LOGD("Marking all sessions as possibly needing new streams: "
+                     "response=%s, response-flag=NEW_STREAM",
+                     lttng_viewer_next_index_return_code_string(rp_status));
+        lttng_live_need_new_streams(lttng_live_msg_iter);
+    }
+
     switch (rp_status) {
     case LTTNG_VIEWER_INDEX_INACTIVE:
     {
@@ -1448,7 +1450,6 @@ lttng_live_get_next_index(struct lttng_live_msg_iter *lttng_live_msg_iter,
             stream->ctf_stream_class_id.value = ctf_stream_class_id;
             stream->ctf_stream_class_id.is_set = true;
         }
-
         lttng_live_stream_iterator_set_state(stream, LTTNG_LIVE_STREAM_ACTIVE_DATA);
 
         if (flags & LTTNG_VIEWER_FLAG_NEW_METADATA) {
@@ -1457,12 +1458,6 @@ lttng_live_get_next_index(struct lttng_live_msg_iter *lttng_live_msg_iter,
                          lttng_viewer_next_index_return_code_string(rp_status), trace->id);
             trace->metadata_stream_state = LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED;
         }
-        if (flags & LTTNG_VIEWER_FLAG_NEW_STREAM) {
-            BT_COMP_LOGD("Marking all sessions as possibly needing new streams: "
-                         "response=%s, response-flag=NEW_STREAM",
-                         lttng_viewer_next_index_return_code_string(rp_status));
-            lttng_live_need_new_streams(lttng_live_msg_iter);
-        }
         status = LTTNG_LIVE_ITERATOR_STATUS_OK;
         break;
     }
@@ -1490,6 +1485,7 @@ lttng_live_get_next_index(struct lttng_live_msg_iter *lttng_live_msg_iter,
         status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
         goto end;
     }
+
     goto end;
 
 error:
@@ -1718,10 +1714,9 @@ enum lttng_live_viewer_status live_viewer_connection_create(
     bt_logging_level log_level, const char *url, bool in_query,
     struct lttng_live_msg_iter *lttng_live_msg_iter, struct live_viewer_connection **viewer)
 {
-    struct live_viewer_connection *viewer_connection;
     enum lttng_live_viewer_status status;
 
-    viewer_connection = g_new0(struct live_viewer_connection, 1);
+    live_viewer_connection *viewer_connection = new live_viewer_connection;
 
     if (bt_socket_init(log_level) != 0) {
         BT_COMP_OR_COMP_CLASS_LOGE_APPEND_CAUSE(self_comp, self_comp_class,
@@ -1814,7 +1809,7 @@ void live_viewer_connection_destroy(struct live_viewer_connection *viewer_connec
         g_string_free(viewer_connection->proto, true);
     }
 
-    g_free(viewer_connection);
+    delete viewer_connection;
 
     bt_socket_fini();
 
This page took 0.036495 seconds and 4 git commands to generate.