Skip to content

Commit

Permalink
ames: handle %nail gift, lanes to vere cache
Browse files Browse the repository at this point in the history
  • Loading branch information
pkova committed Oct 13, 2023
1 parent 5f372c8 commit fb18089
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions pkg/vere/io/ames.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,27 +920,11 @@ _ames_lane_into_cache(u3p(u3h_root) lax_p, u3_noun who, u3_noun las) {
u3z(who);
}

/* _ames_lane_from_cache(): retrieve lane for who from cache, if any & fresh
/* _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) {
u3_weak lac = u3h_git(lax_p, who);

if ( 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 @@ -2276,6 +2260,13 @@ _ames_kick_newt(u3_ames* sam_u, u3_noun tag, u3_noun dat)
_ames_ef_turf(sam_u, u3k(dat));
ret_o = c3y;
} break;

case c3__nail: {
u3_noun who = u3k(u3h(dat));
u3_noun las = u3k(u3t(dat));
_ames_lane_into_cache(sam_u->lax_p, who, las);
ret_o = c3y;
} break;
}

u3z(tag); u3z(dat);
Expand Down

0 comments on commit fb18089

Please sign in to comment.