Fix: make sure no index is in flight before using inactivity beacons
authorJulien Desfossez <jdesfossez@efficios.com>
Wed, 27 Aug 2014 17:59:21 +0000 (13:59 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 3 Sep 2014 19:16:09 +0000 (15:16 -0400)
Since the index is sent in two parts on two separate connections from
the consumer, there can be cases where we receive an inactivity beacon
between the index creation and the data reception.

This fix prevents from using the inactivity beacon if we know a data
index is coming.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-relayd/main.c
src/bin/lttng-relayd/stream.h

index 3a6bebaf7d6d3dc1ab5f7cf4fe76522d6f5c56fd..d0b799ed8871b193c70c03f80f33adc63b17c6a4 100644 (file)
@@ -1942,9 +1942,10 @@ int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr,
                DBG("Received live beacon for stream %" PRIu64, stream->stream_handle);
 
                /*
-                * Only flag a stream inactive when it has already received data.
+                * Only flag a stream inactive when it has already received data
+                * and no indexes are in flight.
                 */
-               if (stream->total_index_received > 0) {
+               if (stream->total_index_received > 0 && stream->indexes_in_flight == 0) {
                        stream->beacon_ts_end = be64toh(index_info.timestamp_end);
                }
                ret = 0;
@@ -1961,6 +1962,7 @@ int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr,
                        goto end_rcu_unlock;
                }
                index_created = 1;
+               stream->indexes_in_flight++;
        }
 
        copy_index_control_data(index, &index_info);
@@ -1991,6 +1993,8 @@ int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr,
                        goto end_rcu_unlock;
                }
                stream->total_index_received++;
+               stream->indexes_in_flight--;
+               assert(stream->indexes_in_flight >= 0);
        }
 
 end_rcu_unlock:
@@ -2154,6 +2158,7 @@ static int handle_index_data(struct relay_stream *stream, uint64_t net_seq_num,
                        goto error;
                }
                index_created = 1;
+               stream->indexes_in_flight++;
        }
 
        if (rotate_index || stream->index_fd < 0) {
@@ -2196,6 +2201,8 @@ static int handle_index_data(struct relay_stream *stream, uint64_t net_seq_num,
                        goto error;
                }
                stream->total_index_received++;
+               stream->indexes_in_flight--;
+               assert(stream->indexes_in_flight >= 0);
        }
 
 error:
index 5aca693cce4a5ea131ac383909da542ecb309576..4dd2e627e773bc27878394a1e1a56a30ca5f1885 100644 (file)
@@ -76,6 +76,12 @@ struct relay_stream {
         * timestamp end, when it is active, this field == -1ULL.
         */
        uint64_t beacon_ts_end;
+       /*
+        * Number of indexes that are supposed to be complete soon.
+        * Avoid sending the inactivity beacon to the client when data is in
+        * transit.
+        */
+       int indexes_in_flight;
        /*
         * CTF stream ID, -1ULL when unset.
         */
This page took 0.028874 seconds and 4 git commands to generate.