Clean-up: sessiond: cmd_enable_channel_internal
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.cpp
index 0ca7f217244bd81d7cba98431347d60e7f61c9b4..3ed56f7b064503402b41b1fa204166ada14655fb 100644 (file)
@@ -114,7 +114,8 @@ static int cmd_enable_event_internal(struct ltt_session *session,
                struct lttng_bytecode *filter,
                struct lttng_event_exclusion *exclusion,
                int wpipe);
-static int cmd_enable_channel_internal(struct ltt_session *session,
+static enum lttng_error_code cmd_enable_channel_internal(
+               struct ltt_session *session,
                const struct lttng_domain *domain,
                const struct lttng_channel *_attr,
                int wpipe);
@@ -917,7 +918,6 @@ relayd_comm_error:
  * Returns LTTNG_OK, or an LTTng error code on failure.
  */
 static enum lttng_error_code send_consumer_relayd_sockets(
-               enum lttng_domain_type domain,
                unsigned int session_id, struct consumer_output *consumer,
                struct consumer_socket *sock, const char *session_name,
                const char *hostname, const char *base_path, int session_live_timer,
@@ -998,7 +998,7 @@ int cmd_setup_relayd(struct ltt_session *session)
                cds_lfht_for_each_entry(usess->consumer->socks->ht, &iter.iter,
                                socket, node.node) {
                        pthread_mutex_lock(socket->lock);
-                       ret = send_consumer_relayd_sockets(LTTNG_DOMAIN_UST, session->id,
+                       ret = send_consumer_relayd_sockets(session->id,
                                        usess->consumer, socket,
                                        session->name, session->hostname,
                                        session->base_path,
@@ -1026,7 +1026,7 @@ int cmd_setup_relayd(struct ltt_session *session)
                cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter,
                                socket, node.node) {
                        pthread_mutex_lock(socket->lock);
-                       ret = send_consumer_relayd_sockets(LTTNG_DOMAIN_KERNEL, session->id,
+                       ret = send_consumer_relayd_sockets(session->id,
                                        ksess->consumer, socket,
                                        session->name, session->hostname,
                                        session->base_path,
@@ -1274,12 +1274,13 @@ end:
        return ret;
 }
 
-static int cmd_enable_channel_internal(struct ltt_session *session,
+static enum lttng_error_code cmd_enable_channel_internal(
+               struct ltt_session *session,
                const struct lttng_domain *domain,
                const struct lttng_channel *_attr,
                int wpipe)
 {
-       int ret;
+       enum lttng_error_code ret_code;
        struct ltt_ust_session *usess = session->ust_session;
        struct lttng_ht *chan_ht;
        size_t len;
@@ -1291,7 +1292,7 @@ static int cmd_enable_channel_internal(struct ltt_session *session,
 
        attr = lttng_channel_copy(_attr);
        if (!attr) {
-               ret = -LTTNG_ERR_NOMEM;
+               ret_code = LTTNG_ERR_NOMEM;
                goto end;
        }
 
@@ -1300,7 +1301,7 @@ static int cmd_enable_channel_internal(struct ltt_session *session,
        /* Validate channel name */
        if (attr->name[0] == '.' ||
                memchr(attr->name, '/', len) != NULL) {
-               ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
+               ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
                goto end;
        }
 
@@ -1339,12 +1340,12 @@ static int cmd_enable_channel_internal(struct ltt_session *session,
        case LTTNG_DOMAIN_PYTHON:
                if (!agent_tracing_is_enabled()) {
                        DBG("Attempted to enable a channel in an agent domain but the agent thread is not running");
-                       ret = LTTNG_ERR_AGENT_TRACING_DISABLED;
+                       ret_code = LTTNG_ERR_AGENT_TRACING_DISABLED;
                        goto error;
                }
                break;
        default:
-               ret = LTTNG_ERR_UNKNOWN_DOMAIN;
+               ret_code = LTTNG_ERR_UNKNOWN_DOMAIN;
                goto error;
        }
 
@@ -1361,7 +1362,7 @@ static int cmd_enable_channel_internal(struct ltt_session *session,
                         * some point in time before. The tracer does not allow it.
                         */
                        if (session->has_been_started) {
-                               ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
+                               ret_code = LTTNG_ERR_TRACE_ALREADY_STARTED;
                                goto error;
                        }
 
@@ -1370,16 +1371,16 @@ static int cmd_enable_channel_internal(struct ltt_session *session,
                                /* Enforce mmap output for snapshot sessions. */
                                attr->attr.output = LTTNG_EVENT_MMAP;
                        }
-                       ret = channel_kernel_create(
+                       ret_code = channel_kernel_create(
                                        session->kernel_session, attr, wpipe);
                        if (attr->name[0] != '\0') {
                                session->kernel_session->has_non_default_channel = 1;
                        }
                } else {
-                       ret = channel_kernel_enable(session->kernel_session, kchan);
+                       ret_code = channel_kernel_enable(session->kernel_session, kchan);
                }
 
-               if (ret != LTTNG_OK) {
+               if (ret_code != LTTNG_OK) {
                        goto error;
                }
 
@@ -1404,19 +1405,19 @@ static int cmd_enable_channel_internal(struct ltt_session *session,
                if (domain->type == LTTNG_DOMAIN_JUL) {
                        if (strncmp(attr->name, DEFAULT_JUL_CHANNEL_NAME,
                                        LTTNG_SYMBOL_NAME_LEN)) {
-                               ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
+                               ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
                                goto error;
                        }
                } else if (domain->type == LTTNG_DOMAIN_LOG4J) {
                        if (strncmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME,
                                        LTTNG_SYMBOL_NAME_LEN)) {
-                               ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
+                               ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
                                goto error;
                        }
                } else if (domain->type == LTTNG_DOMAIN_PYTHON) {
                        if (strncmp(attr->name, DEFAULT_PYTHON_CHANNEL_NAME,
                                        LTTNG_SYMBOL_NAME_LEN)) {
-                               ret = LTTNG_ERR_INVALID_CHANNEL_NAME;
+                               ret_code = LTTNG_ERR_INVALID_CHANNEL_NAME;
                                goto error;
                        }
                }
@@ -1430,32 +1431,32 @@ static int cmd_enable_channel_internal(struct ltt_session *session,
                         * some point in time before. The tracer does not allow it.
                         */
                        if (session->has_been_started) {
-                               ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
+                               ret_code = LTTNG_ERR_TRACE_ALREADY_STARTED;
                                goto error;
                        }
 
-                       ret = channel_ust_create(usess, attr, domain->buf_type);
+                       ret_code = channel_ust_create(usess, attr, domain->buf_type);
                        if (attr->name[0] != '\0') {
                                usess->has_non_default_channel = 1;
                        }
                } else {
-                       ret = channel_ust_enable(usess, uchan);
+                       ret_code = channel_ust_enable(usess, uchan);
                }
                break;
        }
        default:
-               ret = LTTNG_ERR_UNKNOWN_DOMAIN;
+               ret_code = LTTNG_ERR_UNKNOWN_DOMAIN;
                goto error;
        }
 
-       if (ret == LTTNG_OK && attr->attr.output != LTTNG_EVENT_MMAP) {
+       if (ret_code == LTTNG_OK && attr->attr.output != LTTNG_EVENT_MMAP) {
                session->has_non_mmap_channel = true;
        }
 error:
        rcu_read_unlock();
 end:
        lttng_channel_destroy(attr);
-       return ret;
+       return ret_code;
 }
 
 enum lttng_error_code cmd_process_attr_tracker_get_tracking_policy(
@@ -1922,8 +1923,8 @@ int cmd_add_context(struct command_ctx *cmd_ctx,
                        ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
                        goto error;
                }
-               /* break is _not_ missing here. */
        }
+       /* fall through */
        case LTTNG_DOMAIN_UST:
        {
                struct ltt_ust_session *usess = session->ust_session;
@@ -2818,7 +2819,7 @@ int cmd_start_trace(struct ltt_session *session)
         */
        session->rotated_after_last_stop = false;
 
-       if (session->rotate_timer_period) {
+       if (session->rotate_timer_period && !session->rotation_schedule_timer_enabled) {
                int int_ret = timer_session_rotation_schedule_timer_start(
                                session, session->rotate_timer_period);
 
@@ -3288,6 +3289,7 @@ void cmd_destroy_session_reply(const struct ltt_session *session,
                .cmd_header_size =
                        sizeof(struct lttcomm_session_destroy_command_header),
                .data_size = 0,
+               .fd_count = 0,
        };
        size_t payload_size_before_location;
 
@@ -5038,7 +5040,7 @@ static enum lttng_error_code set_relayd_for_snapshot(
        cds_lfht_for_each_entry(output->socks->ht, &iter.iter,
                        socket, node.node) {
                pthread_mutex_lock(socket->lock);
-               status = send_consumer_relayd_sockets(LTTNG_DOMAIN_NONE, session->id,
+               status = send_consumer_relayd_sockets(session->id,
                                output, socket,
                                session->name, session->hostname,
                                base_path,
@@ -5067,7 +5069,7 @@ static enum lttng_error_code record_kernel_snapshot(
                struct ltt_kernel_session *ksess,
                const struct consumer_output *output,
                const struct ltt_session *session,
-               int wait, uint64_t nb_packets_per_stream)
+               uint64_t nb_packets_per_stream)
 {
        enum lttng_error_code status;
 
@@ -5076,7 +5078,7 @@ static enum lttng_error_code record_kernel_snapshot(
        LTTNG_ASSERT(session);
 
        status = kernel_snapshot_record(
-                       ksess, output, wait, nb_packets_per_stream);
+                       ksess, output, nb_packets_per_stream);
        return status;
 }
 
@@ -5088,7 +5090,7 @@ static enum lttng_error_code record_kernel_snapshot(
 static enum lttng_error_code record_ust_snapshot(struct ltt_ust_session *usess,
                const struct consumer_output *output,
                const struct ltt_session *session,
-               int wait, uint64_t nb_packets_per_stream)
+               uint64_t nb_packets_per_stream)
 {
        enum lttng_error_code status;
 
@@ -5097,7 +5099,7 @@ static enum lttng_error_code record_ust_snapshot(struct ltt_ust_session *usess,
        LTTNG_ASSERT(session);
 
        status = ust_app_snapshot_record(
-                       usess, output, wait, nb_packets_per_stream);
+                       usess, output, nb_packets_per_stream);
        return status;
 }
 
@@ -5191,7 +5193,7 @@ int64_t get_session_nb_packets_per_stream(const struct ltt_session *session,
 
 static
 enum lttng_error_code snapshot_record(struct ltt_session *session,
-               const struct snapshot_output *snapshot_output, int wait)
+               const struct snapshot_output *snapshot_output)
 {
        int64_t nb_packets_per_stream;
        char snapshot_chunk_name[LTTNG_NAME_MAX];
@@ -5311,7 +5313,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
        if (session->kernel_session) {
                ret_code = record_kernel_snapshot(session->kernel_session,
                                snapshot_kernel_consumer_output, session,
-                               wait, nb_packets_per_stream);
+                               nb_packets_per_stream);
                if (ret_code != LTTNG_OK) {
                        goto error_close_trace_chunk;
                }
@@ -5320,7 +5322,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
        if (session->ust_session) {
                ret_code = record_ust_snapshot(session->ust_session,
                                snapshot_ust_consumer_output, session,
-                               wait, nb_packets_per_stream);
+                               nb_packets_per_stream);
                if (ret_code != LTTNG_OK) {
                        goto error_close_trace_chunk;
                }
@@ -5368,7 +5370,8 @@ error:
  * Return LTTNG_OK on success or else a LTTNG_ERR code.
  */
 int cmd_snapshot_record(struct ltt_session *session,
-               const struct lttng_snapshot_output *output, int wait)
+               const struct lttng_snapshot_output *output,
+               int wait __attribute__((unused)))
 {
        enum lttng_error_code cmd_ret = LTTNG_OK;
        int ret;
@@ -5430,7 +5433,7 @@ int cmd_snapshot_record(struct ltt_session *session,
 
                /* Use the global datetime */
                memcpy(tmp_output->datetime, datetime, sizeof(datetime));
-               cmd_ret = snapshot_record(session, tmp_output, wait);
+               cmd_ret = snapshot_record(session, tmp_output);
                if (cmd_ret != LTTNG_OK) {
                        goto error;
                }
@@ -5470,7 +5473,7 @@ int cmd_snapshot_record(struct ltt_session *session,
                                }
                        }
 
-                       cmd_ret = snapshot_record(session, &output_copy, wait);
+                       cmd_ret = snapshot_record(session, &output_copy);
                        if (cmd_ret != LTTNG_OK) {
                                rcu_read_unlock();
                                goto error;
This page took 0.028952 seconds and 4 git commands to generate.