X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fkernel-consumer.c;h=9622d3058941e6cbe79ffac6528356b14b0a00ad;hp=236ce0eb6abe2948213e01ec5e2816ba8d62495f;hb=a2814ea7573bf5edd5323d6f89c48ff14105db69;hpb=d295668767ac8234e83984e1812d342d03293d88 diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 236ce0eb6..9622d3058 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -1,18 +1,8 @@ /* - * Copyright (C) 2012 - David Goulet + * Copyright (C) 2012 David Goulet * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License, version 2 only, as - * published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -33,7 +23,8 @@ #include "session.h" #include "lttng-sessiond.h" -static char *create_channel_path(struct consumer_output *consumer) +static char *create_channel_path(struct consumer_output *consumer, + size_t *consumer_path_offset) { int ret; char tmp_path[PATH_MAX]; @@ -42,17 +33,21 @@ static char *create_channel_path(struct consumer_output *consumer) assert(consumer); /* Get the right path name destination */ - if (consumer->type == CONSUMER_DST_LOCAL) { + if (consumer->type == CONSUMER_DST_LOCAL || + (consumer->type == CONSUMER_DST_NET && + consumer->relay_major_version == 2 && + consumer->relay_minor_version >= 11)) { pathname = strdup(consumer->domain_subdir); if (!pathname) { PERROR("Failed to copy domain subdirectory string %s", consumer->domain_subdir); goto error; } + *consumer_path_offset = strlen(consumer->domain_subdir); DBG3("Kernel local consumer trace path relative to current trace chunk: \"%s\"", pathname); } else { - /* Network output. */ + /* Network output, relayd < 2.11. */ ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s", consumer->dst.net.base_dir, consumer->domain_subdir); @@ -71,6 +66,7 @@ static char *create_channel_path(struct consumer_output *consumer) PERROR("lttng_strndup"); goto error; } + *consumer_path_offset = 0; DBG3("Kernel network consumer subdir path: %s", pathname); } @@ -98,6 +94,7 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, struct ltt_session *session = NULL; struct lttng_channel_extended *channel_attr_extended; bool is_local_trace; + size_t consumer_path_offset = 0; /* Safety net */ assert(channel); @@ -112,7 +109,7 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, channel->channel->name); is_local_trace = consumer->net_seq_index == -1ULL; - pathname = create_channel_path(consumer); + pathname = create_channel_path(consumer, &consumer_path_offset); if (!pathname) { ret = -1; goto error; @@ -147,7 +144,7 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, consumer_init_add_channel_comm_msg(&lkm, channel->key, ksession->id, - pathname, + &pathname[consumer_path_offset], ksession->uid, ksession->gid, consumer->net_seq_index, @@ -159,6 +156,7 @@ int kernel_consumer_add_channel(struct consumer_socket *sock, channel->channel->attr.tracefile_count, monitor, channel->channel->attr.live_timer_interval, + ksession->is_live_session, channel_attr_extended->monitor_timer_interval, ksession->current_trace_chunk); @@ -224,19 +222,13 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, consumer = ksession->consumer; /* Prep channel message structure */ - consumer_init_add_channel_comm_msg(&lkm, - ksession->metadata->key, - ksession->id, - DEFAULT_KERNEL_TRACE_DIR, - ksession->uid, - ksession->gid, - consumer->net_seq_index, - DEFAULT_METADATA_NAME, - 1, + consumer_init_add_channel_comm_msg(&lkm, ksession->metadata->key, + ksession->id, "", ksession->uid, ksession->gid, + consumer->net_seq_index, DEFAULT_METADATA_NAME, 1, DEFAULT_KERNEL_CHANNEL_OUTPUT, - CONSUMER_CHANNEL_TYPE_METADATA, - 0, 0, - monitor, 0, 0, ksession->current_trace_chunk); + CONSUMER_CHANNEL_TYPE_METADATA, 0, 0, monitor, 0, + ksession->is_live_session, 0, + ksession->current_trace_chunk); health_code_update();