Refactor: pass ltt_session directly
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 28 Apr 2022 19:51:19 +0000 (15:51 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 19 Aug 2022 16:00:30 +0000 (12:00 -0400)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Ib154d105888863d2de383becbf523c13139dadc2

src/bin/lttng-sessiond/cmd.cpp

index 0022333b3b34caf8d357bf478bbc24f60645c741..be1ab52ab2b315df51cd7ff3dff297acca773096 100644 (file)
@@ -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 ? &current_chunk_id.value : NULL,
-                                       session->creation_time,
-                                       session->name_contains_creation_time);
+                                       current_chunk_id.is_set ? &current_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 ? &current_chunk_id.value : NULL,
-                                       session->creation_time,
-                                       session->name_contains_creation_time);
+                                       current_chunk_id.is_set ? &current_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 ? &current_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 ? &current_chunk_id.value : NULL);
                pthread_mutex_unlock(socket->lock);
                if (status != LTTNG_OK) {
                        rcu_read_unlock();
This page took 0.038242 seconds and 5 git commands to generate.