Fix: relayd: per-pid live: no new metadata vs close
[lttng-tools.git] / src / bin / lttng-relayd / main.c
index b3983b163fb32a5b13c593573f92fbfab75b5ca0..54f31d7218a175fa16cbc8a7827f53c393a7f616 100644 (file)
@@ -1521,7 +1521,7 @@ static int relay_close_stream(const struct lttcomm_relayd_hdr *recv_hdr,
 
                vstream = viewer_stream_get_by_id(stream->stream_handle);
                if (vstream) {
-                       if (vstream->metadata_sent == stream->metadata_received) {
+                       if (stream->no_new_metadata_notified) {
                                /*
                                 * Since all the metadata has been sent to the
                                 * viewer and that we have a request to close
@@ -2188,6 +2188,9 @@ static int relay_recv_index(const struct lttcomm_relayd_hdr *recv_hdr,
                index_info.stream_instance_id =
                                be64toh(index_info.stream_instance_id);
                index_info.packet_seq_num = be64toh(index_info.packet_seq_num);
+       } else {
+               index_info.stream_instance_id = -1ULL;
+               index_info.packet_seq_num = -1ULL;
        }
 
        stream = stream_get_by_id(index_info.relay_stream_id);
@@ -2437,7 +2440,7 @@ static int relay_create_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr,
        struct lttng_trace_chunk *chunk = NULL, *published_chunk = NULL;
        enum lttng_error_code reply_code = LTTNG_OK;
        enum lttng_trace_chunk_status chunk_status;
-       struct lttng_directory_handle session_output;
+       struct lttng_directory_handle *session_output = NULL;
 
        if (!session || !conn->version_check_done) {
                ERR("Trying to create a trace chunk before version check");
@@ -2512,14 +2515,15 @@ static int relay_create_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr,
                goto end;
        }
 
-       ret = session_init_output_directory_handle(
-                       conn->session, &session_output);
-       if (ret) {
+       session_output = session_create_output_directory_handle(
+                       conn->session);
+       if (!session_output) {
                reply_code = LTTNG_ERR_CREATE_DIR_FAIL;
                goto end;
        }
-       chunk_status = lttng_trace_chunk_set_as_owner(chunk, &session_output);
-       lttng_directory_handle_fini(&session_output);
+       chunk_status = lttng_trace_chunk_set_as_owner(chunk, session_output);
+       lttng_directory_handle_put(session_output);
+       session_output = NULL;
        if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
                reply_code = LTTNG_ERR_UNK;
                ret = -1;
@@ -2575,6 +2579,7 @@ end:
 end_no_reply:
        lttng_trace_chunk_put(chunk);
        lttng_trace_chunk_put(published_chunk);
+       lttng_directory_handle_put(session_output);
        return ret;
 }
 
This page took 0.027341 seconds and 5 git commands to generate.