| 1 | #ifndef _VIEWER_SESSION_H |
| 2 | #define _VIEWER_SESSION_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com> |
| 6 | * David Goulet <dgoulet@efficios.com> |
| 7 | * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License, version 2 only, as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * this program; if not, write to the Free Software Foundation, Inc., 51 |
| 20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ |
| 22 | |
| 23 | #include <limits.h> |
| 24 | #include <inttypes.h> |
| 25 | #include <pthread.h> |
| 26 | #include <urcu/list.h> |
| 27 | #include <urcu/ref.h> |
| 28 | |
| 29 | #include <common/hashtable/hashtable.h> |
| 30 | #include <common/trace-chunk.h> |
| 31 | |
| 32 | #include "session.h" |
| 33 | |
| 34 | struct relay_viewer_session { |
| 35 | /* |
| 36 | * Session list. Updates are protected by the session_list_lock. |
| 37 | * Traversals are protected by RCU. |
| 38 | * This list limits the design to having the sessions in at most |
| 39 | * one viewer session. |
| 40 | */ |
| 41 | struct cds_list_head session_list; /* RCU list. */ |
| 42 | pthread_mutex_t session_list_lock; /* Protects list updates. */ |
| 43 | /* Once set, the current trace chunk of a viewer must not change. */ |
| 44 | struct lttng_trace_chunk *current_trace_chunk; |
| 45 | }; |
| 46 | |
| 47 | struct relay_viewer_session *viewer_session_create(void); |
| 48 | void viewer_session_destroy(struct relay_viewer_session *vsession); |
| 49 | void viewer_session_close(struct relay_viewer_session *vsession); |
| 50 | |
| 51 | enum lttng_viewer_attach_return_code viewer_session_attach( |
| 52 | struct relay_viewer_session *vsession, |
| 53 | struct relay_session *session); |
| 54 | int viewer_session_is_attached(struct relay_viewer_session *vsession, |
| 55 | struct relay_session *session); |
| 56 | void viewer_session_close_one_session(struct relay_viewer_session *vsession, |
| 57 | struct relay_session *session); |
| 58 | int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession, |
| 59 | struct lttng_trace_chunk *relay_session_trace_chunk); |
| 60 | |
| 61 | #endif /* _VIEWER_SESSION_H */ |