X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=5868c829f689d7015fc839ff8048197e182b5ea0;hb=19bfbd16a509837bbe57f9c00d6c2a1f0933a5a9;hp=e067cb835e1a2739dfa35f83ce32a3d3c59b586a;hpb=95b2346e7dc4f74f2bc62b65dc1eede129b17275;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index e067cb835..5868c829f 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -517,7 +517,6 @@ static int list_lttng_agent_events(struct agent *agt, rcu_read_lock(); nb_event = lttng_ht_get_count(agt->events); - rcu_read_unlock(); if (nb_event == 0) { ret = nb_event; *total_size = 0; @@ -531,7 +530,6 @@ static int list_lttng_agent_events(struct agent *agt, * This is only valid because the commands which add events are * processed in the same thread as the listing. */ - rcu_read_lock(); cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) { ret = increment_extended_len(event->filter_expression, NULL, NULL, &extended_len); @@ -541,7 +539,6 @@ static int list_lttng_agent_events(struct agent *agt, goto error; } } - rcu_read_unlock(); *total_size = nb_event * sizeof(*tmp_events) + extended_len; tmp_events = zmalloc(*total_size); @@ -554,7 +551,6 @@ static int list_lttng_agent_events(struct agent *agt, extended_at = ((uint8_t *) tmp_events) + nb_event * sizeof(struct lttng_event); - rcu_read_lock(); cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) { strncpy(tmp_events[i].name, event->name, sizeof(tmp_events[i].name)); tmp_events[i].name[sizeof(tmp_events[i].name) - 1] = '\0'; @@ -823,8 +819,7 @@ end: return nb_event; error: - /* Negate the error code to differentiate the size from an error */ - return -ret; + return ret; } /* @@ -1512,15 +1507,6 @@ int cmd_enable_channel(struct ltt_session *session, rcu_read_lock(); - /* - * Don't try to enable a channel if the session has been started at - * some point in time before. The tracer does not allow it. - */ - if (session->has_been_started) { - ret = LTTNG_ERR_TRACE_ALREADY_STARTED; - goto error; - } - /* * If the session is a live session, remove the switch timer, the * live timer does the same thing but sends also synchronisation @@ -1569,6 +1555,15 @@ int cmd_enable_channel(struct ltt_session *session, kchan = trace_kernel_get_channel_by_name(attr.name, session->kernel_session); if (kchan == NULL) { + /* + * Don't try to create a channel if the session has been started at + * some point in time before. The tracer does not allow it. + */ + if (session->has_been_started) { + ret = LTTNG_ERR_TRACE_ALREADY_STARTED; + goto error; + } + if (session->snapshot.nb_output > 0 || session->snapshot_mode) { /* Enforce mmap output for snapshot sessions. */ @@ -1628,6 +1623,15 @@ int cmd_enable_channel(struct ltt_session *session, uchan = trace_ust_find_channel_by_name(chan_ht, attr.name); if (uchan == NULL) { + /* + * Don't try to create a channel if the session has been started at + * some point in time before. The tracer does not allow it. + */ + if (session->has_been_started) { + ret = LTTNG_ERR_TRACE_ALREADY_STARTED; + goto error; + } + ret = channel_ust_create(usess, &attr, domain->buf_type); if (attr.name[0] != '\0') { usess->has_non_default_channel = 1; @@ -4540,7 +4544,7 @@ int64_t get_session_nb_packets_per_stream(const struct ltt_session *session, } cur_nb_packets++; } - if (!cur_nb_packets) { + if (!cur_nb_packets && size_left != max_size) { /* Not enough room to grab one packet of each stream, error. */ return -1; } @@ -4653,7 +4657,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, snapshot_output->max_size); if (nb_packets_per_stream < 0) { ret_code = LTTNG_ERR_MAX_SIZE_INVALID; - goto error; + goto error_close_trace_chunk; } if (session->kernel_session) { @@ -4661,7 +4665,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, snapshot_kernel_consumer_output, session, wait, nb_packets_per_stream); if (ret_code != LTTNG_OK) { - goto error; + goto error_close_trace_chunk; } } @@ -4670,10 +4674,10 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, snapshot_ust_consumer_output, session, wait, nb_packets_per_stream); if (ret_code != LTTNG_OK) { - goto error; + goto error_close_trace_chunk; } } - +error_close_trace_chunk: if (session_close_trace_chunk( session, session->current_trace_chunk, NULL, NULL)) { /* @@ -4907,6 +4911,12 @@ int cmd_rotate_session(struct ltt_session *session, goto end; } + /* Unsupported feature in lttng-modules before 2.8 (lack of sequence number). */ + if (session->kernel_session && !kernel_supports_ring_buffer_packet_sequence_number()) { + cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE_KERNEL; + goto end; + } + if (session->rotation_state == LTTNG_ROTATION_STATE_ONGOING) { DBG("Refusing to launch a rotation; a rotation is already in progress for session %s", session->name);