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=14bb7b32dab3f1559a0468cdc484c456961fdbd5;hb=8d7f6956990e8d0e0f32a532321db44263c6903f;hpb=c2d6932774987366baf42a93461cd73c38f1113a diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 14bb7b32d..afa741c05 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -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.