Try to harden Donar
This commit is contained in:
parent
697868cc18
commit
960f63bcc0
2 changed files with 16 additions and 11 deletions
|
@ -319,22 +319,20 @@ void algo_lightning_update_stats (struct light_ctx *lightc) {
|
||||||
int64_t delta = 0;
|
int64_t delta = 0;
|
||||||
switch (lightc->historic[i].state) {
|
switch (lightc->historic[i].state) {
|
||||||
case IN_ORDER:
|
case IN_ORDER:
|
||||||
lightc->stats[l].ooo += delta;
|
delta = 0;
|
||||||
lightc->stats[l].meas_occ += 1;
|
|
||||||
break;
|
break;
|
||||||
case OOO_ONGOING:
|
case OOO_ONGOING:
|
||||||
timespec_diff(&now, &lightc->historic[i].detected_at, &temp_time);
|
timespec_diff(&now, &lightc->historic[i].detected_at, &temp_time);
|
||||||
delta = timespec_get_unit (&temp_time, MILISEC);
|
delta = timespec_get_unit (&temp_time, MILISEC);
|
||||||
lightc->stats[l].ooo += delta;
|
delta *= 2;
|
||||||
lightc->stats[l].meas_occ += 1;
|
|
||||||
break;
|
break;
|
||||||
case OOO_DONE:
|
case OOO_DONE:
|
||||||
timespec_diff(&lightc->historic[i].finished_at, &lightc->historic[i].detected_at, &temp_time);
|
timespec_diff(&lightc->historic[i].finished_at, &lightc->historic[i].detected_at, &temp_time);
|
||||||
delta = timespec_get_unit (&temp_time, MILISEC);
|
delta = timespec_get_unit (&temp_time, MILISEC);
|
||||||
lightc->stats[l].ooo += delta;
|
|
||||||
lightc->stats[l].meas_occ += 1;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
lightc->stats[l].ooo += delta;
|
||||||
|
lightc->stats[l].meas_occ += 1;
|
||||||
|
|
||||||
if (lightc->explain) printf("(stats.compute) packet=%ld, link=%d, status=%s, delta=%ld\n", lightc->historic[i].pkt_id, l, ooo_state_str[lightc->historic[i].state], delta);
|
if (lightc->explain) printf("(stats.compute) packet=%ld, link=%d, status=%s, delta=%ld\n", lightc->historic[i].pkt_id, l, ooo_state_str[lightc->historic[i].state], delta);
|
||||||
lightc->stats[l].link_id = l;
|
lightc->stats[l].link_id = l;
|
||||||
|
@ -384,12 +382,18 @@ int send_message(struct evt_core_ctx* ctx, struct buffer_packet* bp) {
|
||||||
|
|
||||||
struct algo_ctx* app_ctx = cat->app_ctx;
|
struct algo_ctx* app_ctx = cat->app_ctx;
|
||||||
struct light_ctx* lightc = app_ctx->misc;
|
struct light_ctx* lightc = app_ctx->misc;
|
||||||
if (lightc->selected_link >= lightc->total_links) return 0;
|
if (lightc->selected_link >= lightc->total_links) {
|
||||||
|
fprintf(stderr, "[algo_lightning] PACKET DROPPED! Selected link id %d is greater than the total number of links %d\n", lightc->selected_link, lightc->total_links);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
set_now(&lightc->status[lightc->selected_link].last);
|
set_now(&lightc->status[lightc->selected_link].last);
|
||||||
|
|
||||||
sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + lightc->selected_link);
|
sprintf(url, "tcp:write:127.0.0.1:%d", 7500 + lightc->selected_link);
|
||||||
struct evt_core_fdinfo *to_fdinfo = evt_core_get_from_url (ctx, url);
|
struct evt_core_fdinfo *to_fdinfo = evt_core_get_from_url (ctx, url);
|
||||||
if (to_fdinfo == NULL) return 0;
|
if (to_fdinfo == NULL) {
|
||||||
|
fprintf(stderr, "[algo_lightning] PACKET DROPPED! We don't have any entry for %s currently\n", url);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct buffer_packet* bp_dup = dup_buffer_tow (&app_ctx->br, bp, to_fdinfo);
|
struct buffer_packet* bp_dup = dup_buffer_tow (&app_ctx->br, bp, to_fdinfo);
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ int main_on_tcp_write(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo)
|
||||||
uint8_t is_rdy = fdinfo->cat->socklist->len >= app_ctx->link_count ? 1 : 0;
|
uint8_t is_rdy = fdinfo->cat->socklist->len >= app_ctx->link_count ? 1 : 0;
|
||||||
if (!app_ctx->is_rdy && is_rdy) printf("=== Our %d requested circuits are now up ===\n", app_ctx->link_count);
|
if (!app_ctx->is_rdy && is_rdy) printf("=== Our %d requested circuits are now up ===\n", app_ctx->link_count);
|
||||||
else if (app_ctx->is_rdy && !is_rdy) printf("=== Only %d/%d circuits are available, results could be biased ===\n", fdinfo->cat->socklist->len, app_ctx->link_count);
|
else if (app_ctx->is_rdy && !is_rdy) printf("=== Only %d/%d circuits are available, results could be biased ===\n", fdinfo->cat->socklist->len, app_ctx->link_count);
|
||||||
app_ctx->is_rdy = app_ctx->is_rdy || is_rdy; // @FIXME prevent deactivation for our tests
|
app_ctx->is_rdy = app_ctx->is_rdy || is_rdy; // @FIXME we don't want deactivation finally
|
||||||
|
|
||||||
// 1. Get current write buffer OR a buffer from the waiting queue OR leave
|
// 1. Get current write buffer OR a buffer from the waiting queue OR leave
|
||||||
if ((bp = get_write_buffer(&app_ctx->br, fdinfo)) == NULL) return 1;
|
if ((bp = get_write_buffer(&app_ctx->br, fdinfo)) == NULL) return 1;
|
||||||
|
@ -117,6 +117,7 @@ int main_on_tcp_write(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo)
|
||||||
if (write_res == FDS_ERR) goto co_error;
|
if (write_res == FDS_ERR) goto co_error;
|
||||||
if (write_res == FDS_AGAIN) return 1;
|
if (write_res == FDS_AGAIN) return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
app_ctx->cell_sent++;
|
app_ctx->cell_sent++;
|
||||||
|
|
||||||
free_buffer:
|
free_buffer:
|
||||||
|
@ -218,7 +219,7 @@ void algo_main_init(struct evt_core_ctx* evt, struct algo_params* ap) {
|
||||||
|
|
||||||
struct evt_core_cat tcp_read = {
|
struct evt_core_cat tcp_read = {
|
||||||
.name = "tcp-read",
|
.name = "tcp-read",
|
||||||
.flags = EPOLLIN | EPOLLET | EPOLLHUP,
|
.flags = EPOLLIN | EPOLLET | EPOLLHUP | EPOLLRDHUP,
|
||||||
.app_ctx = ctx,
|
.app_ctx = ctx,
|
||||||
.free_app_ctx = algo_main_destroy,
|
.free_app_ctx = algo_main_destroy,
|
||||||
.cb = main_on_tcp_read,
|
.cb = main_on_tcp_read,
|
||||||
|
@ -240,7 +241,7 @@ void algo_main_init(struct evt_core_ctx* evt, struct algo_params* ap) {
|
||||||
|
|
||||||
struct evt_core_cat tcp_write = {
|
struct evt_core_cat tcp_write = {
|
||||||
.name = "tcp-write",
|
.name = "tcp-write",
|
||||||
.flags = EPOLLOUT | EPOLLET | EPOLLHUP,
|
.flags = EPOLLOUT | EPOLLET | EPOLLHUP | EPOLLRDHUP,
|
||||||
.app_ctx = ctx,
|
.app_ctx = ctx,
|
||||||
.free_app_ctx = algo_main_destroy,
|
.free_app_ctx = algo_main_destroy,
|
||||||
.cb = main_on_tcp_write,
|
.cb = main_on_tcp_write,
|
||||||
|
|
Loading…
Reference in a new issue