Add internal extended channel structure
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.c
index 03b74c0b74771a9d0be8158f152a617123799c47..afa741c05b93554c00ec5dd70d90472123176a8b 100644 (file)
@@ -150,7 +150,7 @@ end:
  * On success, returns the number of bytes sent (>=0)
  * On error, returns -1
  */
-static int send_session_varlen(void *data, size_t len)
+static int send_session_varlen(const void *data, size_t len)
 {
        int ret;
 
@@ -400,7 +400,7 @@ static int disconnect_sessiond(void)
  */
 LTTNG_HIDDEN
 int lttng_ctl_ask_sessiond_varlen(struct lttcomm_session_msg *lsm,
-               void *vardata, size_t varlen, void **buf)
+               const void *vardata, size_t varlen, void **buf)
 {
        int ret;
        size_t size;
@@ -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.025479 seconds and 5 git commands to generate.