Fix some errors

This commit is contained in:
Quentin 2019-10-08 10:54:27 +02:00
parent 721f4ea54f
commit 192f355121

View file

@ -71,6 +71,9 @@ void algo_lightning_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, str
}
}
for (int i = 0; i < lightc->sent_past_links; i++)
lightc->prev_links[i] = UINT8_MAX;
union abstract_packet m;
lightc->monit_pkt_size = sizeof(m.fmt.headers) + sizeof(m.fmt.content.link_monitoring_lightning) + sizeof(uint8_t) * (lightc->sent_past_links - 1);
timespec_set_unit (&lightc->window, window, MILISEC);
@ -155,6 +158,8 @@ void algo_lightning_update_stats (struct light_ctx *lightc, int64_t *stats) {
for (int i = 0; i < HISTORIC_SIZE; i++) {
if (timespec_lt(&lightc->historic[i].finished_at, &not_before)) continue;
uint8_t l = lightc->historic[i].link_id;
if (l >= lightc->total_links) continue;
int64_t delta = 0;
switch (lightc->historic[i].state) {
case IN_ORDER:
@ -168,7 +173,7 @@ void algo_lightning_update_stats (struct light_ctx *lightc, int64_t *stats) {
delta = timespec_get_unit (&temp_time, MILISEC);
break;
}
uint8_t l = lightc->historic[i].link_id;
stats[l] = delta > stats[l] ? delta : stats[l];
}
}
@ -191,6 +196,7 @@ int send_message(struct evt_core_ctx* ctx, struct buffer_packet* bp) {
struct buffer_packet* bp_dup = dup_buffer_tow (&app_ctx->br, bp, to_fdinfo);
lightc->pkt_sent_id++;
union abstract_packet monit = {
.fmt.headers.cmd = CMD_LINK_MONITORING_LIGHTNING,
.fmt.headers.size = lightc->monit_pkt_size,
@ -204,7 +210,6 @@ int send_message(struct evt_core_ctx* ctx, struct buffer_packet* bp) {
}
lightc->prev_links[lightc->pkt_sent_id % MAX_LINKS] = lightc->selected_link;
lightc->pkt_sent_id++;
if (ctx->verbose > 1) {
dump_buffer_packet(bp_dup);
@ -239,7 +244,6 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
int64_t cdelta = stats[lightc->selected_link];
// OK link
printf("cdelta=%ld\n", cdelta);
if (cdelta < lightc->max_ooo) {
send_message (ctx, bp);
break;