Propagate trace format all the way to the consumer
[lttng-tools.git] / src / common / ust-consumer / ust-consumer.cpp
index 431bb98f6cd25ce1da5315ffd177b37960525d04..25da16ff0ec85252e4ab0285007aeee50730f8a9 100644 (file)
@@ -97,18 +97,9 @@ static struct lttng_consumer_stream *allocate_stream(int cpu, int key,
        LTTNG_ASSERT(channel);
        LTTNG_ASSERT(ctx);
 
-       stream = consumer_stream_create(
-                       channel,
-                       channel->key,
-                       key,
-                       channel->name,
-                       channel->relayd_id,
-                       channel->session_id,
-                       channel->trace_chunk,
-                       cpu,
-                       &alloc_ret,
-                       channel->type,
-                       channel->monitor);
+       stream = consumer_stream_create(channel, channel->key, key, channel->name,
+                       channel->relayd_id, channel->session_id, channel->trace_chunk, cpu,
+                       &alloc_ret, channel->type, channel->monitor, channel->trace_format);
        if (stream == NULL) {
                switch (alloc_ret) {
                case -ENOENT:
@@ -702,6 +693,14 @@ static int flush_channel(uint64_t chan_key)
 next:
                pthread_mutex_unlock(&stream->lock);
        }
+
+       /*
+        * Send one last buffer statistics update to the session daemon. This
+        * ensures that the session daemon gets at least one statistics update
+        * per channel even in the case of short-lived channels, such as when a
+        * short-lived app is traced in per-pid mode.
+        */
+       sample_and_send_channel_buffer_stats(channel);
 error:
        rcu_read_unlock();
        return ret;
@@ -1474,23 +1473,17 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                };
 
                /* Create a plain object and reserve a channel key. */
-               channel = consumer_allocate_channel(
-                               msg.u.ask_channel.key,
+               channel = consumer_allocate_channel(msg.u.ask_channel.key,
                                msg.u.ask_channel.session_id,
-                               msg.u.ask_channel.chunk_id.is_set ?
-                                               &chunk_id : NULL,
-                               msg.u.ask_channel.pathname,
-                               msg.u.ask_channel.name,
+                               msg.u.ask_channel.chunk_id.is_set ? &chunk_id : NULL,
+                               msg.u.ask_channel.pathname, msg.u.ask_channel.name,
                                msg.u.ask_channel.relayd_id,
                                (enum lttng_event_output) msg.u.ask_channel.output,
-                               msg.u.ask_channel.tracefile_size,
-                               msg.u.ask_channel.tracefile_count,
-                               msg.u.ask_channel.session_id_per_pid,
-                               msg.u.ask_channel.monitor,
-                               msg.u.ask_channel.live_timer_interval,
-                               msg.u.ask_channel.is_live,
-                               msg.u.ask_channel.root_shm_path,
-                               msg.u.ask_channel.shm_path);
+                               msg.u.ask_channel.tracefile_size, msg.u.ask_channel.tracefile_count,
+                               msg.u.ask_channel.session_id_per_pid, msg.u.ask_channel.monitor,
+                               msg.u.ask_channel.live_timer_interval, msg.u.ask_channel.is_live,
+                               msg.u.ask_channel.root_shm_path, msg.u.ask_channel.shm_path,
+                               msg.u.ask_channel.trace_format);
                if (!channel) {
                        goto end_channel_error;
                }
@@ -2093,9 +2086,11 @@ end_rotate_channel_nosignal:
        case LTTNG_CONSUMER_INIT:
        {
                int ret_send_status;
+               lttng_uuid sessiond_uuid;
 
-               ret_code = lttng_consumer_init_command(ctx,
-                               msg.u.init.sessiond_uuid);
+               std::copy(std::begin(msg.u.init.sessiond_uuid), std::end(msg.u.init.sessiond_uuid),
+                               sessiond_uuid.begin());
+               ret_code = lttng_consumer_init_command(ctx, sessiond_uuid);
                health_code_update();
                ret_send_status = consumer_send_status_msg(sock, ret_code);
                if (ret_send_status < 0) {
@@ -2421,8 +2416,9 @@ void lttng_ustconsumer_on_stream_hangup(struct lttng_consumer_stream *stream)
                        stream->quiescent = true;
                }
        }
-       pthread_mutex_unlock(&stream->lock);
+
        stream->hangup_flush_done = 1;
+       pthread_mutex_unlock(&stream->lock);
 }
 
 void lttng_ustconsumer_del_channel(struct lttng_consumer_channel *chan)
This page took 0.032255 seconds and 5 git commands to generate.