X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fdestroy.c;h=7b7ea0e8028cec3f15e160f4f2c374079982fc5f;hp=5b69cb5d9b45e54f7f7877f859bde66eb5febd54;hb=fd076c09672458b1bc5a8ea46f8fe060f5f8ab43;hpb=b09ee5ba37c5b43ae724cdbdca7ca3038fb1f61b diff --git a/src/bin/lttng/commands/destroy.c b/src/bin/lttng/commands/destroy.c index 5b69cb5d9..7b7ea0e80 100644 --- a/src/bin/lttng/commands/destroy.c +++ b/src/bin/lttng/commands/destroy.c @@ -28,6 +28,7 @@ #include +static char *opt_session_name; static int opt_destroy_all; enum { @@ -156,28 +157,32 @@ int cmd_destroy(int argc, const char **argv) goto end; } - session_name = (char *) poptGetArg(pc); - - /* - * ignore session name in case all - * sessions are to be destroyed - */ + /* Ignore session name in case all sessions are to be destroyed */ if (opt_destroy_all) { ret = destroy_all_sessions(); goto end; } - if (session_name == NULL) { - ret = get_default_session_name(&session_name); - if (ret < 0 || session_name == NULL) { + + opt_session_name = (char *) poptGetArg(pc); + + if (opt_session_name == NULL) { + /* No session name specified, lookup default */ + session_name = get_session_name(); + if (session_name == NULL) { + ret = CMD_ERROR; goto end; } + } else { + session_name = opt_session_name; } + ret = destroy_session(session_name); end: - poptFreeContext(pc); - if (session_name != NULL) { + if (opt_session_name == NULL) { free(session_name); } + + poptFreeContext(pc); return ret; }