src.ctf.lttng-live: make component class handle interruptions
[babeltrace.git] / src / plugins / ctf / lttng-live / metadata.c
index 787fc0b322da0c39d68494b636c852a6e6ec8876..7a7a0d8a445c59815ba85e8a540c33b447a48819 100644 (file)
@@ -151,11 +151,15 @@ enum lttng_live_iterator_status lttng_live_metadata_update(
                goto end;
        }
 
-       /* Open for writing */
+       /*
+        * Open a new write only file handle to populate the `metadata_buf`
+        * memory buffer so we can write in loop in it easily.
+        */
        fp = bt_open_memstream(&metadata_buf, &size);
        if (!fp) {
                if (errno == EINTR &&
                                lttng_live_graph_is_canceled(session->lttng_live_msg_iter)) {
+                       session->lttng_live_msg_iter->was_interrupted = true;
                        status = LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
                } else {
                        BT_COMP_LOGE_APPEND_CAUSE_ERRNO(self_comp,
@@ -210,6 +214,7 @@ enum lttng_live_iterator_status lttng_live_metadata_update(
                goto end;
        }
 
+       /* The memory buffer `metadata_buf` contains all the metadata. */
        if (bt_close_memstream(&metadata_buf, &size, fp)) {
                BT_COMP_LOGE_APPEND_CAUSE_ERRNO(self_comp,
                        "Metadata bt_close_memstream", ".");
@@ -226,10 +231,15 @@ enum lttng_live_iterator_status lttng_live_metadata_update(
                goto end;
        }
 
+       /*
+        * Open a new reading file handle on the `metadata_buf` and pass it to
+        * the metadata decoder.
+        */
        fp = bt_fmemopen(metadata_buf, len_read, "rb");
        if (!fp) {
                if (errno == EINTR &&
                                lttng_live_graph_is_canceled(session->lttng_live_msg_iter)) {
+                       session->lttng_live_msg_iter->was_interrupted = true;
                        status = LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
                } else {
                        BT_COMP_LOGE_APPEND_CAUSE_ERRNO(self_comp,
This page took 0.023592 seconds and 4 git commands to generate.