Add internal extended channel structure
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 14bb7b32dab3f1559a0468cdc484c456961fdbd5..afa741c05b93554c00ec5dd70d90472123176a8b 100644 (file)
@@ -1525,7 +1525,7 @@ int lttng_create_session(const char *name, const char *url)
  * Destroy session using name.
  * Returns size of returned session payload data or a negative error code.
  */
-int lttng_destroy_session(const char *session_name)
+int _lttng_destroy_session(const char *session_name)
 {
        struct lttcomm_session_msg lsm;
 
@@ -1542,6 +1542,48 @@ int lttng_destroy_session(const char *session_name)
        return lttng_ctl_ask_sessiond(&lsm, NULL);
 }
 
+/*
+ * Stop the session and wait for the data before destroying it
+ */
+int lttng_destroy_session(const char *session_name)
+{
+       int ret;
+
+       /*
+        * Stop the tracing and wait for the data.
+        */
+       ret = _lttng_stop_tracing(session_name, 1);
+       if (ret && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) {
+               goto end;
+       }
+
+       ret = _lttng_destroy_session(session_name);
+end:
+       return ret;
+}
+
+/*
+ * Destroy the session without waiting for the data.
+ */
+int lttng_destroy_session_no_wait(const char *session_name)
+{
+       int ret;
+
+       /*
+        * Stop the tracing without waiting for the data.
+        * The session might already have been stopped, so just
+        * skip this error.
+        */
+       ret = _lttng_stop_tracing(session_name, 0);
+       if (ret && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) {
+               goto end;
+       }
+
+       ret = _lttng_destroy_session(session_name);
+end:
+       return ret;
+}
+
 /*
  * Ask the session daemon for all available sessions.
  * Sets the contents of the sessions array.
This page took 0.024916 seconds and 5 git commands to generate.