fix bugs...
This commit is contained in:
parent
49dd7910aa
commit
2a772edc84
1 changed files with 12 additions and 5 deletions
|
@ -299,7 +299,7 @@ int compare_stat_entry_max(const void *a, const void *b) {
|
|||
return sea->ooo - seb->ooo;
|
||||
}
|
||||
|
||||
void algo_lightning_update_stats (struct light_ctx *lightc) {
|
||||
void algo_lightning_update_stats (struct light_ctx *lightc, struct evt_core_ctx* ctx) {
|
||||
struct timespec now, not_before = {0}, temp_time;
|
||||
set_now(&now);
|
||||
timespec_diff (&now, &lightc->window, ¬_before);
|
||||
|
@ -324,7 +324,6 @@ void algo_lightning_update_stats (struct light_ctx *lightc) {
|
|||
case OOO_ONGOING:
|
||||
timespec_diff(&now, &lightc->historic[i].detected_at, &temp_time);
|
||||
delta = timespec_get_unit (&temp_time, MILISEC);
|
||||
delta *= 2;
|
||||
break;
|
||||
case OOO_DONE:
|
||||
timespec_diff(&lightc->historic[i].finished_at, &lightc->historic[i].detected_at, &temp_time);
|
||||
|
@ -346,8 +345,8 @@ void algo_lightning_update_stats (struct light_ctx *lightc) {
|
|||
|
||||
// Compute average
|
||||
for (int i = 0; i < lightc->total_links; i++) {
|
||||
if (lightc->stats[i].meas_occ <= 0) continue;
|
||||
lightc->stats[i].ooo = lightc->stats[i].ooo / lightc->stats[i].meas_occ;
|
||||
if (lightc->stats[i].meas_occ <= 0) lightc->stats[i].ooo = -1;
|
||||
else lightc->stats[i].ooo = lightc->stats[i].ooo / lightc->stats[i].meas_occ;
|
||||
}
|
||||
|
||||
// Set my local stats + merge remote stats
|
||||
|
@ -366,6 +365,14 @@ void algo_lightning_update_stats (struct light_ctx *lightc) {
|
|||
} */
|
||||
}
|
||||
|
||||
// Disable broken links
|
||||
char url[256];
|
||||
for (int i = 0; i < lightc->total_links; i++) {
|
||||
sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + i);
|
||||
struct evt_core_fdinfo *to_fdinfo = evt_core_get_from_url (ctx, url);
|
||||
if (to_fdinfo == NULL) lightc->stats[i].ooo = -1;
|
||||
}
|
||||
|
||||
// Sort
|
||||
if (!lightc->disable_scheduler) {
|
||||
qsort(lightc->stats, lightc->total_links, sizeof(struct stat_entry), compare_stat_entry_max);
|
||||
|
@ -512,7 +519,7 @@ int algo_lightning_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo*
|
|||
algo_lightning_pad (ctx, fdinfo, bp);
|
||||
|
||||
// Compute stats
|
||||
algo_lightning_update_stats(lightc);
|
||||
algo_lightning_update_stats(lightc, ctx);
|
||||
algo_lightning_update_used(lightc, &now);
|
||||
algo_lightning_link_cat(lightc);
|
||||
|
||||
|
|
Loading…
Reference in a new issue