From 124c0375c0755e98b5b3086124e0229b181c7207 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 29 Aug 2019 18:11:50 +0200 Subject: [PATCH] Better handle timeouts --- src/algo_thunder.c | 8 ++++---- src/packet.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/algo_thunder.c b/src/algo_thunder.c index 6151dc5..b856504 100644 --- a/src/algo_thunder.c +++ b/src/algo_thunder.c @@ -15,7 +15,7 @@ struct thunder_ctx { uint16_t emit_id; uint8_t selected_link; uint8_t total_links; - uint8_t delta_t_per_link[MAX_LINKS]; + uint64_t delta_t_per_link[MAX_LINKS]; uint64_t received_pkts_on_link[MAX_LINKS]; uint64_t blacklisted[MAX_LINKS]; size_t monit_pkt_size; @@ -132,13 +132,13 @@ int schedule(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct bu union abstract_packet *new_ap = buffer_append_ap (bp_dup, &links); // 4. We compute the time difference - uint64_t mili_sec = compute_delta (&thunderc->prev_link_time, 200); + uint64_t mili_sec = compute_delta (&thunderc->prev_link_time, UINT16_MAX); // 5. We create the array struct link_info *li = &new_ap->fmt.content.link_monitoring_thunder.links_status; for (int i = 0; i < thunderc->total_links; i++) { thunderc->delta_t_per_link[i] += mili_sec; - li[i].delta_t = thunderc->delta_t_per_link[i]; + li[i].delta_t = thunderc->delta_t_per_link[i] > UINT16_MAX ? UINT16_MAX : thunderc->delta_t_per_link[i]; } li[thunderc->selected_link].delta_t = 0; @@ -315,7 +315,7 @@ void algo_thunder_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struc thunderc->recv_id = 1; thunderc->emit_id = 1; thunderc->total_links = app_ctx->ap.links; - thunderc->selected_link = thunderc->total_links; + thunderc->selected_link = thunderc->total_links - 1; for (int i = 0; i < MAX_LINKS; i++) thunderc->received_pkts_on_link[i] = 1; union abstract_packet links = {}; diff --git a/src/packet.h b/src/packet.h index c04376f..544e9cc 100644 --- a/src/packet.h +++ b/src/packet.h @@ -43,7 +43,7 @@ enum PKT_FLAGS { }; struct link_info { - uint8_t delta_t; + uint16_t delta_t; }; union abstract_packet {