X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=afa741c05b93554c00ec5dd70d90472123176a8b;hp=03b74c0b74771a9d0be8158f152a617123799c47;hb=8d7f6956990e8d0e0f32a532321db44263c6903f;hpb=2001793c1141e89b34e70efb28b27ec0cc8e6d47 diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 03b74c0b7..afa741c05 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -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.