X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fconsumer.c;h=b1ccbc1082c7728e306bdccfa680652063bc358a;hb=af706bb7e9bda5d6b95414165681abe422f1541e;hp=8198629f32638fc181a07cc2c5d28ac6703c062f;hpb=ee91bab210156bd9a4ec23eac93aa563556f2803;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 8198629f3..b1ccbc108 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "consumer.h" #include "health.h" @@ -409,6 +408,28 @@ error: return output; } +/* + * Iterate over the consumer output socket hash table and destroy them. The + * socket file descriptor are only closed if the consumer output was + * registered meaning it's an external consumer. + */ +void consumer_destroy_output_sockets(struct consumer_output *obj) +{ + struct lttng_ht_iter iter; + struct consumer_socket *socket; + + if (!obj->socks) { + return; + } + + rcu_read_lock(); + cds_lfht_for_each_entry(obj->socks->ht, &iter.iter, socket, node.node) { + consumer_del_socket(socket, obj); + consumer_destroy_socket(socket); + } + rcu_read_unlock(); +} + /* * Delete the consumer_output object from the list and free the ptr. * @@ -420,17 +441,9 @@ void consumer_destroy_output(struct consumer_output *obj) return; } - if (obj->socks) { - struct lttng_ht_iter iter; - struct consumer_socket *socket; - - rcu_read_lock(); - cds_lfht_for_each_entry(obj->socks->ht, &iter.iter, socket, node.node) { - consumer_del_socket(socket, obj); - consumer_destroy_socket(socket); - } - rcu_read_unlock(); + consumer_destroy_output_sockets(obj); + if (obj->socks) { /* Finally destroy HT */ ht_cleanup_push(obj->socks); } @@ -723,6 +736,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, uint32_t chan_id, uint64_t tracefile_size, uint64_t tracefile_count, + uint64_t session_id_per_pid, unsigned int monitor) { assert(msg); @@ -739,6 +753,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, msg->u.ask_channel.output = output; msg->u.ask_channel.type = type; msg->u.ask_channel.session_id = session_id; + msg->u.ask_channel.session_id_per_pid = session_id_per_pid; msg->u.ask_channel.uid = uid; msg->u.ask_channel.gid = gid; msg->u.ask_channel.relayd_id = relayd_id; @@ -750,9 +765,11 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg, memcpy(msg->u.ask_channel.uuid, uuid, sizeof(msg->u.ask_channel.uuid)); - strncpy(msg->u.ask_channel.pathname, pathname, - sizeof(msg->u.ask_channel.pathname)); - msg->u.ask_channel.pathname[sizeof(msg->u.ask_channel.pathname)-1] = '\0'; + if (pathname) { + strncpy(msg->u.ask_channel.pathname, pathname, + sizeof(msg->u.ask_channel.pathname)); + msg->u.ask_channel.pathname[sizeof(msg->u.ask_channel.pathname)-1] = '\0'; + } strncpy(msg->u.ask_channel.name, name, sizeof(msg->u.ask_channel.name)); msg->u.ask_channel.name[sizeof(msg->u.ask_channel.name) - 1] = '\0'; @@ -1196,7 +1213,6 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, const char *session_path, int wait) { int ret; - char datetime[16]; struct lttcomm_consumer_msg msg; assert(socket); @@ -1206,13 +1222,6 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, DBG("Consumer snapshot channel key %" PRIu64, key); - ret = utils_get_current_time_str("%Y%m%d-%H%M%S", datetime, - sizeof(datetime)); - if (!ret) { - ret = -EINVAL; - goto error; - } - memset(&msg, 0, sizeof(msg)); msg.cmd_type = LTTNG_CONSUMER_SNAPSHOT_CHANNEL; msg.u.snapshot_channel.key = key; @@ -1224,7 +1233,7 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, msg.u.snapshot_channel.use_relayd = 1; ret = snprintf(msg.u.snapshot_channel.pathname, sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s", - output->consumer->subdir, output->name, datetime, + output->consumer->subdir, output->name, output->datetime, session_path); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; @@ -1233,8 +1242,8 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, } else { ret = snprintf(msg.u.snapshot_channel.pathname, sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s", - output->consumer->dst.trace_path, output->name, datetime, - session_path); + output->consumer->dst.trace_path, output->name, + output->datetime, session_path); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; goto error;