From a46526fcb6f5ac33dd792e6b399a9a2c054ba682 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 28 Apr 2022 15:51:19 -0400 Subject: [PATCH] Refactor: pass ltt_session directly Signed-off-by: Jonathan Rajotte Change-Id: Ib154d105888863d2de383becbf523c13139dadc2 --- src/bin/lttng-sessiond/cmd.cpp | 66 +++++++++++++--------------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.cpp b/src/bin/lttng-sessiond/cmd.cpp index 0022333b3..be1ab52ab 100644 --- a/src/bin/lttng-sessiond/cmd.cpp +++ b/src/bin/lttng-sessiond/cmd.cpp @@ -899,12 +899,11 @@ error: * * Returns LTTNG_OK, or an LTTng error code on failure. */ -static enum lttng_error_code send_consumer_relayd_sockets( - unsigned int session_id, struct consumer_output *consumer, - struct consumer_socket *sock, const char *session_name, - const char *hostname, const char *base_path, int session_live_timer, - const uint64_t *current_chunk_id, time_t session_creation_time, - bool session_name_contains_creation_time) +static lttng_error_code send_consumer_relayd_sockets(const ltt_session& session, + struct consumer_output *consumer, + struct consumer_socket *sock, + const char *base_path, + const uint64_t *current_chunk_id) { enum lttng_error_code status = LTTNG_OK; struct lttcomm_relayd_sock *control_sock = nullptr; @@ -938,10 +937,10 @@ static enum lttng_error_code send_consumer_relayd_sockets( consumer->relay_allows_clear = true; } - status = send_consumer_relayd_socket(session_id, &consumer->dst.net.control, - consumer, sock, session_name, hostname, base_path, - session_live_timer, current_chunk_id, session_creation_time, - session_name_contains_creation_time, *control_sock); + status = send_consumer_relayd_socket(session.id, &consumer->dst.net.control, + consumer, sock, session.name, session.hostname, base_path, + session.live_timer, current_chunk_id, session.creation_time, + session.name_contains_creation_time, *control_sock); if (status != LTTNG_OK) { goto error; @@ -957,10 +956,10 @@ static enum lttng_error_code send_consumer_relayd_sockets( } LTTNG_ASSERT(data_sock); - status = send_consumer_relayd_socket(session_id, &consumer->dst.net.data, consumer, - sock, session_name, hostname, base_path, session_live_timer, - current_chunk_id, session_creation_time, - session_name_contains_creation_time, *data_sock); + status = send_consumer_relayd_socket(session.id, &consumer->dst.net.data, consumer, + sock, session.name, session.hostname, base_path, session.live_timer, + current_chunk_id, session.creation_time, + session.name_contains_creation_time, *data_sock); if (status != LTTNG_OK) { goto error; @@ -1019,17 +1018,12 @@ int cmd_setup_relayd(struct ltt_session *session) if (usess && usess->consumer && usess->consumer->type == CONSUMER_DST_NET && usess->consumer->enabled) { /* For each consumer socket, send relayd sockets */ - cds_lfht_for_each_entry(usess->consumer->socks->ht, &iter.iter, - socket, node.node) { + cds_lfht_for_each_entry ( + usess->consumer->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); - ret = send_consumer_relayd_sockets(session->id, - usess->consumer, socket, - session->name, session->hostname, + ret = send_consumer_relayd_sockets(*session, usess->consumer, socket, session->base_path, - session->live_timer, - current_chunk_id.is_set ? ¤t_chunk_id.value : NULL, - session->creation_time, - session->name_contains_creation_time); + current_chunk_id.is_set ? ¤t_chunk_id.value : NULL); pthread_mutex_unlock(socket->lock); if (ret != LTTNG_OK) { goto error; @@ -1047,17 +1041,12 @@ int cmd_setup_relayd(struct ltt_session *session) if (ksess && ksess->consumer && ksess->consumer->type == CONSUMER_DST_NET && ksess->consumer->enabled) { - cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter, - socket, node.node) { + cds_lfht_for_each_entry ( + ksess->consumer->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); - ret = send_consumer_relayd_sockets(session->id, - ksess->consumer, socket, - session->name, session->hostname, + ret = send_consumer_relayd_sockets(*session, ksess->consumer, socket, session->base_path, - session->live_timer, - current_chunk_id.is_set ? ¤t_chunk_id.value : NULL, - session->creation_time, - session->name_contains_creation_time); + current_chunk_id.is_set ? ¤t_chunk_id.value : NULL); pthread_mutex_unlock(socket->lock); if (ret != LTTNG_OK) { goto error; @@ -5070,17 +5059,10 @@ static enum lttng_error_code set_relayd_for_snapshot( * snapshot output. */ rcu_read_lock(); - cds_lfht_for_each_entry(output->socks->ht, &iter.iter, - socket, node.node) { + cds_lfht_for_each_entry (output->socks->ht, &iter.iter, socket, node.node) { pthread_mutex_lock(socket->lock); - status = send_consumer_relayd_sockets(session->id, - output, socket, - session->name, session->hostname, - base_path, - session->live_timer, - current_chunk_id.is_set ? ¤t_chunk_id.value : NULL, - session->creation_time, - session->name_contains_creation_time); + status = send_consumer_relayd_sockets(*session, output, socket, base_path, + current_chunk_id.is_set ? ¤t_chunk_id.value : NULL); pthread_mutex_unlock(socket->lock); if (status != LTTNG_OK) { rcu_read_unlock(); -- 2.34.1