#include <common/defaults.hpp>
#include <common/fd-tracker/utils.hpp>
#include <common/time.hpp>
+#include <common/urcu.hpp>
#include <common/utils.hpp>
#include <common/uuid.hpp>
struct lttng_ht_node_u64 *node;
struct lttng_ht_iter iter;
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
lttng_ht_lookup(sessions_ht, &id, &iter);
- node = lttng_ht_iter_get_node_u64(&iter);
+ node = lttng_ht_iter_get_node<lttng_ht_node_u64>(&iter);
if (!node) {
DBG("Session find by ID %" PRIu64 " id NOT found", id);
goto end;
session = nullptr;
}
end:
- rcu_read_unlock();
return session;
}
bool session_has_ongoing_rotation(const struct relay_session *session)
{
bool ongoing_rotation = false;
- struct lttng_ht_iter iter;
- struct relay_session *iterated_session;
ASSERT_LOCKED(session->lock);
goto end;
}
- rcu_read_lock();
/*
* Sample the 'ongoing_rotation' status of all relay sessions that
* originate from the same session daemon session.
*/
- cds_lfht_for_each_entry (sessions_ht->ht, &iter.iter, iterated_session, session_n.node) {
+ for (auto *iterated_session :
+ lttng::urcu::lfht_iteration_adapter<relay_session,
+ decltype(relay_session::session_n),
+ &relay_session::session_n>(*sessions_ht->ht)) {
if (!session_get(iterated_session)) {
continue;
}
break;
}
}
- rcu_read_unlock();
end:
return ongoing_rotation;
static void rcu_destroy_session(struct rcu_head *rcu_head)
{
- struct relay_session *session = caa_container_of(rcu_head, struct relay_session, rcu_node);
+ auto *session = lttng::utils::container_of(rcu_head, &relay_session::rcu_node);
/*
* Since each trace has a reference on the session, it means
* that if we are at the point where we teardown the session, no
if (!session) {
return;
}
- rcu_read_lock();
+ const lttng::urcu::read_lock_guard read_lock;
urcu_ref_put(&session->ref, session_release);
- rcu_read_unlock();
}
int session_close(struct relay_session *session)
{
int ret = 0;
- struct ctf_trace *trace;
- struct lttng_ht_iter iter;
- struct relay_stream *stream;
pthread_mutex_lock(&session->lock);
DBG("closing session %" PRIu64 ": is conn already closed %d",
session->connection_closed = true;
pthread_mutex_unlock(&session->lock);
- rcu_read_lock();
- cds_lfht_for_each_entry (session->ctf_traces_ht->ht, &iter.iter, trace, node.node) {
+ for (auto *trace :
+ lttng::urcu::lfht_iteration_adapter<ctf_trace,
+ decltype(ctf_trace::node),
+ &ctf_trace::node>(*session->ctf_traces_ht->ht)) {
ret = ctf_trace_close(trace);
if (ret) {
- goto rcu_unlock;
+ goto end;
}
}
- cds_list_for_each_entry_rcu(stream, &session->recv_list, recv_node)
- {
+
+ for (auto *stream :
+ lttng::urcu::rcu_list_iteration_adapter<relay_stream, &relay_stream::recv_node>(
+ session->recv_list)) {
/* Close streams which have not been published yet. */
try_stream_close(stream);
}
-rcu_unlock:
- rcu_read_unlock();
+
+end:
if (ret) {
return ret;
}
+
/* Put self-reference from create. */
session_put(session);
return ret;
int session_abort(struct relay_session *session)
{
- int ret = 0;
+ const int ret = 0;
if (!session) {
return 0;
void print_sessions()
{
- struct lttng_ht_iter iter;
- struct relay_session *session;
-
if (!sessions_ht) {
return;
}
- rcu_read_lock();
- cds_lfht_for_each_entry (sessions_ht->ht, &iter.iter, session, session_n.node) {
+ for (auto *session :
+ lttng::urcu::lfht_iteration_adapter<relay_session,
+ decltype(relay_session::session_n),
+ &relay_session::session_n>(*sessions_ht->ht)) {
if (!session_get(session)) {
continue;
}
session->id);
session_put(session);
}
- rcu_read_unlock();
}