diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index 8f2d5ae5bd..d8a81438a9 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -334,6 +334,7 @@ */ typedef struct _u3_ovum { void* ptr_v; // context + c3_w try_w; // retry count c3_w mil_w; // timeout ms u3_noun tar; // target (in arvo) u3_noun wir; // wire @@ -848,6 +849,7 @@ */ void u3_auto_peer(u3_ovum* egg_u, + void* ptr_v, u3_ovum_peer news_f, u3_ovum_bail bail_f); diff --git a/pkg/urbit/vere/auto.c b/pkg/urbit/vere/auto.c index 9fedc7017b..49b04b9358 100644 --- a/pkg/urbit/vere/auto.c +++ b/pkg/urbit/vere/auto.c @@ -54,9 +54,11 @@ u3_auto_plan(u3_auto* car_u, u3_ovum *egg_u) */ void u3_auto_peer(u3_ovum* egg_u, + void* ptr_v, u3_ovum_peer news_f, u3_ovum_bail bail_f) { + egg_u->ptr_v = ptr_v; egg_u->cb_u.news_f = news_f; egg_u->cb_u.bail_f = bail_f; } @@ -97,9 +99,8 @@ u3_auto_bail(u3_ovum* egg_u, u3_noun lud) } else { u3_auto_bail_slog(egg_u, lud); + u3_ovum_free(egg_u); } - - u3_ovum_free(egg_u); } /* _auto_news(): notify driver of ovum status diff --git a/pkg/urbit/vere/io/ames.c b/pkg/urbit/vere/io/ames.c index be2c970a2c..a4bad01277 100644 --- a/pkg/urbit/vere/io/ames.c +++ b/pkg/urbit/vere/io/ames.c @@ -431,6 +431,8 @@ _ames_hear_bail(u3_ovum* egg_u, u3_noun lud) u3l_log("ames: packet failed (%" PRIu64 " total)\n\n", sam_u->fal_d); } } + + u3_ovum_free(egg_u); } /* _ames_recv_cb(): receive callback. @@ -473,7 +475,7 @@ _ames_recv_cb(uv_udp_t* wax_u, u3_auto_peer( u3_auto_plan(&sam_u->car_u, u3_ovum_init(0, c3__a, wir, cad)), - 0, _ames_hear_bail); + 0, 0, _ames_hear_bail); _ames_cap_queue(sam_u); } diff --git a/pkg/urbit/vere/io/behn.c b/pkg/urbit/vere/io/behn.c index 5fa639da22..dbe99e65d6 100644 --- a/pkg/urbit/vere/io/behn.c +++ b/pkg/urbit/vere/io/behn.c @@ -17,7 +17,6 @@ u3_auto car_u; // driver uv_timer_t tim_u; // behn timer c3_o alm_o; // alarm - c3_w bon_w; // %born retry count } u3_behn; /* _behn_time_cb(): timer callback. @@ -94,18 +93,14 @@ _behn_born_news(u3_ovum* egg_u, u3_ovum_news new_e) } } -static void -_behn_io_talk(u3_auto* car_u); - /* _behn_born_bail(): %born is essential, retry failures. */ static void _behn_born_bail(u3_ovum* egg_u, u3_noun lud) { u3_auto* car_u = egg_u->car_u; - u3_behn* teh_u = (u3_behn*)car_u; - if ( teh_u->bon_w == 2 ) { + if ( 2 == egg_u->try_w ) { u3l_log("behn: initialization failed\n"); if ( 2 == u3qb_lent(lud) ) { @@ -123,11 +118,12 @@ _behn_born_bail(u3_ovum* egg_u, u3_noun lud) } } + u3_ovum_free(egg_u); u3_pier_bail(car_u->pir_u); } else { - _behn_io_talk(car_u); - teh_u->bon_w++; + egg_u->try_w++; + u3_auto_plan(car_u, egg_u); } u3z(lud); @@ -144,6 +140,7 @@ _behn_io_talk(u3_auto* car_u) u3_auto_peer( u3_auto_plan(car_u, u3_ovum_init(0, c3__b, wir, cad)), + 0, _behn_born_news, _behn_born_bail); } diff --git a/pkg/urbit/vere/io/fore.c b/pkg/urbit/vere/io/fore.c index 4691e8a6e6..96f6dd53b7 100644 --- a/pkg/urbit/vere/io/fore.c +++ b/pkg/urbit/vere/io/fore.c @@ -18,6 +18,8 @@ _fore_inject_bail(u3_ovum* egg_u, u3_noun lud) { u3_auto_bail_slog(egg_u, lud); u3l_log("pier: injected event failed\n"); + + u3_ovum_free(egg_u); } /* _fore_inject(): inject an arbitrary ovum from a jammed file at [pax_c]. @@ -61,7 +63,7 @@ _fore_inject(u3_auto* car_u, c3_c* pax_c) u3_auto_peer( u3_auto_plan(car_u, u3_ovum_init(0, u3k(tar), u3k(wir), u3k(cad))), - 0, _fore_inject_bail); + 0, 0, _fore_inject_bail); } u3z(ovo); diff --git a/pkg/urbit/vere/ward.c b/pkg/urbit/vere/ward.c index 993d132c69..bb9b092129 100644 --- a/pkg/urbit/vere/ward.c +++ b/pkg/urbit/vere/ward.c @@ -135,6 +135,7 @@ u3_ovum_init(c3_w mil_w, { u3_ovum* egg_u = c3_malloc(sizeof(*egg_u)); egg_u->car_u = 0; + egg_u->try_w = 0; egg_u->ptr_v = 0; egg_u->mil_w = mil_w; egg_u->tar = tar;