ctf: save self_msg_iter in ctf_msg_iter when creating it
[babeltrace.git] / src / plugins / ctf / lttng-live / viewer-connection.c
index befffb30a8c6117c096f9df086c7ff12823781ad..b1f37f04a0516bc04addd95af1f4c48ba2de7678 100644 (file)
 #define BT_LOG_TAG "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"
 #include "logging/comp-logging.h"
 
-#include <stdio.h>
+#include <fcntl.h>
+#include <stdbool.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
-#include <stdbool.h>
+#include <sys/types.h>
 #include <unistd.h>
+
 #include <glib.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <fcntl.h>
 
 #include "compat/socket.h"
 #include "compat/endian.h"
@@ -812,7 +812,8 @@ error:
 
 static
 int receive_streams(struct lttng_live_session *session,
-               uint32_t stream_count)
+               uint32_t stream_count,
+               bt_self_message_iterator *self_msg_iter)
 {
        ssize_t ret_len;
        uint32_t i;
@@ -862,7 +863,7 @@ int receive_streams(struct lttng_live_session *session,
                        BT_COMP_LOGI("    stream %" PRIu64 " : %s/%s",
                                stream_id, stream.path_name, stream.channel_name);
                        live_stream = lttng_live_stream_iterator_create(session,
-                               ctf_trace_id, stream_id);
+                               ctf_trace_id, stream_id, self_msg_iter);
                        if (!live_stream) {
                                BT_COMP_LOGE_APPEND_CAUSE(self_comp,
                                        "Error creating stream");
@@ -878,7 +879,8 @@ error:
 
 BT_HIDDEN
 enum lttng_live_attach_session_status lttng_live_attach_session(
-               struct lttng_live_session *session)
+               struct lttng_live_session *session,
+               bt_self_message_iterator *self_msg_iter)
 {
        struct lttng_viewer_cmd cmd;
        enum lttng_live_attach_session_status attach_status;
@@ -960,7 +962,7 @@ enum lttng_live_attach_session_status lttng_live_attach_session(
        }
 
        /* We receive the initial list of streams. */
-       if (receive_streams(session, streams_count)) {
+       if (receive_streams(session, streams_count, self_msg_iter)) {
                BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error receiving streams");
                goto error;
        }
@@ -1343,12 +1345,12 @@ error:
 }
 
 BT_HIDDEN
-enum bt_msg_iter_medium_status lttng_live_get_stream_bytes(
+enum ctf_msg_iter_medium_status lttng_live_get_stream_bytes(
                struct lttng_live_msg_iter *lttng_live_msg_iter,
                struct lttng_live_stream_iterator *stream, uint8_t *buf,
                uint64_t offset, uint64_t req_len, uint64_t *recv_len)
 {
-       enum bt_msg_iter_medium_status retstatus = BT_MSG_ITER_MEDIUM_STATUS_OK;
+       enum ctf_msg_iter_medium_status retstatus = CTF_MSG_ITER_MEDIUM_STATUS_OK;
        struct lttng_viewer_trace_packet rp;
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_get_packet rq;
@@ -1418,7 +1420,7 @@ enum bt_msg_iter_medium_status lttng_live_get_stream_bytes(
        case LTTNG_VIEWER_GET_PACKET_RETRY:
                /* Unimplemented by relay daemon */
                BT_COMP_LOGD("Received get_data_packet response: retry");
-               retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN;
+               retstatus = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
                goto end;
        case LTTNG_VIEWER_GET_PACKET_ERR:
                if (flags & LTTNG_VIEWER_FLAG_NEW_METADATA) {
@@ -1431,14 +1433,14 @@ enum bt_msg_iter_medium_status lttng_live_get_stream_bytes(
                }
                if (flags & (LTTNG_VIEWER_FLAG_NEW_METADATA
                                | LTTNG_VIEWER_FLAG_NEW_STREAM)) {
-                       retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN;
+                       retstatus = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
                        goto end;
                }
                BT_COMP_LOGE_APPEND_CAUSE(self_comp,
                        "Received get_data_packet response: error");
                goto error;
        case LTTNG_VIEWER_GET_PACKET_EOF:
-               retstatus = BT_MSG_ITER_MEDIUM_STATUS_EOF;
+               retstatus = CTF_MSG_ITER_MEDIUM_STATUS_EOF;
                goto end;
        default:
                BT_COMP_LOGE_APPEND_CAUSE(self_comp,
@@ -1469,9 +1471,9 @@ end:
 
 error:
        if (lttng_live_graph_is_canceled(lttng_live_msg_iter)) {
-               retstatus = BT_MSG_ITER_MEDIUM_STATUS_AGAIN;
+               retstatus = CTF_MSG_ITER_MEDIUM_STATUS_AGAIN;
        } else {
-               retstatus = BT_MSG_ITER_MEDIUM_STATUS_ERROR;
+               retstatus = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
        }
        return retstatus;
 }
@@ -1481,7 +1483,8 @@ error:
  */
 BT_HIDDEN
 enum lttng_live_iterator_status lttng_live_get_new_streams(
-               struct lttng_live_session *session)
+               struct lttng_live_session *session,
+               bt_self_message_iterator *self_msg_iter)
 {
        enum lttng_live_iterator_status status =
                LTTNG_LIVE_ITERATOR_STATUS_OK;
@@ -1562,7 +1565,7 @@ enum lttng_live_iterator_status lttng_live_get_new_streams(
                goto error;
        }
 
-       if (receive_streams(session, streams_count)) {
+       if (receive_streams(session, streams_count, self_msg_iter)) {
                BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error receiving streams");
                goto error;
        }
This page took 0.027064 seconds and 4 git commands to generate.