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

Fix timestamp buffer segmentation fault in recv_packet

parent 1593fe37
......@@ -18,6 +18,8 @@
#define MAX_BUFFER_SIZE 1024
#define TIMESTAMP_BUFFER_SIZE 64
uint64_t ts_to_uint(struct timespec t);
void add_ns(struct timespec *t, uint64_t ns);
uint64_t calcdiff_ns(struct timespec t1, struct timespec t2);
......
......@@ -39,7 +39,7 @@ static ingress_stat_t *stats;
static uint64_t *kernel_latency_hist;
static int use_histogram;
static uint64_t timestamps_buffer[64];
static uint64_t timestamps_buffer[TIMESTAMP_BUFFER_SIZE];
static int ts_buf_read_index = 0;
static int ts_buf_write_index = 0;
......@@ -132,7 +132,8 @@ void recv_udp_packet() {
if (params->use_timestamps) {
clock_gettime(CLOCK_REALTIME, &ts);
timestamps_buffer[ts_buf_write_index++] = 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;
}
iov.iov_base = &rx_buffer;
......@@ -156,7 +157,8 @@ void recv_udp_packet() {
struct timespec *stamp = (struct timespec *)CMSG_DATA(cmsg);
uint64_t kernel_latency = timestamps_buffer[ts_buf_read_index++] - ts_to_uint(*stamp);
uint64_t kernel_latency = timestamps_buffer[ts_buf_read_index] - ts_to_uint(*stamp);
ts_buf_read_index = (ts_buf_read_index + 1) % TIMESTAMP_BUFFER_SIZE;
kernel_latency /= 1000u;
stats->min_kernel_latency = min(kernel_latency, stats->min_kernel_latency);
......
......@@ -37,8 +37,6 @@
#include "common.h"
#include "send_packet.h"
#define TIMESTAMP_BUFFER_SIZE 64
static void *poll_thread(void *p);
static void process_error_queue();
......
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