kchan = trace_kernel_get_channel_by_name(attr->name,
session->kernel_session);
if (kchan == NULL) {
+ if (session->snapshot.nb_output > 0 ||
+ session->snapshot_mode) {
+ /* Enforce mmap output for snapshot sessions. */
+ attr->attr.output = LTTNG_EVENT_MMAP;
+ }
ret = channel_kernel_create(session->kernel_session, attr, wpipe);
if (attr->name[0] != '\0') {
session->kernel_session->has_non_default_channel = 1;
goto error;
}
+ if (ret == LTTNG_OK && attr->attr.output != LTTNG_EVENT_MMAP) {
+ session->has_non_mmap_channel = true;
+ }
error:
rcu_read_unlock();
end:
/* Flag session that trace should start automatically */
if (usess) {
- /*
- * Even though the start trace might fail, flag this session active so
- * other application coming in are started by default.
- */
- usess->active = 1;
-
ret = ust_app_start_trace_all(usess);
if (ret < 0) {
ret = LTTNG_ERR_UST_START_FAIL;
goto error;
}
- if (session->rotation_schedule_timer_enabled) {
- if (timer_session_rotation_schedule_timer_stop(
- session)) {
- ERR("Failed to stop the \"rotation schedule\" timer of session %s",
- session->name);
- }
- }
-
- /*
- * A rotation is still ongoing. The check timer will continue to wait
- * for the rotation to complete. When the rotation finally completes,
- * a check will be performed to rename the "active" chunk to the
- * expected "timestamp_begin-timestamp_end" format.
- */
- if (session->current_archive_id > 0 &&
- session->rotation_state != LTTNG_ROTATION_STATE_ONGOING) {
- ret = rename_active_chunk(session);
- if (ret) {
- /*
- * This error should not prevent the user from stopping
- * the session. However, it will be reported at the end.
- */
- error_occurred = true;
- }
- }
-
/* Kernel tracer */
if (ksession && ksession->active) {
DBG("Stop kernel tracing");
}
if (usess && usess->active) {
- /*
- * Even though the stop trace might fail, flag this session inactive so
- * other application coming in are not started by default.
- */
- usess->active = 0;
-
ret = ust_app_stop_trace_all(usess);
if (ret < 0) {
ret = LTTNG_ERR_UST_STOP_FAIL;
DBG("Begin destroy session %s (id %" PRIu64 ")", session->name, session->id);
- if (session->rotation_pending_check_timer_enabled) {
- if (timer_session_rotation_pending_check_stop(session)) {
- ERR("Failed to stop the \"rotation pending check\" timer of session %s",
- session->name);
- }
- }
-
if (session->rotation_schedule_timer_enabled) {
if (timer_session_rotation_schedule_timer_stop(
session)) {
session->rotate_size = 0;
}
- /*
- * The rename of the current chunk is performed at stop, but if we rotated
- * the session after the previous stop command, we need to rename the
- * new (and empty) chunk that was started in between.
- */
- if (session->rotated_after_last_stop) {
- rename_active_chunk(session);
+ if (session->current_archive_id != 0) {
+ if (!session->rotated_after_last_stop) {
+ ret = cmd_rotate_session(session, NULL);
+ if (ret != LTTNG_OK) {
+ ERR("Failed to perform an implicit rotation as part of the rotation: %s", lttng_strerror(-ret));
+ }
+ } else {
+ /*
+ * Rename the active chunk to ensure it has a name
+ * of the form ts_begin-ts_end-id.
+ *
+ * Note that no trace data has been produced since
+ * the last rotation; the directory should be
+ * removed.
+ */
+ ret = rename_active_chunk(session);
+ if (ret) {
+ ERR("Failed to rename active chunk during the destruction of session \"%s\"",
+ session->name);
+ }
+ }
}
if (session->shm_path[0]) {
goto error;
}
+ if (session->has_non_mmap_channel) {
+ ret = LTTNG_ERR_SNAPSHOT_UNSUPPORTED;
+ goto error;
+ }
+
/* Only one output is allowed until we have the "tee" feature. */
if (session->snapshot.nb_output == 1) {
ret = LTTNG_ERR_SNAPSHOT_OUTPUT_EXIST;
goto error_snapshot;
}
+ goto end;
+
error_snapshot:
/* Clean up copied sockets so this output can use some other later on. */
consumer_destroy_output_sockets(output->consumer);
error:
+end:
return status;
}
goto end;
}
- if (session->live_timer || session->snapshot_mode ||
- !session->output_traces) {
+ if (session->live_timer || !session->output_traces) {
cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE;
goto end;
}
DBG("Cmd rotate set schedule session %s", session->name);
- if (session->live_timer || session->snapshot_mode ||
- !session->output_traces) {
+ if (session->live_timer || !session->output_traces) {
DBG("Failing ROTATION_SET_SCHEDULE command as the rotation feature is not available for this session");
ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE;
goto end;