Cleanup: Reduce scope of relayd connections in live thread
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 27 Feb 2015 16:34:04 +0000 (11:34 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 27 Feb 2015 16:34:04 +0000 (11:34 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/live.c

index ed52012407be36ef76a04d1c494a028d148bf6cd..562a7fa522017ae4126d2d7b76847fbed9f81dc6 100644 (file)
@@ -1863,13 +1863,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");
 
@@ -1950,6 +1950,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;
@@ -1965,6 +1967,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. */
@@ -2002,10 +2006,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:
This page took 0.027337 seconds and 4 git commands to generate.