* 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;
*/
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;
* 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;
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.