[lttng-dev] [RFC PATCH lttng-tools] Fix: relayd: Swap endianness of packet index

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Fri Nov 8 11:32:47 EST 2019


The packet index in stream_update_index() is meant to be stored
to disk, and therefore is kept in big endian.

Swap its endianness to host endian before using it internally.

Fixes "Fix: relayd: use packet sequence number for rotation position".

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/bin/lttng-relayd/stream.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c
index c5bf3759..f9ff5e9a 100644
--- a/src/bin/lttng-relayd/stream.c
+++ b/src/bin/lttng-relayd/stream.c
@@ -1142,7 +1142,8 @@ int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num,
 		tracefile_array_file_rotate(stream->tfa, TRACEFILE_ROTATE_READ);
 		tracefile_array_commit_seq(stream->tfa);
 		stream->index_received_seqcount++;
-		stream->received_packet_seq_num = index->index_data.packet_seq_num;
+		stream->received_packet_seq_num =
+				be64toh(index->index_data.packet_seq_num);
 		*flushed = true;
 	} else if (ret > 0) {
 		index->total_size = total_size;
-- 
2.17.1



More information about the lttng-dev mailing list