Fix: sessiond: don't wait for a rotation from a null chunk to finish
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 5a122d8d3c8dcf7e7f361b34f69f46c4680c0d22..7c9477df938787407dc5eaf8b0c569ddfa0557a5 100644 (file)
@@ -4925,9 +4925,6 @@ int cmd_rotate_session(struct ltt_session *session,
                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);
@@ -4951,11 +4948,6 @@ int cmd_rotate_session(struct ltt_session *session,
                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) {
@@ -4971,6 +4963,26 @@ int cmd_rotate_session(struct ltt_session *session,
                }
        }
 
+       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 :
@@ -4995,10 +5007,6 @@ int cmd_rotate_session(struct ltt_session *session,
                goto error;
        }
 
-       if (!session->active) {
-               session->rotated_after_last_stop = true;
-       }
-
        if (rotate_return) {
                rotate_return->rotation_id = ongoing_rotation_chunk_id;
        }
This page took 0.032467 seconds and 4 git commands to generate.