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>
DBG("Received live beacon for stream %" PRIu64, stream->stream_handle);
/*
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;
stream->beacon_ts_end = be64toh(index_info.timestamp_end);
}
ret = 0;
goto end_rcu_unlock;
}
index_created = 1;
goto end_rcu_unlock;
}
index_created = 1;
+ stream->indexes_in_flight++;
}
copy_index_control_data(index, &index_info);
}
copy_index_control_data(index, &index_info);
goto end_rcu_unlock;
}
stream->total_index_received++;
goto end_rcu_unlock;
}
stream->total_index_received++;
+ stream->indexes_in_flight--;
+ assert(stream->indexes_in_flight >= 0);
goto error;
}
index_created = 1;
goto error;
}
index_created = 1;
+ stream->indexes_in_flight++;
}
if (rotate_index || stream->index_fd < 0) {
}
if (rotate_index || stream->index_fd < 0) {
goto error;
}
stream->total_index_received++;
goto error;
}
stream->total_index_received++;
+ stream->indexes_in_flight--;
+ assert(stream->indexes_in_flight >= 0);
* timestamp end, when it is active, this field == -1ULL.
*/
uint64_t beacon_ts_end;
* 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.
*/
/*
* CTF stream ID, -1ULL when unset.
*/