consumerd: refactor: split read_subbuf into sub-operations
[lttng-tools.git] / src / common / consumer / consumer-stream.h
CommitLineData
51230d70
DG
1/*
2 * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18#ifndef LTTNG_CONSUMER_STREAM_H
19#define LTTNG_CONSUMER_STREAM_H
20
21#include "consumer.h"
22
6f1177cf
JG
23/*
24 * Create a consumer stream.
25 *
26 * The channel lock MUST be acquired.
27 */
28struct lttng_consumer_stream *consumer_stream_create(
29 struct lttng_consumer_channel *channel,
30 uint64_t channel_key,
31 uint64_t stream_key,
32 const char *channel_name,
33 uint64_t relayd_id,
34 uint64_t session_id,
35 struct lttng_trace_chunk *trace_chunk,
36 int cpu,
37 int *alloc_ret,
38 enum consumer_channel_type type,
39 unsigned int monitor);
40
51230d70
DG
41/*
42 * Close stream's file descriptors and, if needed, close stream also on the
43 * relayd side.
44 *
45 * The stream lock MUST be acquired.
46 * The consumer data lock MUST be acquired.
47 */
48void consumer_stream_close(struct lttng_consumer_stream *stream);
49
50/*
51 * Close stream on the relayd side. This call can destroy a relayd if the
52 * conditions are met.
53 *
54 * A RCU read side lock MUST be acquired if the relayd object was looked up in
55 * a hash table before calling this.
56 */
57void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
58 struct consumer_relayd_sock_pair *relayd);
59
60/*
61 * Delete the stream from all possible hash tables.
62 *
63 * The consumer data lock MUST be acquired.
64 */
65void consumer_stream_delete(struct lttng_consumer_stream *stream,
66 struct lttng_ht *ht);
67
68/*
69 * Free the given stream within a RCU call.
70 */
71void consumer_stream_free(struct lttng_consumer_stream *stream);
72
73/*
74 * Destroy a stream completely. This will delete, close and free the stream.
75 * Once return, the stream is NO longer usable. Its channel may get destroyed
76 * if conditions are met.
77 *
78 * This MUST be called WITHOUT the consumer data and stream lock acquired.
79 */
80void consumer_stream_destroy(struct lttng_consumer_stream *stream,
81 struct lttng_ht *ht);
82
10a50311
JD
83/*
84 * Destroy the stream's buffers on the tracer side. This is also called in a
85 * stream destroy.
86 */
87void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream);
88
1c20f0e2
JD
89/*
90 * Write index of a specific stream either on the relayd or local disk.
91 */
92int consumer_stream_write_index(struct lttng_consumer_stream *stream,
50adc264 93 struct ctf_packet_index *index);
1c20f0e2 94
94d49140
JD
95int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx,
96 uint64_t session_id);
97
e5148e25 98/*
84a93c08 99 * Create the output files of a local stream.
e5148e25
JG
100 *
101 * This must be called with the channel's and the stream's lock held.
102 */
103int consumer_stream_create_output_files(struct lttng_consumer_stream *stream,
104 bool create_index);
105
106/*
107 * Rotate the output files of a local stream. This will change the
108 * active output files of both the binary and index in accordance
109 * with the stream's configuration (stream file count).
110 *
111 * This must be called with the channel's and the stream's lock held.
112 */
113int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream);
114
1d18f2d9
JG
115/*
116 * Indicates whether or not a stream is logically deleted. A deleted stream
117 * should no longer be used; its existence is only garanteed by the RCU lock
118 * held by the caller.
119 *
120 * This function must be called with the RCU read side lock held.
121 */
122bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream);
123
51230d70 124#endif /* LTTNG_CONSUMER_STREAM_H */
This page took 0.047491 seconds and 4 git commands to generate.