From: Francis Deslauriers Date: Fri, 2 Mar 2018 15:41:34 +0000 (-0500) Subject: Use free running metadata channel key between sessiond and kernel consumer X-Git-Tag: v2.11.0-rc1~368 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d40f035921a2d3be652d31bdcc250db521f96209;p=lttng-tools.git Use free running metadata channel key between sessiond and kernel consumer Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 10011f4cd..160c19f59 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -218,7 +218,7 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, /* Prep channel message structure */ consumer_init_channel_comm_msg(&lkm, LTTNG_CONSUMER_ADD_CHANNEL, - session->metadata->fd, + session->metadata->key, session->id, pathname, session->uid, @@ -243,7 +243,7 @@ int kernel_consumer_add_metadata(struct consumer_socket *sock, /* Prep stream message structure */ consumer_init_stream_comm_msg(&lkm, LTTNG_CONSUMER_ADD_STREAM, - session->metadata->fd, + session->metadata->key, session->metadata_stream_fd, 0); /* CPU: 0 for metadata. */ @@ -497,11 +497,11 @@ int kernel_consumer_destroy_metadata(struct consumer_socket *socket, assert(metadata); assert(socket); - DBG("Sending kernel consumer destroy channel key %d", metadata->fd); + DBG("Sending kernel consumer destroy channel key %" PRIu64, metadata->key); memset(&msg, 0, sizeof(msg)); msg.cmd_type = LTTNG_CONSUMER_DESTROY_CHANNEL; - msg.u.destroy_channel.key = metadata->fd; + msg.u.destroy_channel.key = metadata->key; pthread_mutex_lock(socket->lock); health_code_update(); diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 158a12a36..e5f068a0c 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -535,6 +535,7 @@ int kernel_open_metadata(struct ltt_kernel_session *session) } lkm->fd = ret; + lkm->key = ++next_kernel_channel_key; /* Prevent fd duplication after execlp() */ ret = fcntl(lkm->fd, F_SETFD, FD_CLOEXEC); if (ret < 0) { @@ -1052,7 +1053,7 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess, } /* Snapshot metadata, */ - ret = consumer_snapshot_channel(socket, ksess->metadata->fd, output, + ret = consumer_snapshot_channel(socket, ksess->metadata->key, output, 1, ksess->uid, ksess->gid, DEFAULT_KERNEL_TRACE_DIR, wait, 0); if (ret < 0) { diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index 9c52cee09..3210d4b33 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -81,6 +81,7 @@ struct ltt_kernel_channel { /* Metadata */ struct ltt_kernel_metadata { int fd; + uint64_t key; /* Key to reference this channel with the consumer. */ struct lttng_channel *conf; };