relayd: add remote trace chunk close command
[lttng-tools.git] / src / common / ust-consumer / ust-consumer.c
index 83b2143d727ca5aab4790d665ba229912a1501d6..0d61b866f46d426c120694d9138f57a83be26a5d 100644 (file)
@@ -2008,8 +2008,8 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
        case LTTNG_CONSUMER_CREATE_TRACE_CHUNK:
        {
                const struct lttng_credentials credentials = {
-                       .uid = msg.u.create_trace_chunk.credentials.uid,
-                       .gid = msg.u.create_trace_chunk.credentials.gid,
+                       .uid = msg.u.create_trace_chunk.credentials.value.uid,
+                       .gid = msg.u.create_trace_chunk.credentials.value.gid,
                };
                const bool is_local_trace =
                                !msg.u.create_trace_chunk.relayd_id.is_set;
@@ -2062,9 +2062,12 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                                !is_local_trace ? &relayd_id : NULL,
                                msg.u.create_trace_chunk.session_id,
                                msg.u.create_trace_chunk.chunk_id,
-                               (time_t) msg.u.create_trace_chunk.creation_timestamp,
+                               (time_t) msg.u.create_trace_chunk
+                                               .creation_timestamp,
                                chunk_override_name,
-                               &credentials,
+                               msg.u.create_trace_chunk.credentials.is_set ?
+                                               &credentials :
+                                               NULL,
                                chunk_directory_handle.is_set ?
                                                &chunk_directory_handle.value :
                                                NULL);
@@ -2077,15 +2080,21 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
        }
        case LTTNG_CONSUMER_CLOSE_TRACE_CHUNK:
        {
+               enum lttng_trace_chunk_command_type close_command =
+                               msg.u.close_trace_chunk.close_command.value;
                const uint64_t relayd_id =
                                msg.u.close_trace_chunk.relayd_id.value;
 
                ret_code = lttng_consumer_close_trace_chunk(
                                msg.u.close_trace_chunk.relayd_id.is_set ?
-                                               &relayd_id : NULL,
+                                               &relayd_id :
+                                               NULL,
                                msg.u.close_trace_chunk.session_id,
                                msg.u.close_trace_chunk.chunk_id,
-                               (time_t) msg.u.close_trace_chunk.close_timestamp);
+                               (time_t) msg.u.close_trace_chunk.close_timestamp,
+                               msg.u.close_trace_chunk.close_command.is_set ?
+                                               &close_command :
+                                               NULL);
                goto end_msg_sessiond;
        }
        case LTTNG_CONSUMER_TRACE_CHUNK_EXISTS:
@@ -2513,6 +2522,13 @@ int commit_one_metadata_packet(struct lttng_consumer_stream *stream)
                        stream->ust_metadata_pushed);
        ret = write_len;
 
+       /*
+        * Switch packet (but don't open the next one) on every commit of
+        * a metadata packet. Since the subbuffer is fully filled (with padding,
+        * if needed), the stream is "quiescent" after this commit.
+        */
+       ustctl_flush_buffer(stream->ustream, 1);
+       stream->quiescent = true;
 end:
        pthread_mutex_unlock(&stream->chan->metadata_cache->lock);
        return ret;
@@ -2557,7 +2573,6 @@ int lttng_ustconsumer_sync_metadata(struct lttng_consumer_local_data *ctx,
                retry = 1;
        }
 
-       ustctl_flush_buffer(metadata->ustream, 1);
        ret = ustctl_snapshot(metadata->ustream);
        if (ret < 0) {
                if (errno != EAGAIN) {
@@ -2761,7 +2776,6 @@ retry:
                        if (ret <= 0) {
                                goto error;
                        }
-                       ustctl_flush_buffer(stream->ustream, 1);
                        goto retry;
                }
 
This page took 0.025212 seconds and 4 git commands to generate.