Skip to content

Commit

Permalink
ames: wait for %nail before enabling new lane cache behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
pkova committed Oct 16, 2023
1 parent fb18089 commit 4b523ad
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions pkg/vere/io/ames.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
c3_w imp_w[256]; // imperial IPs
time_t imp_t[256]; // imperial IP timestamps
c3_o imp_o[256]; // imperial print status
c3_d nal_d; // lane cache backcompat flag
struct { // config:
c3_o net_o; // can send
c3_o see_o; // can scry
Expand Down Expand Up @@ -923,8 +924,24 @@ _ames_lane_into_cache(u3p(u3h_root) lax_p, u3_noun who, u3_noun las) {
/* _ames_lane_from_cache(): retrieve lane for who from cache, if any
*/
static u3_weak
_ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who) {
_ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who, c3_o nal) {
u3_weak lac = u3h_git(lax_p, who);

if (nal == c3n && u3_none != lac ) {
struct timeval tim_tv;
gettimeofday(&tim_tv, 0);
u3_noun now = u3_time_in_tv(&tim_tv);
u3_noun den = u3t(lac);

// consider entries older than 2 minutes stale, ignore them
//
if ( 120000 > u3_time_gap_ms(u3k(den), now) ) {
lac = u3k(u3h(lac));
} else {
lac = u3_none;
}
}

u3z(who);
return lac;
}
Expand Down Expand Up @@ -1461,7 +1478,7 @@ _ames_try_send(u3_pact* pac_u, c3_o for_o)
//
else {
u3_noun key = u3i_chubs(2, pac_u->pre_u.rec_d);
lac = _ames_lane_from_cache(sam_u->lax_p, key);
lac = _ames_lane_from_cache(sam_u->lax_p, key, sam_u->nal_d);
}

// if we know there's no lane, drop the packet
Expand Down Expand Up @@ -2265,6 +2282,7 @@ _ames_kick_newt(u3_ames* sam_u, u3_noun tag, u3_noun dat)
u3_noun who = u3k(u3h(dat));
u3_noun las = u3k(u3t(dat));
_ames_lane_into_cache(sam_u->lax_p, who, las);
sam_u->nal_d = c3y;
ret_o = c3y;
} break;
}
Expand Down Expand Up @@ -2448,6 +2466,7 @@ u3_ames_io_init(u3_pier* pir_u)
{
u3_ames* sam_u = c3_calloc(sizeof(*sam_u));
sam_u->pir_u = pir_u;
sam_u->nal_d = c3n;
sam_u->fig_u.net_o = c3y;
sam_u->fig_u.see_o = c3y;
sam_u->fig_u.fit_o = c3n;
Expand Down

0 comments on commit 4b523ad

Please sign in to comment.