]> git.lttng.org Git - lttng-tools.git/commitdiff
Fix: Off by one in seq num for data pending command
authorDavid Goulet <dgoulet@efficios.com>
Wed, 19 Dec 2012 20:36:59 +0000 (15:36 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 19 Dec 2012 20:50:37 +0000 (15:50 -0500)
Like the close stream command, the next sequence number of the stream
needs to be used minus 1 for the data pending or else we are off by one
on the relayd during the check since 4 data packets for instance means a
prev_seq value of 4 but a last_next_seq_num of 5 hence creating an off
by one for the data pending check.

Furthermore, the check was actually wrong on the relayd side. Having a
previous sequence number lower than the last one seen does NOT mean that
the data is not pending so the check needed was actually equal or
greater.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-relayd/main.c
src/common/consumer.c

index 47780e2660c59a22ccf3e32c88cf3dd7a98ef12d..d0cf15a30febfa0602a4b377387fbe947e521a2d 100644 (file)
@@ -1427,7 +1427,7 @@ int relay_data_pending(struct lttcomm_relayd_hdr *recv_hdr,
                        last_net_seq_num);
 
        /* Avoid wrapping issue */
-       if (((int64_t) (stream->prev_seq - last_net_seq_num)) <= 0) {
+       if (((int64_t) (stream->prev_seq - last_net_seq_num)) >= 0) {
                /* Data has in fact been written and is NOT pending */
                ret = 0;
        } else {
index be984a49270fefbba0b55bccd8ebf897ceea4ce7..61d6f2e79b702337e3e8095da5132136714616b5 100644 (file)
@@ -782,6 +782,13 @@ static int write_relayd_stream_header(struct lttng_consumer_stream *stream,
                data_hdr.stream_id = htobe64(stream->relayd_stream_id);
                data_hdr.data_size = htobe32(data_size);
                data_hdr.padding_size = htobe32(padding);
+               /*
+                * Note that net_seq_num below is assigned with the *current* value of
+                * next_net_seq_num and only after that the next_net_seq_num will be
+                * increment. This is why when issuing a command on the relayd using
+                * this next value, 1 should always be substracted in order to compare
+                * the last seen sequence number on the relayd side to the last sent.
+                */
                data_hdr.net_seq_num = htobe64(stream->next_net_seq_num++);
                /* Other fields are zeroed previously */
 
@@ -3021,7 +3028,8 @@ int consumer_data_pending(uint64_t id)
                                                stream->relayd_stream_id);
                        } else {
                                ret = relayd_data_pending(&relayd->control_sock,
-                                               stream->relayd_stream_id, stream->next_net_seq_num);
+                                               stream->relayd_stream_id,
+                                               stream->next_net_seq_num - 1);
                        }
                        pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
                        if (ret == 1) {
This page took 0.035401 seconds and 4 git commands to generate.