+ /* Ignore session name in case all sessions are to be destroyed */
+ if (opt_destroy_all) {
+ command_ret = destroy_all_sessions(sessions, count);
+ if (command_ret) {
+ success = 0;
+ }
+ } else {
+ opt_session_name = (char *) poptGetArg(pc);
+
+ if (!opt_session_name) {
+ /* No session name specified, lookup default */
+ session_name = get_session_name();
+ if (session_name == NULL) {
+ command_ret = CMD_ERROR;
+ success = 0;
+ goto mi_closing;
+ }
+ } else {
+ session_name = opt_session_name;
+ }
+
+ /* Find the corresponding lttng_session struct */
+ found = 0;
+ for (i = 0; i < count; i++) {
+ if (strncmp(sessions[i].name, session_name, NAME_MAX) == 0) {
+ found = 1;
+ command_ret = destroy_session(&sessions[i]);
+ if (command_ret) {
+ success = 0;
+ }
+
+ }
+ }