Commit bd13db96 authored by Joanne Hugé's avatar Joanne Hugé

Fix still present segmentation fault caused by incrementing index without modulo

parent d067cff7
......@@ -131,7 +131,8 @@ void send_udp_packet(char *data,
if (params->use_timestamps) {
clock_gettime(CLOCK_REALTIME, &ts);
timestamps_buffer[(ts_buf_write_index++) % TIMESTAMP_BUFFER_SIZE] = ts_to_uint(ts);
timestamps_buffer[ts_buf_write_index] = ts_to_uint(ts);
ts_buf_write_index = (ts_buf_write_index + 1) % TIMESTAMP_BUFFER_SIZE;
}
packets_sent++;
......@@ -222,7 +223,8 @@ static void process_error_queue() {
struct timespec *stamp = (struct timespec *)CMSG_DATA(cmsg);
int kernel_latency = (ts_to_uint(*stamp) - timestamps_buffer[(ts_buf_read_index++) % TIMESTAMP_BUFFER_SIZE]) / 1000;
int kernel_latency = (ts_to_uint(*stamp) - timestamps_buffer[ts_buf_read_index]) / 1000;
ts_buf_read_index = (ts_buf_read_index + 1) % TIMESTAMP_BUFFER_SIZE;
stats->min_kernel_latency = min(kernel_latency, stats->min_kernel_latency);
stats->max_kernel_latency = max(kernel_latency, stats->max_kernel_latency);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment