Commit | Line | Data |
---|---|---|
2f8f53af DG |
1 | /* |
2 | * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com> | |
3 | * David Goulet <dgoulet@efficios.com> | |
4 | * | |
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. | |
8 | * | |
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 | |
12 | * more details. | |
13 | * | |
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. | |
17 | */ | |
18 | ||
19 | #include "session.h" | |
20 | ||
21 | /* | |
22 | * Lookup a session within the given hash table and session id. RCU read side | |
23 | * lock MUST be acquired before calling this and as long as the caller has a | |
24 | * reference to the object. | |
25 | * | |
26 | * Return session or NULL if not found. | |
27 | */ | |
28 | struct relay_session *session_find_by_id(struct lttng_ht *ht, uint64_t id) | |
29 | { | |
30 | struct relay_session *session = NULL; | |
31 | struct lttng_ht_node_ulong *node; | |
32 | struct lttng_ht_iter iter; | |
33 | ||
34 | assert(ht); | |
35 | ||
36 | lttng_ht_lookup(ht, (void *)((unsigned long) id), &iter); | |
37 | node = lttng_ht_iter_get_node_ulong(&iter); | |
38 | if (!node) { | |
39 | goto end; | |
40 | } | |
41 | session = caa_container_of(node, struct relay_session, session_n); | |
42 | ||
43 | end: | |
44 | return session; | |
45 | } |