- ret = lttng_destroy_session(session_name);
- if (ret < 0) {
- switch (-ret) {
- case LTTCOMM_SESS_NOT_FOUND:
- WARN("Session name %s not found", session_name);
+ /*
+ * Data sleep time before retrying (in usec). Don't sleep if the call
+ * returned value indicates availability.
+ */
+ if (ret) {
+ if (!printed_wait_msg) {
+ _MSG("Waiting for destruction of session \"%s\"",
+ session->name);
+ printed_wait_msg = true;
+ fflush(stdout);
+ }
+
+ usleep(DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US);
+ _MSG(".");
+ fflush(stdout);
+ }
+ } while (ret != 0);
+ }
+ if (!session_was_stopped) {
+ /*
+ * Don't print the event and packet loss warnings since the user
+ * already saw them when stopping the trace.
+ */
+ print_session_stats(session->name);
+ }
+
+ ret_code = lttng_destroy_session_ext(session->name, &handle);
+ if (ret_code != LTTNG_OK) {
+ ret = -ret_code;
+ goto error;
+ }
+
+ if (opt_no_wait) {
+ goto skip_wait_rotation;
+ }
+
+ do {
+ status = lttng_destruction_handle_wait_for_completion(handle,
+ DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US / USEC_PER_MSEC);
+ switch (status) {
+ case LTTNG_DESTRUCTION_HANDLE_STATUS_TIMEOUT:
+ if (!printed_wait_msg) {
+ _MSG("Waiting for destruction of session \"%s\"",
+ session->name);
+ printed_wait_msg = true;
+ }
+ _MSG(".");
+ fflush(stdout);