mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 01:01:37 +03:00
conn: various fixes and cleanups
This commit is contained in:
parent
275beeb071
commit
c89eb11f57
@ -779,6 +779,7 @@
|
||||
# define c3__nest c3_s4('n','e','s','t')
|
||||
# define c3__netd c3_s4('n','e','t','d')
|
||||
# define c3__new c3_s3('n','e','w')
|
||||
# define c3__news c3_s4('n','e','w','s')
|
||||
# define c3__newt c3_s4('n','e','w','t')
|
||||
# define c3__next c3_s4('n','e','x','t')
|
||||
# define c3__nich c3_s4('n','i','c','h')
|
||||
|
@ -26,7 +26,7 @@
|
||||
** %peek is a namespace read request (aka scry). they are
|
||||
** forwarded directly to arvo. its arguments are the nom of the
|
||||
** external peek interface in arvo, at arm 22. (lyc is always
|
||||
** [~ ~], i.e. request from self.) that is:
|
||||
** `~, i.e. request from self.) that is:
|
||||
**
|
||||
** $+ each path
|
||||
** $% [%once vis=view syd=desk tyl=spur]
|
||||
@ -122,29 +122,6 @@ _conn_moat_free(void* ptr_v, ssize_t err_i, const c3_c* err_c)
|
||||
c3_free(ptr_v);
|
||||
}
|
||||
|
||||
/* _conn_punt_goof(): print stack trace of error.
|
||||
*/
|
||||
static void
|
||||
_conn_punt_goof(u3_noun lud)
|
||||
{
|
||||
if ( 2 == u3qb_lent(lud) ) {
|
||||
u3_pier_punt_goof("conn", u3k(u3h(lud)));
|
||||
u3_pier_punt_goof("crud", u3k(u3h(u3t(lud))));
|
||||
}
|
||||
else {
|
||||
u3_noun dul = lud;
|
||||
c3_w len_w = 1;
|
||||
|
||||
while ( u3_nul != dul ) {
|
||||
u3l_log("conn: bail %u\r\n", len_w++);
|
||||
u3_pier_punt_goof("conn", u3k(u3h(dul)));
|
||||
dul = u3t(dul);
|
||||
}
|
||||
}
|
||||
|
||||
u3z(lud);
|
||||
}
|
||||
|
||||
/* _conn_send_noun(): jam and send noun over chan.
|
||||
*/
|
||||
static void
|
||||
@ -247,7 +224,7 @@ _conn_poke_bail(u3_ovum* egg_u, u3_noun lud)
|
||||
c3_l sev_l, coq_l;
|
||||
u3_atom rid;
|
||||
|
||||
_conn_punt_goof(u3k(lud));
|
||||
u3_auto_bail_slog(egg_u, u3k(lud));
|
||||
if ( (c3n == _conn_read_wire(u3k(wir), c3__khan, &sev_l, &coq_l, &rid)) ||
|
||||
(con_u->sev_l != sev_l) )
|
||||
{
|
||||
@ -258,7 +235,7 @@ _conn_poke_bail(u3_ovum* egg_u, u3_noun lud)
|
||||
}
|
||||
can_u = _conn_find_chan(con_u, sev_l, coq_l);
|
||||
if ( can_u ) {
|
||||
_conn_send_noun(can_u, u3nt(rid, c3__fail, lud));
|
||||
_conn_send_noun(can_u, u3nt(rid, c3__bail, lud));
|
||||
}
|
||||
else {
|
||||
u3z(rid); u3z(lud);
|
||||
@ -380,14 +357,16 @@ _conn_ovum_bail(u3_ovum* egg_u, u3_noun lud)
|
||||
u3_chan* can_u = ran_u->can_u;
|
||||
u3_cran* inn_u;
|
||||
|
||||
u3_auto_bail_slog(egg_u, u3k(lud));
|
||||
if ( !can_u ) {
|
||||
// chan was closed; noop.
|
||||
//
|
||||
u3z(ran_u->rid); c3_free(ran_u);
|
||||
u3z(lud); return;
|
||||
}
|
||||
_conn_send_noun(can_u, u3nq(ran_u->rid, c3__ovum, c3__bail, lud));
|
||||
_conn_send_noun(can_u, u3nt(ran_u->rid, c3__bail, lud));
|
||||
_conn_drop_cran(can_u, ran_u);
|
||||
u3_ovum_free(egg_u);
|
||||
}
|
||||
|
||||
/* _conn_ovum_news(): lifecycle callback for injected events.
|
||||
@ -397,19 +376,19 @@ _conn_ovum_news(u3_ovum* egg_u, u3_ovum_news new_e)
|
||||
{
|
||||
u3_cran* ran_u = egg_u->ptr_v;
|
||||
u3_chan* can_u = ran_u->can_u;
|
||||
c3_l new_l;
|
||||
c3_m new_m;
|
||||
|
||||
if ( can_u ) {
|
||||
switch (new_e) {
|
||||
default: c3_assert(!"not-reached");
|
||||
case u3_ovum_drop: new_l = c3__drop; break;
|
||||
case u3_ovum_work: new_l = c3__work; break;
|
||||
case u3_ovum_done: new_l = c3__done; break;
|
||||
default: c3_assert(!"not reached");
|
||||
case u3_ovum_drop: new_m = c3__drop; break;
|
||||
case u3_ovum_work: new_m = c3__work; break;
|
||||
case u3_ovum_done: new_m = c3__done; break;
|
||||
}
|
||||
_conn_send_noun(can_u, u3nt(u3k(ran_u->rid), c3__ovum, new_l));
|
||||
_conn_send_noun(can_u, u3nt(u3k(ran_u->rid), c3__news, new_m));
|
||||
}
|
||||
if ( (u3_ovum_done == new_e) ||
|
||||
(u3_ovum_drop == new_e) )
|
||||
if ( u3_ovum_done == new_e ||
|
||||
u3_ovum_drop == new_e )
|
||||
{
|
||||
u3z(ran_u->rid);
|
||||
if ( !can_u ) {
|
||||
@ -691,6 +670,7 @@ _conn_born_bail(u3_ovum* egg_u, u3_noun lud)
|
||||
{
|
||||
u3l_log("conn: %%born failure; %%fyrd not supported\n");
|
||||
u3z(lud);
|
||||
u3_ovum_free(egg_u);
|
||||
}
|
||||
|
||||
/* _conn_io_talk(): open socket and notify %khan that we're live.
|
||||
|
Loading…
Reference in New Issue
Block a user