X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fstream.c;h=3c61e3532e1fd2b810b278f9cb9c5c98391444af;hp=f98b465572ec880d4730224da7766fe4ce7fc040;hb=927617721d01b4a676356787f7792799e3c84223;hpb=014e956d14322163d9740bb6f35580f21358f702 diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index f98b46557..3c61e3532 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -210,6 +210,16 @@ 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) { + 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 " + "rotation command would result in data loss", + __FUNCTION__); + ret = -1; + goto end; + } + ASSERT_LOCKED(stream->lock); /* * Acquire a reference to the current trace chunk to ensure @@ -245,6 +255,7 @@ static int rotate_truncate_stream(struct relay_stream *stream) goto end; } + assert(stream->stream_fd); /* * Seek the current tracefile to the position at which the rotation * should have occurred. @@ -1041,6 +1052,7 @@ int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num, uint64_t data_offset; struct relay_index *index; + assert(stream->trace_chunk); ASSERT_LOCKED(stream->lock); /* Get data offset because we are about to update the index. */ data_offset = htobe64(stream->tracefile_size_current); @@ -1122,9 +1134,7 @@ int stream_complete_packet(struct relay_stream *stream, size_t packet_total_size stream->prev_data_seq = sequence_number; ret = try_rotate_stream_data(stream); - if (ret < 0) { - goto end; - } + end: return ret; }