| 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 | |
| 23 | /* |
| 24 | * Close stream's file descriptors and, if needed, close stream also on the |
| 25 | * relayd side. |
| 26 | * |
| 27 | * The stream lock MUST be acquired. |
| 28 | * The consumer data lock MUST be acquired. |
| 29 | */ |
| 30 | void consumer_stream_close(struct lttng_consumer_stream *stream); |
| 31 | |
| 32 | /* |
| 33 | * Close stream on the relayd side. This call can destroy a relayd if the |
| 34 | * conditions are met. |
| 35 | * |
| 36 | * A RCU read side lock MUST be acquired if the relayd object was looked up in |
| 37 | * a hash table before calling this. |
| 38 | */ |
| 39 | void consumer_stream_relayd_close(struct lttng_consumer_stream *stream, |
| 40 | struct consumer_relayd_sock_pair *relayd); |
| 41 | |
| 42 | /* |
| 43 | * Delete the stream from all possible hash tables. |
| 44 | * |
| 45 | * The consumer data lock MUST be acquired. |
| 46 | */ |
| 47 | void consumer_stream_delete(struct lttng_consumer_stream *stream, |
| 48 | struct lttng_ht *ht); |
| 49 | |
| 50 | /* |
| 51 | * Free the given stream within a RCU call. |
| 52 | */ |
| 53 | void consumer_stream_free(struct lttng_consumer_stream *stream); |
| 54 | |
| 55 | /* |
| 56 | * Destroy a stream completely. This will delete, close and free the stream. |
| 57 | * Once return, the stream is NO longer usable. Its channel may get destroyed |
| 58 | * if conditions are met. |
| 59 | * |
| 60 | * This MUST be called WITHOUT the consumer data and stream lock acquired. |
| 61 | */ |
| 62 | void consumer_stream_destroy(struct lttng_consumer_stream *stream, |
| 63 | struct lttng_ht *ht); |
| 64 | |
| 65 | /* |
| 66 | * Destroy the stream's buffers on the tracer side. This is also called in a |
| 67 | * stream destroy. |
| 68 | */ |
| 69 | void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream); |
| 70 | |
| 71 | /* |
| 72 | * Write index of a specific stream either on the relayd or local disk. |
| 73 | */ |
| 74 | int consumer_stream_write_index(struct lttng_consumer_stream *stream, |
| 75 | struct ctf_packet_index *index); |
| 76 | |
| 77 | int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx, |
| 78 | uint64_t session_id); |
| 79 | |
| 80 | /* |
| 81 | * Create the output files of a local stream. |
| 82 | * |
| 83 | * This must be called with the channel's and the stream's lock held. |
| 84 | */ |
| 85 | int consumer_stream_create_output_files(struct lttng_consumer_stream *stream, |
| 86 | bool create_index); |
| 87 | |
| 88 | /* |
| 89 | * Rotate the output files of a local stream. This will change the |
| 90 | * active output files of both the binary and index in accordance |
| 91 | * with the stream's configuration (stream file count). |
| 92 | * |
| 93 | * This must be called with the channel's and the stream's lock held. |
| 94 | */ |
| 95 | int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream); |
| 96 | |
| 97 | #endif /* LTTNG_CONSUMER_STREAM_H */ |