X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fstream.c;h=755fb6734072113af804e59f6e1e81089adb6b1f;hp=9d753bd0a7037c042c6218487d0bda0a4d95a0b4;hb=f3fe2a9216e46a1a10490e7457fabce7872bf5b7;hpb=d91bc249cd6e3d3a3b8de29d226343d5db279cb3 diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index 9d753bd0a..755fb6734 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -90,7 +90,6 @@ static int stream_create_data_output_file_from_trace_chunk( const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; ASSERT_LOCKED(stream->lock); - assert(stream->trace_chunk); ret = utils_stream_file_path(stream->path_name, stream->channel_name, stream->tracefile_size, stream->tracefile_current_index, @@ -210,7 +209,7 @@ static int rotate_truncate_stream(struct relay_stream *stream) struct stream_fd *previous_stream_fd = NULL; struct lttng_trace_chunk *previous_chunk = NULL; - if (!LTTNG_OPTIONAL_GET(&stream->ongoing_rotation)->next_trace_chunk) { + if (!LTTNG_OPTIONAL_GET(stream->ongoing_rotation).next_trace_chunk) { ERR("Protocol error encoutered in %s(): stream rotation " "sequence number is before the current sequence number " "and the next trace chunk is unset. Honoring this " @@ -955,6 +954,14 @@ int stream_init_packet(struct relay_stream *stream, size_t packet_size, int ret = 0; ASSERT_LOCKED(stream->lock); + + if (!stream->stream_fd || !stream->trace_chunk) { + ERR("Protocol error: received a packet for a stream that doesn't have a current trace chunk: stream_id = %" PRIu64 ", channel_name = %s", + stream->stream_handle, stream->channel_name); + ret = -1; + goto end; + } + if (caa_likely(stream->tracefile_size == 0)) { /* No size limit set; nothing to check. */ goto end; @@ -1020,6 +1027,12 @@ int stream_write(struct relay_stream *stream, memset(padding_buffer, 0, min(sizeof(padding_buffer), padding_to_write)); + if (!stream->stream_fd || !stream->trace_chunk) { + ERR("Protocol error: received a packet for a stream that doesn't have a current trace chunk: stream_id = %" PRIu64 ", channel_name = %s", + stream->stream_handle, stream->channel_name); + ret = -1; + goto end; + } if (packet) { write_ret = lttng_write(stream->stream_fd->fd, packet->data, packet->size);