X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fkernel-consumer.c;h=3649374efb0ae38cf6f1685df734abe7f6d28d88;hb=6c598487f3667228a3457d1f3b0cc8f9e745141c;hp=6cda088d9e5e7600174476d29962adf2bd532189;hpb=bb3c4e70f3dc7550185398d88b07081e97c0ad22;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 6cda088d9..3649374ef 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -15,16 +15,15 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include -#include #include #include #include #include +#include #include "consumer.h" #include "health-sessiond.h" @@ -48,16 +47,16 @@ static char *create_channel_path(struct consumer_output *consumer, PERROR("snprintf kernel channel path"); goto error; } - pathname = strndup(tmp_path, sizeof(tmp_path)); + pathname = lttng_strndup(tmp_path, sizeof(tmp_path)); if (!pathname) { - PERROR("strndup"); + PERROR("lttng_strndup"); goto error; } /* Create directory */ ret = run_as_mkdir_recursive(pathname, S_IRWXU | S_IRWXG, uid, gid); if (ret < 0) { - if (ret != -EEXIST) { + if (errno != EEXIST) { ERR("Trace directory creation error"); goto error; } @@ -69,9 +68,9 @@ static char *create_channel_path(struct consumer_output *consumer, PERROR("snprintf kernel metadata path"); goto error; } - pathname = strndup(tmp_path, sizeof(tmp_path)); + pathname = lttng_strndup(tmp_path, sizeof(tmp_path)); if (!pathname) { - PERROR("strndup"); + PERROR("lttng_strndup"); goto error; } DBG3("Kernel network consumer subdir path: %s", pathname); @@ -314,7 +313,7 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, struct ltt_kernel_channel *channel, struct ltt_kernel_session *session, unsigned int monitor) { - int ret; + int ret = LTTNG_OK; struct ltt_kernel_stream *stream; /* Safety net */ @@ -332,14 +331,17 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, DBG("Sending streams of channel %s to kernel consumer", channel->channel->name); - ret = kernel_consumer_add_channel(sock, channel, session, monitor); - if (ret < 0) { - goto error; + if (!channel->sent_to_consumer) { + ret = kernel_consumer_add_channel(sock, channel, session, monitor); + if (ret < 0) { + goto error; + } + channel->sent_to_consumer = true; } /* Send streams */ cds_list_for_each_entry(stream, &channel->stream_list.head, list) { - if (!stream->fd) { + if (!stream->fd || stream->sent_to_consumer) { continue; } @@ -349,6 +351,7 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, if (ret < 0) { goto error; } + stream->sent_to_consumer = true; } error: