Fix: code refactoring of viewer streams in relayd
[lttng-tools.git] / src / bin / lttng-relayd / session.c
CommitLineData
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 */
28struct 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
43end:
44 return session;
45}
This page took 0.033323 seconds and 4 git commands to generate.