+/*
+ * Atomically check if new streams got added in the session since the last
+ * check and reset the flag to 0.
+ *
+ * Returns 1 if new streams got added, 0 if nothing changed, a negative value
+ * on error.
+ */
+static
+int check_new_streams(uint64_t session_id, struct lttng_ht *sessions_ht)
+{
+ struct lttng_ht_node_ulong *node;
+ struct lttng_ht_iter iter;
+ struct relay_session *session;
+ unsigned long current_val;
+ int ret;
+
+ lttng_ht_lookup(sessions_ht,
+ (void *)((unsigned long) session_id), &iter);
+ node = lttng_ht_iter_get_node_ulong(&iter);
+ if (node == NULL) {
+ DBG("Relay session %" PRIu64 " not found", session_id);
+ ret = -1;
+ goto error;
+ }
+
+ session = caa_container_of(node, struct relay_session, session_n);
+
+ current_val = uatomic_cmpxchg(&session->new_streams, 1, 0);
+ ret = current_val;
+
+error:
+ return ret;
+}
+