X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fclient.cpp;h=46f524896ed2dd82e1a1ced94cff9092b937a8c2;hb=999af9c1150784f8676c6fce0764772d2314854a;hp=154fa4a3633f585af655a7697edbb68e128f787d;hpb=7966af5763c4aaca39df9bbfa9277ff15715c720;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/client.cpp b/src/bin/lttng-sessiond/client.cpp index 154fa4a36..46f524896 100644 --- a/src/bin/lttng-sessiond/client.cpp +++ b/src/bin/lttng-sessiond/client.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 EfficiOS Inc. * Copyright (C) 2011 Mathieu Desnoyers * Copyright (C) 2013 Jérémie Galarneau * @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -416,8 +417,6 @@ error: * Copy consumer output from the tracing session to the domain session. The * function also applies the right modification on a per domain basis for the * trace files destination directory. - * - * Should *NOT* be called with RCU read-side lock held. */ static int copy_session_consumer(int domain, struct ltt_session *session) { @@ -481,8 +480,6 @@ error: /* * Create an UST session and add it to the session ust list. - * - * Should *NOT* be called with RCU read-side lock held. */ static int create_ust_session(struct ltt_session *session, const struct lttng_domain *domain) @@ -919,8 +916,6 @@ end: * "sock" is only used for special-case var. len data. * A command may assume the ownership of the socket, in which case its value * should be set to -1. - * - * Should *NOT* be called with RCU read-side lock held. */ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, int *sock_error) @@ -934,8 +929,6 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int *sock, lttcomm_sessiond_command_str((lttcomm_sessiond_command) cmd_ctx->lsm.cmd_type), cmd_ctx->lsm.cmd_type); - LTTNG_ASSERT(!rcu_read_ongoing()); - *sock_error = 0; switch (cmd_ctx->lsm.cmd_type) { @@ -1440,14 +1433,8 @@ error_add_context: } case LTTNG_ENABLE_CHANNEL: { - cmd_ctx->lsm.u.channel.chan.attr.extended.ptr = - (struct lttng_channel_extended *) &cmd_ctx->lsm.u.channel.extended; - lttng_domain domain = cmd_ctx->lsm.domain; - lttng_channel chan = cmd_ctx->lsm.u.channel.chan; - ret = cmd_enable_channel(cmd_ctx->session, - &domain, - &chan, - the_kernel_poll_pipe[1]); + ret = cmd_enable_channel( + cmd_ctx, *sock, the_kernel_poll_pipe[1]); break; } case LTTNG_PROCESS_ATTR_TRACKER_ADD_INCLUDE_VALUE: @@ -1970,25 +1957,30 @@ error_add_context: } case LTTNG_LIST_CHANNELS: { - ssize_t payload_size; - struct lttng_channel *channels = NULL; + enum lttng_error_code ret_code; + size_t original_payload_size; + size_t payload_size; + const size_t command_header_size = sizeof(struct lttcomm_list_command_header); - payload_size = cmd_list_channels(cmd_ctx->lsm.domain.type, - cmd_ctx->session, &channels); - if (payload_size < 0) { - /* Return value is a negative lttng_error_code. */ - ret = -payload_size; - goto error; + ret = setup_empty_lttng_msg(cmd_ctx); + if (ret) { + ret = LTTNG_ERR_NOMEM; + goto setup_error; } - ret = setup_lttng_msg_no_cmd_header(cmd_ctx, channels, - payload_size); - free(channels); + original_payload_size = cmd_ctx->reply_payload.buffer.size; - if (ret < 0) { - goto setup_error; + ret_code = cmd_list_channels(cmd_ctx->lsm.domain.type, + cmd_ctx->session, &cmd_ctx->reply_payload); + if (ret_code != LTTNG_OK) { + ret = (int) ret_code; + goto error; } + payload_size = cmd_ctx->reply_payload.buffer.size - + command_header_size - original_payload_size; + update_lttng_msg(cmd_ctx, command_header_size, payload_size); + ret = LTTNG_OK; break; }