Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ames: handle %nail gift, lanes to vere cache #541

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 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_o nal_d; // lane cache backcompat flag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/b nal_o

struct { // config:
c3_o net_o; // can send
c3_o see_o; // can scry
Expand Down Expand Up @@ -920,13 +921,13 @@ _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) {
_ames_lane_from_cache(u3p(u3h_root) lax_p, u3_noun who, c3_o nal) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/b nal_o

u3_weak lac = u3h_git(lax_p, who);

if ( u3_none != lac ) {
if (nal == c3n && u3_none != lac ) {
struct timeval tim_tv;
gettimeofday(&tim_tv, 0);
u3_noun now = u3_time_in_tv(&tim_tv);
Expand Down Expand Up @@ -1477,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 @@ -2276,6 +2277,14 @@ _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);
sam_u->nal_d = c3y;
ret_o = c3y;
} break;
}

u3z(tag); u3z(dat);
Expand Down Expand Up @@ -2457,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