- return 0;
-}
-
-static
-int check_session_rotation_pending_relay(struct ltt_session *session)
-{
- int ret;
- struct consumer_socket *socket;
- struct cds_lfht_iter iter;
- bool rotation_completed = true;
- const struct consumer_output *output;
-
- /*
- * Check for a pending rotation on any consumer as we only use
- * it as a "tunnel" to the relayd.
- */
-
- rcu_read_lock();
- if (session->ust_session) {
- cds_lfht_first(session->ust_session->consumer->socks->ht,
- &iter);
- output = session->ust_session->consumer;
- } else {
- cds_lfht_first(session->kernel_session->consumer->socks->ht,
- &iter);
- output = session->kernel_session->consumer;
- }
- assert(cds_lfht_iter_get_node(&iter));
-
- socket = caa_container_of(cds_lfht_iter_get_node(&iter),
- typeof(*socket), node.node);
-
- pthread_mutex_lock(socket->lock);
- DBG("[rotation-thread] Checking for pending relay rotation on session \"%s\", trace archive %" PRIu64 " through the %s consumer",
- session->name, session->current_archive_id - 1,
- lttng_consumer_type_str(socket->type));
- ret = consumer_check_rotation_pending_relay(socket,
- output,
- session->id,
- session->current_archive_id - 1);
- pthread_mutex_unlock(socket->lock);
-
- if (ret == 0) {
- /* Rotation was completed on the relay. */
- DBG("[rotation-thread] Relay rotation of trace archive %" PRIu64 " of session \"%s\" was completed",
- session->current_archive_id - 1,
- session->name);
- } else if (ret == 1) {
- /* Rotation pending on relay. */
- DBG("[rotation-thread] Relay rotation of trace archive %" PRIu64 " of session \"%s\" is pending",
- session->current_archive_id - 1,
- session->name);
- rotation_completed = false;
- } else {
- /* Not a fatal error. */
- ERR("[rotation-thread] Encountered an error when checking if rotation of trace archive %" PRIu64 " of session \"%s\" is pending on the relay",
- session->current_archive_id - 1,
- session->name);
- ret = session_reset_rotation_state(session,
- LTTNG_ROTATION_STATE_ERROR);
- if (ret) {
- ERR("Failed to reset rotation state of session \"%s\"",
- session->name);
- }
- rotation_completed = false;
- }
-
- rcu_read_unlock();
-
- if (rotation_completed) {
- DBG("[rotation-thread] Rotation of trace archive %" PRIu64 " of session \"%s\" is complete on the relay",
- session->current_archive_id - 1,
- session->name);
- session->rotation_pending_relay = false;
- }
- return 0;