- lttng_ht_node_init_ulong(&relay_connection->sock_n,
- (unsigned long) relay_connection->sock->fd);
- rcu_read_lock();
- lttng_ht_add_unique_ulong(relay_connections_ht,
- &relay_connection->sock_n);
- rcu_read_unlock();
- return lttng_poll_add(events,
- relay_connection->sock->fd,
- LPOLLIN | LPOLLRDHUP);
-
-error_read:
- free(relay_connection);
-error:
- return -1;
-}
-
-static
-void deferred_free_connection(struct rcu_head *head)
-{
- struct relay_command *relay_connection =
- caa_container_of(head, struct relay_command, rcu_node);
-
- lttcomm_destroy_sock(relay_connection->sock);
- free(relay_connection);
-}
-
-static
-void relay_del_connection(struct lttng_ht *relay_connections_ht,
- struct lttng_ht_iter *iter, struct relay_command *relay_connection,
- struct lttng_ht *sessions_ht)
-{
- int ret;
-
- ret = lttng_ht_del(relay_connections_ht, iter);
- assert(!ret);
-
- if (relay_connection->type == RELAY_CONTROL) {
- struct relay_stream_recv_handle *node, *tmp_node;
-
- relay_delete_session(relay_connection, sessions_ht);
- lttng_ht_destroy(relay_connection->ctf_traces_ht);
-
- /* Clean up recv list. */
- cds_list_for_each_entry_safe(node, tmp_node,
- &relay_connection->recv_head, node) {
- cds_list_del(&node->node);
- free(node);
- }
- }
-
- call_rcu(&relay_connection->rcu_node, deferred_free_connection);