- ret = lttng_destroy_session(session->name);
- if (ret < 0) {
- switch (-ret) {
- case LTTNG_ERR_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_destroy_msg) {
+ _MSG("Destroying session %s",
+ session->name);
+ newline_needed = true;
+ printed_destroy_msg = true;
+ fflush(stdout);
+ }
+
+ usleep(DEFAULT_DATA_AVAILABILITY_WAIT_TIME_US);
+ _MSG(".");
+ fflush(stdout);
+ }
+ } while (ret != 0);
+ }
+
+ if (!session_was_already_stopped) {
+ /*
+ * Don't print the event and packet loss warnings since the user
+ * already saw them when stopping the trace.
+ */
+ ret = get_session_stats_str(session->name, &stats_str);
+ if (ret < 0) {
+ goto error;
+ }
+ }
+
+ 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_destroy_msg) {
+ _MSG("Destroying session %s", session->name);
+ newline_needed = true;
+ printed_destroy_msg = true;
+ }
+ _MSG(".");
+ fflush(stdout);