X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fstream.c;h=1b4e38ac8fc2b0c9d209b39ac3a559fe9e284f98;hb=0f68efb616cd046543e5fc5a091466ec26df2216;hp=c02820d314e04526264555bb12584c40aa8606a0;hpb=f2aea36dd732363bb58b2613b3680ad7a3bec856;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index c02820d31..1b4e38ac8 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. @@ -1015,7 +1026,8 @@ int stream_write(struct relay_stream *stream, } if (stream->is_metadata) { - stream->metadata_received += packet->size + padding_len; + stream->metadata_received += packet ? packet->size : 0; + stream->metadata_received += padding_len; } DBG("Wrote to %sstream %" PRIu64 ": data_length = %zu, padding_length = %zu", @@ -1121,9 +1133,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; }