relayd: keep track of prev_index_seq in relayd_stream
[lttng-tools.git] / src / bin / lttng-relayd / main.c
index 44fb2e27cb99a1bc34feeeaaa7d7d618bcbb72f3..92f9a5600ac28b7280dcea9f1041b7725b13b748 100644 (file)
@@ -2314,12 +2314,18 @@ static int relay_recv_index(const struct lttcomm_relayd_hdr *recv_hdr,
                tracefile_array_commit_seq(stream->tfa);
                stream->index_received_seqcount++;
                stream->pos_after_last_complete_data_index += index->total_size;
+               stream->prev_index_seq = index_info.net_seq_num;
        } else if (ret > 0) {
                /* no flush. */
                ret = 0;
        } else {
+               /*
+                * ret < 0
+                *
+                * relay_index_try_flush is responsible for the self-reference
+                * put of the index object on error.
+                */
                ERR("relay_index_try_flush error %d", ret);
-               relay_index_put(index);
                ret = -1;
        }
 
@@ -2820,7 +2826,8 @@ int relay_rotate_pending(const struct lttcomm_relayd_hdr *recv_hdr,
 
        chunk_id = be64toh(msg.chunk_id);
 
-       DBG("Evaluating rotate pending for chunk id %" PRIu64, chunk_id);
+       DBG("Evaluating rotate pending for session \"%s\" and  chunk id %" PRIu64,
+                       session->session_name, chunk_id);
 
        /*
         * Iterate over all the streams in the session and check if they are
@@ -3216,9 +3223,13 @@ static int handle_index_data(struct relay_stream *stream, uint64_t net_seq_num,
                /* No flush. */
                ret = 0;
        } else {
-               /* Put self-ref for this index due to error. */
-               relay_index_put(index);
-               index = NULL;
+               /*
+                * ret < 0
+                *
+                * relay_index_try_flush is responsible for the self-reference
+                * put of the index object on error.
+                */
+               ERR("relay_index_try_flush error %d", ret);
                ret = -1;
        }
 end:
@@ -3472,6 +3483,7 @@ static enum relay_connection_status relay_process_data_receive_payload(
        if (index_flushed) {
                stream->pos_after_last_complete_data_index =
                                stream->tracefile_size_current;
+               stream->prev_index_seq = state->header.net_seq_num;
        }
 
        stream->prev_seq = state->header.net_seq_num;
This page took 0.024472 seconds and 5 git commands to generate.