rcu_read_lock();
nb_event = lttng_ht_get_count(agt->events);
- rcu_read_unlock();
if (nb_event == 0) {
ret = nb_event;
*total_size = 0;
* 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);
goto error;
}
}
- rcu_read_unlock();
*total_size = nb_event * sizeof(*tmp_events) + extended_len;
tmp_events = zmalloc(*total_size);
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';
return nb_event;
error:
- /* Negate the error code to differentiate the size from an error */
- return -ret;
+ return ret;
}
/*
DBG("Setting relayd for session %s", session->name);
+ rcu_read_lock();
if (session->current_trace_chunk) {
enum lttng_trace_chunk_status status = lttng_trace_chunk_get_id(
session->current_trace_chunk, ¤t_chunk_id.value);
}
}
- rcu_read_lock();
-
if (usess && usess->consumer && usess->consumer->type == CONSUMER_DST_NET
&& usess->consumer->enabled) {
/* For each consumer socket, send relayd sockets */
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
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. */
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;
}
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;
}
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) {
snapshot_kernel_consumer_output, session,
wait, nb_packets_per_stream);
if (ret_code != LTTNG_OK) {
- goto error;
+ goto error_close_trace_chunk;
}
}
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)) {
/*
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);
cmd_ret = LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP;
goto end;
}
-
- session->rotation_state = LTTNG_ROTATION_STATE_ONGOING;
-
if (session->active) {
new_trace_chunk = session_create_new_trace_chunk(session, NULL,
NULL, NULL);
goto error;
}
- assert(chunk_being_archived);
- chunk_status = lttng_trace_chunk_get_id(chunk_being_archived,
- &ongoing_rotation_chunk_id);
- assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
-
if (session->kernel_session) {
cmd_ret = kernel_rotate_session(session);
if (cmd_ret != LTTNG_OK) {
}
}
+ if (!session->active) {
+ session->rotated_after_last_stop = true;
+ }
+
+ if (!chunk_being_archived) {
+ DBG("Rotating session \"%s\" from a \"NULL\" trace chunk to a new trace chunk, skipping completion check",
+ session->name);
+ if (failed_to_rotate) {
+ cmd_ret = rotation_fail_code;
+ goto error;
+ }
+ cmd_ret = LTTNG_OK;
+ goto end;
+ }
+
+ session->rotation_state = LTTNG_ROTATION_STATE_ONGOING;
+ chunk_status = lttng_trace_chunk_get_id(chunk_being_archived,
+ &ongoing_rotation_chunk_id);
+ assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
+
ret = session_close_trace_chunk(session, chunk_being_archived,
quiet_rotation ?
NULL :
goto error;
}
- if (!session->active) {
- session->rotated_after_last_stop = true;
- }
-
if (rotate_return) {
rotate_return->rotation_id = ongoing_rotation_chunk_id;
}