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

Fix segmentation fault due tu previous commit

parent f9c04177
...@@ -263,10 +263,11 @@ static void do_tsn_task(struct thread_param *param, char *data, uint64_t next_tx ...@@ -263,10 +263,11 @@ static void do_tsn_task(struct thread_param *param, char *data, uint64_t next_tx
if (enable_histograms) { if (enable_histograms) {
rtt_us = param->stats.rtt / 1000; rtt_us = param->stats.rtt / 1000;
if (rtt_us > MAX_HIST_VAL) {
if (rtt_us > MAX_HIST_VAL)
fprintf(stderr, "RTT value higher than MAX_HIST_VAL : %d ( > %d)\n", rtt_us, MAX_HIST_VAL); fprintf(stderr, "RTT value higher than MAX_HIST_VAL : %d ( > %d)\n", rtt_us, MAX_HIST_VAL);
} else
histograms[0][rtt_us]++; histograms[0][rtt_us]++;
} }
} }
} }
......
...@@ -173,15 +173,15 @@ static void fill_histograms(packet_info_t *packet_info, int64_t histograms[NB_HI ...@@ -173,15 +173,15 @@ static void fill_histograms(packet_info_t *packet_info, int64_t histograms[NB_HI
user_space_time /= 1000u; user_space_time /= 1000u;
kernel_space_time /= 1000u; kernel_space_time /= 1000u;
if (user_space_time > MAX_HIST_VAL) { if (user_space_time > MAX_HIST_VAL)
fprintf(stderr, "user_space_time value too high: %" PRIu64 "us\n", user_space_time); fprintf(stderr, "user_space_time value too high: %" PRIu64 "us\n", user_space_time);
} else
if (kernel_space_time > MAX_HIST_VAL) { histograms[0][user_space_time]++;
fprintf(stderr, "kernel_space_time value too high: %" PRIu64 "us\n", kernel_space_time);
}
histograms[0][user_space_time]++; if (kernel_space_time > MAX_HIST_VAL)
histograms[1][kernel_space_time]++; fprintf(stderr, "kernel_space_time value too high: %" PRIu64 "us\n", kernel_space_time);
else
histograms[1][kernel_space_time]++;
} }
#ifdef DEBUG #ifdef DEBUG
......
...@@ -208,15 +208,15 @@ static void fill_histograms(packet_info_t *packet_info, int64_t histograms[NB_HI ...@@ -208,15 +208,15 @@ static void fill_histograms(packet_info_t *packet_info, int64_t histograms[NB_HI
user_space_time /= 1000u; user_space_time /= 1000u;
kernel_space_time /= 1000u; kernel_space_time /= 1000u;
if (user_space_time > MAX_HIST_VAL) { if (user_space_time > MAX_HIST_VAL)
fprintf(stderr, "user_space_time value too high: %" PRIu64 "us\n", user_space_time); fprintf(stderr, "user_space_time value too high: %" PRIu64 "us\n", user_space_time);
} else
if (kernel_space_time > MAX_HIST_VAL) { histograms[0][user_space_time]++;
fprintf(stderr, "kernel_space_time value too high: %" PRIu64 "us\n", kernel_space_time);
}
histograms[0][user_space_time]++; if (kernel_space_time > MAX_HIST_VAL)
histograms[1][kernel_space_time]++; fprintf(stderr, "kernel_space_time value too high: %" PRIu64 "us\n", kernel_space_time);
else
histograms[1][kernel_space_time]++;
} }
static void process_timestamps(packet_info_t *packet_info, int64_t histograms[NB_HISTOGRAMS][MAX_HIST_VAL]) { static void process_timestamps(packet_info_t *packet_info, int64_t histograms[NB_HISTOGRAMS][MAX_HIST_VAL]) {
......
...@@ -157,6 +157,7 @@ static void *packet_receiving_thread(void *p) { ...@@ -157,6 +157,7 @@ static void *packet_receiving_thread(void *p) {
if (enable_histograms) { if (enable_histograms) {
dist_to_interval = (((int64_t)diff) - param->interval) / 1000; dist_to_interval = (((int64_t)diff) - param->interval) / 1000;
dist_to_interval += MAX_HIST_VAL / 2; dist_to_interval += MAX_HIST_VAL / 2;
if (dist_to_interval > ((int)MAX_HIST_VAL) || dist_to_interval < 0) if (dist_to_interval > ((int)MAX_HIST_VAL) || dist_to_interval < 0)
fprintf(stderr, "jitter higher than MAX_HIST_VAL: %" PRIi64 "\n", dist_to_interval); fprintf(stderr, "jitter higher than MAX_HIST_VAL: %" PRIi64 "\n", dist_to_interval);
else else
......
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