Fix: sessiond: don't negate error code on list error
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 2bd010f895c223f83136f1c234f8bead46fbe339..3e3169f7bb6afd594bf7ff56dc728967aabaf14e 100644 (file)
@@ -816,8 +816,7 @@ end:
        return nb_event;
 
 error:
-       /* Negate the error code to differentiate the size from an error */
-       return -ret;
+       return ret;
 }
 
 /*
@@ -2791,6 +2790,16 @@ int cmd_start_trace(struct ltt_session *session)
                }
        }
 
+       /*
+        * Open a packet in every stream of the session to ensure that viewers
+        * can correctly identify the boundaries of the periods during which
+        * tracing was active for this session.
+        */
+       ret = session_open_packets(session);
+       if (ret != LTTNG_OK) {
+               goto error;
+       }
+
        /*
         * Clear the flag that indicates that a rotation was done while the
         * session was stopped.
@@ -3402,9 +3411,17 @@ int cmd_destroy_session(struct ltt_session *session,
                 */
                ret = cmd_rotate_session(session, NULL, true,
                        LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
-               if (ret != LTTNG_OK) {
+               /*
+                * Rotation operations may not be supported by the kernel
+                * tracer. Hence, do not consider this implicit rotation as
+                * a session destruction error. The library has already stopped
+                * the session and waited for pending data; there is nothing
+                * left to do but complete the destruction of the session.
+                */
+               if (ret != LTTNG_OK &&
+                               ret != -LTTNG_ERR_ROTATION_NOT_AVAILABLE_KERNEL) {
                        ERR("Failed to perform a quiet rotation as part of the destruction of session \"%s\": %s",
-                                       session->name, lttng_strerror(-ret));
+                           session->name, lttng_strerror(ret));
                        destruction_last_error = -ret;
                }
        }
This page took 0.046177 seconds and 4 git commands to generate.