- enum lttng_domain_type domain;
- struct rotation_channel_info *channel_info;
- struct ltt_session *session = NULL;
- uint64_t key;
-
- if (fd == handle->ust32_consumer ||
- fd == handle->ust64_consumer) {
- domain = LTTNG_DOMAIN_UST;
- } else if (fd == handle->kernel_consumer) {
- domain = LTTNG_DOMAIN_KERNEL;
+ struct consumer_socket *socket;
+ struct cds_lfht_iter iter;
+ bool rotation_completed = true;
+
+ /*
+ * Check for a local pending rotation on all consumers (32-bit
+ * user space, 64-bit user space, and kernel).
+ */
+ DBG("[rotation-thread] Checking for pending local rotation on session \"%s\", trace archive %" PRIu64,
+ session->name, session->current_archive_id - 1);
+
+ rcu_read_lock();
+ if (!session->ust_session) {
+ goto skip_ust;
+ }
+ cds_lfht_for_each_entry(session->ust_session->consumer->socks->ht,
+ &iter, socket, node.node) {
+ ret = check_session_rotation_pending_local_on_consumer(session,
+ socket, &rotation_completed);
+ if (ret || !rotation_completed) {
+ goto end;
+ }
+ }
+
+skip_ust:
+ if (!session->kernel_session) {
+ goto skip_kernel;
+ }
+ cds_lfht_for_each_entry(session->kernel_session->consumer->socks->ht,
+ &iter, socket, node.node) {
+ ret = check_session_rotation_pending_local_on_consumer(session,
+ socket, &rotation_completed);
+ if (ret || !rotation_completed) {
+ goto end;
+ }
+ }
+skip_kernel:
+end:
+ rcu_read_unlock();
+
+ if (rotation_completed) {
+ DBG("[rotation-thread] Local rotation of trace archive %" PRIu64 " of session \"%s\" is complete on all consumers",
+ session->current_archive_id - 1,
+ session->name);
+ session->rotation_pending_local = false;
+ }
+ if (ret) {
+ ret = session_reset_rotation_state(session,
+ LTTNG_ROTATION_STATE_ERROR);
+ if (ret) {
+ ERR("Failed to reset rotation state of session \"%s\"",
+ session->name);
+ }
+ }
+ 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;