2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <common/common.h>
22 #include "connection.h"
25 static void rcu_free_connection(struct rcu_head
*head
)
27 struct relay_connection
*conn
=
28 caa_container_of(head
, struct relay_connection
, rcu_node
);
30 lttcomm_destroy_sock(conn
->sock
);
31 connection_free(conn
);
35 * Must be called with a read side lock held. The read side lock must be
36 * kept until the returned relay_connection is no longer in use.
38 struct relay_connection
*connection_find_by_sock(struct lttng_ht
*ht
, int sock
)
40 struct lttng_ht_node_ulong
*node
;
41 struct lttng_ht_iter iter
;
42 struct relay_connection
*conn
= NULL
;
47 lttng_ht_lookup(ht
, (void *)((unsigned long) sock
), &iter
);
48 node
= lttng_ht_iter_get_node_ulong(&iter
);
50 DBG2("Relay connection by sock %d not found", sock
);
53 conn
= caa_container_of(node
, struct relay_connection
, sock_n
);
59 void connection_delete(struct lttng_ht
*ht
, struct relay_connection
*conn
)
62 struct lttng_ht_iter iter
;
67 iter
.iter
.node
= &conn
->sock_n
.node
;
68 ret
= lttng_ht_del(ht
, &iter
);
72 void connection_destroy(struct relay_connection
*conn
)
76 call_rcu(&conn
->rcu_node
, rcu_free_connection
);
79 struct relay_connection
*connection_create(void)
81 struct relay_connection
*conn
;
83 conn
= zmalloc(sizeof(*conn
));
85 PERROR("zmalloc relay connection");
93 void connection_init(struct relay_connection
*conn
)
98 CDS_INIT_LIST_HEAD(&conn
->recv_head
);
99 lttng_ht_node_init_ulong(&conn
->sock_n
, (unsigned long) conn
->sock
->fd
);
102 void connection_free(struct relay_connection
*conn
)
106 free(conn
->viewer_session
);
This page took 0.065705 seconds and 4 git commands to generate.