From f89048c17c5baf5bda4e791823e49ffb0d99facc Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 27 Feb 2015 11:34:04 -0500 Subject: [PATCH 1/1] Cleanup: Reduce scope of relayd connections in live thread MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/live.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index ff2bbda83..938fcd4f5 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -1862,13 +1862,13 @@ void *thread_worker(void *data) { int ret, err = -1; uint32_t nb_fd; - struct relay_connection *conn; struct lttng_poll_event events; struct lttng_ht *relay_connections_ht; struct lttng_ht_iter iter; struct lttng_viewer_cmd recv_hdr; struct relay_local_data *relay_ctx = (struct relay_local_data *) data; struct lttng_ht *sessions_ht = relay_ctx->sessions_ht; + struct relay_connection *destroy_conn; DBG("[thread] Live viewer relay worker started"); @@ -1949,6 +1949,8 @@ restart: ERR("Relay live pipe error"); goto error; } else if (revents & LPOLLIN) { + struct relay_connection *conn; + ret = lttng_read(live_conn_pipe[0], &conn, sizeof(conn)); if (ret < 0) { goto error; @@ -1964,6 +1966,8 @@ restart: DBG("Connection socket %d added", conn->sock->fd); } } else { + struct relay_connection *conn; + rcu_read_lock(); conn = connection_find_by_sock(relay_connections_ht, pollfd); /* If not found, there is a synchronization issue. */ @@ -2001,10 +2005,11 @@ error: /* Cleanup reamaining connection object. */ rcu_read_lock(); - cds_lfht_for_each_entry(relay_connections_ht->ht, &iter.iter, conn, + cds_lfht_for_each_entry(relay_connections_ht->ht, &iter.iter, + destroy_conn, sock_n.node) { health_code_update(); - destroy_connection(relay_connections_ht, conn); + destroy_connection(relay_connections_ht, destroy_conn); } rcu_read_unlock(); error_poll_create: -- 2.34.1