X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=0330186209268cb63b49175e08d4a4102d07e96a;hp=def3e64e59a2d27899d1b70dba0f74e74a7b7dea;hb=92fe5ca1528abfa90cc26f767d274dbff61ffc61;hpb=e32d7f274604b77bcd83c24994e88df3761ed658 diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index def3e64e5..033018620 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2684,12 +2684,6 @@ int cmd_start_trace(struct ltt_session *session) /* 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; @@ -2747,32 +2741,6 @@ int cmd_stop_trace(struct ltt_session *session) 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"); @@ -2807,12 +2775,6 @@ int cmd_stop_trace(struct ltt_session *session) } 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; @@ -3056,13 +3018,6 @@ int cmd_destroy_session(struct ltt_session *session, 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)) { @@ -3076,13 +3031,27 @@ int cmd_destroy_session(struct ltt_session *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]) { @@ -4210,10 +4179,13 @@ static enum lttng_error_code record_ust_snapshot(struct ltt_ust_session *usess, 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; } @@ -4527,8 +4499,7 @@ int cmd_rotate_session(struct ltt_session *session, 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; } @@ -4602,7 +4573,7 @@ int cmd_rotate_session(struct ltt_session *session, now = time(NULL); if (now == (time_t) -1) { - cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE; + cmd_ret = LTTNG_ERR_UNK; goto end; } @@ -4877,8 +4848,7 @@ int cmd_rotation_set_schedule(struct ltt_session *session, 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;