Some fixes
This commit is contained in:
parent
11ece09158
commit
927123cb2e
1 changed files with 14 additions and 6 deletions
|
@ -200,7 +200,7 @@ int send_message(struct evt_core_ctx* ctx, struct buffer_packet* bp) {
|
|||
union abstract_packet *ap_buf = buffer_append_ap (bp_dup, &monit);
|
||||
uint8_t *links = &ap_buf->fmt.content.link_monitoring_lightning.prev_links;
|
||||
for (int i = 0; i < lightc->sent_past_links; i++) {
|
||||
links[i] = lightc->prev_links[lightc->pkt_sent_id - (i + 1) % MAX_LINKS];
|
||||
links[i] = lightc->prev_links[(lightc->pkt_sent_id - (i + 1)) % MAX_LINKS];
|
||||
}
|
||||
|
||||
lightc->prev_links[lightc->pkt_sent_id % MAX_LINKS] = lightc->selected_link;
|
||||
|
@ -224,27 +224,35 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
|
|||
int64_t stats[MAX_LINKS];
|
||||
algo_lightning_update_stats(lightc, stats);
|
||||
|
||||
struct timespec now;
|
||||
struct timespec now, temp_time;
|
||||
set_now(&now);
|
||||
|
||||
while (1) {
|
||||
int protection = lightc->total_links;
|
||||
while (protection-- > 0) {
|
||||
lightc->selected_link = (lightc->selected_link + 1) % lightc->total_links;
|
||||
uint64_t cdelta = stats[lightc->selected_link];
|
||||
int64_t cdelta = stats[lightc->selected_link];
|
||||
|
||||
// OK link
|
||||
if (cdelta >= 0 && cdelta < lightc->max_ooo) {
|
||||
printf("cdelta=%ld\n", cdelta);
|
||||
if (cdelta < lightc->max_ooo) {
|
||||
send_message (ctx, bp);
|
||||
break;
|
||||
}
|
||||
|
||||
// Broken link that must be probed
|
||||
if (elapsed_micros (&now, &lightc->last[lightc->selected_link]) >= lightc->sleep_duration) {
|
||||
timespec_diff (&now, &lightc->last[lightc->selected_link], &temp_time);
|
||||
uint64_t elapsed = timespec_get_unit(&temp_time, MILISEC);
|
||||
if (elapsed >= lightc->sleep_duration) {
|
||||
send_message (ctx, bp);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Broken link probed recently
|
||||
}
|
||||
if (protection <= 0) {
|
||||
fprintf(stderr, "Schedule error\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
mv_buffer_rtof (&app_ctx->br, fdinfo);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue