| 1 | #ifndef _CTF_TRACE_H |
| 2 | #define _CTF_TRACE_H |
| 3 | |
| 4 | /* |
| 5 | * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com> |
| 6 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> |
| 7 | * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 8 | * |
| 9 | * SPDX-License-Identifier: GPL-2.0-only |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <inttypes.h> |
| 14 | #include <urcu/ref.h> |
| 15 | |
| 16 | #include <common/hashtable/hashtable.hpp> |
| 17 | |
| 18 | #include "session.hpp" |
| 19 | #include "stream.hpp" |
| 20 | #include "viewer-stream.hpp" |
| 21 | |
| 22 | struct ctf_trace { |
| 23 | struct urcu_ref ref; /* Every stream has a ref on the trace. */ |
| 24 | struct relay_session *session; /* Back ref to trace session */ |
| 25 | |
| 26 | /* Trace sub-folder relative to the session output path. */ |
| 27 | char *path; |
| 28 | |
| 29 | /* |
| 30 | * The ctf_trace lock nests inside the session lock. |
| 31 | */ |
| 32 | pthread_mutex_t lock; |
| 33 | uint64_t id; |
| 34 | struct relay_viewer_stream *viewer_metadata_stream; /* RCU protected */ |
| 35 | |
| 36 | /* |
| 37 | * Relay streams associated with this ctf trace. |
| 38 | * Updates are protected by the stream_list lock. |
| 39 | * Traversals are protected by RCU. |
| 40 | */ |
| 41 | struct cds_list_head stream_list; |
| 42 | pthread_mutex_t stream_list_lock; |
| 43 | |
| 44 | /* |
| 45 | * Node within session trace hash table. Node is indexed by |
| 46 | * stream path name. |
| 47 | */ |
| 48 | struct lttng_ht_node_str node; |
| 49 | struct rcu_head rcu_node; /* For call_rcu teardown. */ |
| 50 | |
| 51 | /* |
| 52 | * True if the metadata stream of this trace was sent the viewer in the |
| 53 | * past. |
| 54 | */ |
| 55 | bool metadata_stream_sent_to_viewer; |
| 56 | }; |
| 57 | |
| 58 | struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session, |
| 59 | const char *subpath); |
| 60 | bool ctf_trace_get(struct ctf_trace *trace); |
| 61 | void ctf_trace_put(struct ctf_trace *trace); |
| 62 | |
| 63 | int ctf_trace_close(struct ctf_trace *trace); |
| 64 | |
| 65 | struct relay_viewer_stream *ctf_trace_get_viewer_metadata_stream(struct ctf_trace *trace); |
| 66 | |
| 67 | #endif /* _CTF_TRACE_H */ |