+static void finalize_snapshot_stream(
+ struct lttng_consumer_stream *stream, uint64_t relayd_id)
+{
+ ASSERT_LOCKED(stream->lock);
+
+ if (relayd_id == (uint64_t) -1ULL) {
+ if (stream->out_fd >= 0) {
+ const int ret = close(stream->out_fd);
+
+ if (ret < 0) {
+ PERROR("Failed to close stream snapshot output file descriptor");
+ }
+
+ stream->out_fd = -1;
+ }
+ } else {
+ close_relayd_stream(stream);
+ stream->net_seq_idx = (uint64_t) -1ULL;
+ }
+
+ lttng_trace_chunk_put(stream->trace_chunk);
+ stream->trace_chunk = NULL;
+}
+