From 843f5df95fcaa45f89b7df96a0050d44255d702d Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 6 Dec 2011 14:43:41 -0500 Subject: [PATCH] API change for lttng_destroy_session prototype Now takes a session name and no lttng_handle anymore. Signed-off-by: David Goulet --- include/lttng/lttng.h | 2 +- liblttngctl/lttngctl.c | 8 ++++---- lttng/commands/destroy.c | 21 ++++----------------- tests/lttng/kernel_all_events_basic.c | 4 ++-- tests/lttng/kernel_event_basic.c | 4 ++-- 5 files changed, 13 insertions(+), 26 deletions(-) diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index a137a4385..5654eb79f 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -242,7 +242,7 @@ extern int lttng_create_session(const char *name, const char *path); * The session will not be useable anymore, tracing will stopped for all * registered trace and tracing buffers will be flushed. */ -extern int lttng_destroy_session(struct lttng_handle *handle); +extern int lttng_destroy_session(const char *name); /* * List all tracing sessions. diff --git a/liblttngctl/lttngctl.c b/liblttngctl/lttngctl.c index 9c3735f38..48e82def7 100644 --- a/liblttngctl/lttngctl.c +++ b/liblttngctl/lttngctl.c @@ -666,17 +666,17 @@ int lttng_create_session(const char *name, const char *path) /* * Destroy session using name. */ -int lttng_destroy_session(struct lttng_handle *handle) +int lttng_destroy_session(const char *session_name) { struct lttcomm_session_msg lsm; - if (handle == NULL) { + if (session_name == NULL) { return -1; } lsm.cmd_type = LTTNG_DESTROY_SESSION; - copy_string(lsm.session.name, handle->session_name, - sizeof(lsm.session.name)); + + copy_string(lsm.session.name, session_name, sizeof(lsm.session.name)); return ask_sessiond(&lsm, NULL); } diff --git a/lttng/commands/destroy.c b/lttng/commands/destroy.c index 3b02a53ee..151686ff9 100644 --- a/lttng/commands/destroy.c +++ b/lttng/commands/destroy.c @@ -30,7 +30,6 @@ #include "../utils.h" static char *opt_session_name; -static struct lttng_handle *handle; enum { OPT_HELP = 1, @@ -57,10 +56,8 @@ static void usage(FILE *ofp) } /* - * destroy_session - * - * Destroy a session removing the config directory and unregistering to the - * session daemon. + * Destroy a session removing the config directory and unregistering to the + * session daemon. */ static int destroy_session() { @@ -77,13 +74,7 @@ static int destroy_session() session_name = opt_session_name; } - handle = lttng_create_handle(session_name, NULL); - if (handle == NULL) { - ret = -1; - goto error; - } - - ret = lttng_destroy_session(handle); + ret = lttng_destroy_session(session_name); if (ret < 0) { goto free_name; } @@ -108,15 +99,11 @@ free_name: free(session_name); } error: - lttng_destroy_handle(handle); - return ret; } /* - * cmd_destroy - * - * The 'destroy ' first level command + * The 'destroy ' first level command */ int cmd_destroy(int argc, const char **argv) { diff --git a/tests/lttng/kernel_all_events_basic.c b/tests/lttng/kernel_all_events_basic.c index 52546287f..eb46decae 100644 --- a/tests/lttng/kernel_all_events_basic.c +++ b/tests/lttng/kernel_all_events_basic.c @@ -93,7 +93,7 @@ int main(int argc, char **argv) PRINT_OK(); printf("Destroy tracing session: "); - if ((ret = lttng_destroy_session(handle)) < 0) { + if ((ret = lttng_destroy_session("test")) < 0) { printf("error destroying session: %s\n", lttng_strerror(ret)); } PRINT_OK(); @@ -108,7 +108,7 @@ handle_fail: stop_fail: start_fail: enable_fail: - lttng_destroy_session(handle); + lttng_destroy_session("test"); lttng_destroy_handle(handle); return 1; diff --git a/tests/lttng/kernel_event_basic.c b/tests/lttng/kernel_event_basic.c index 255557148..d45b5e4f9 100644 --- a/tests/lttng/kernel_event_basic.c +++ b/tests/lttng/kernel_event_basic.c @@ -160,7 +160,7 @@ int main(int argc, char **argv) PRINT_OK(); printf("Destroy tracing session: "); - if ((ret = lttng_destroy_session(handle)) < 0) { + if ((ret = lttng_destroy_session(session_name)) < 0) { printf("error destroying session: %s\n", lttng_strerror(ret)); } PRINT_OK(); @@ -175,7 +175,7 @@ handle_fail: stop_fail: start_fail: enable_fail: - lttng_destroy_session(handle); + lttng_destroy_session(session_name); lttng_destroy_handle(handle); return 1; -- 2.34.1