vere: refactors ovum and callbacks to support retry

This commit is contained in:
Joe Bryan 2020-06-27 01:13:06 -07:00
parent b6a0487d7a
commit 49444e86c5
6 changed files with 17 additions and 12 deletions

View File

@ -334,6 +334,7 @@
*/ */
typedef struct _u3_ovum { typedef struct _u3_ovum {
void* ptr_v; // context void* ptr_v; // context
c3_w try_w; // retry count
c3_w mil_w; // timeout ms c3_w mil_w; // timeout ms
u3_noun tar; // target (in arvo) u3_noun tar; // target (in arvo)
u3_noun wir; // wire u3_noun wir; // wire
@ -848,6 +849,7 @@
*/ */
void void
u3_auto_peer(u3_ovum* egg_u, u3_auto_peer(u3_ovum* egg_u,
void* ptr_v,
u3_ovum_peer news_f, u3_ovum_peer news_f,
u3_ovum_bail bail_f); u3_ovum_bail bail_f);

View File

@ -54,9 +54,11 @@ u3_auto_plan(u3_auto* car_u, u3_ovum *egg_u)
*/ */
void void
u3_auto_peer(u3_ovum* egg_u, u3_auto_peer(u3_ovum* egg_u,
void* ptr_v,
u3_ovum_peer news_f, u3_ovum_peer news_f,
u3_ovum_bail bail_f) u3_ovum_bail bail_f)
{ {
egg_u->ptr_v = ptr_v;
egg_u->cb_u.news_f = news_f; egg_u->cb_u.news_f = news_f;
egg_u->cb_u.bail_f = bail_f; egg_u->cb_u.bail_f = bail_f;
} }
@ -97,9 +99,8 @@ u3_auto_bail(u3_ovum* egg_u, u3_noun lud)
} }
else { else {
u3_auto_bail_slog(egg_u, lud); u3_auto_bail_slog(egg_u, lud);
}
u3_ovum_free(egg_u); u3_ovum_free(egg_u);
}
} }
/* _auto_news(): notify driver of ovum status /* _auto_news(): notify driver of ovum status

View File

@ -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); u3l_log("ames: packet failed (%" PRIu64 " total)\n\n", sam_u->fal_d);
} }
} }
u3_ovum_free(egg_u);
} }
/* _ames_recv_cb(): receive callback. /* _ames_recv_cb(): receive callback.
@ -473,7 +475,7 @@ _ames_recv_cb(uv_udp_t* wax_u,
u3_auto_peer( u3_auto_peer(
u3_auto_plan(&sam_u->car_u, u3_auto_plan(&sam_u->car_u,
u3_ovum_init(0, c3__a, wir, cad)), u3_ovum_init(0, c3__a, wir, cad)),
0, _ames_hear_bail); 0, 0, _ames_hear_bail);
_ames_cap_queue(sam_u); _ames_cap_queue(sam_u);
} }

View File

@ -17,7 +17,6 @@
u3_auto car_u; // driver u3_auto car_u; // driver
uv_timer_t tim_u; // behn timer uv_timer_t tim_u; // behn timer
c3_o alm_o; // alarm c3_o alm_o; // alarm
c3_w bon_w; // %born retry count
} u3_behn; } u3_behn;
/* _behn_time_cb(): timer callback. /* _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. /* _behn_born_bail(): %born is essential, retry failures.
*/ */
static void static void
_behn_born_bail(u3_ovum* egg_u, u3_noun lud) _behn_born_bail(u3_ovum* egg_u, u3_noun lud)
{ {
u3_auto* car_u = egg_u->car_u; 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"); u3l_log("behn: initialization failed\n");
if ( 2 == u3qb_lent(lud) ) { 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); u3_pier_bail(car_u->pir_u);
} }
else { else {
_behn_io_talk(car_u); egg_u->try_w++;
teh_u->bon_w++; u3_auto_plan(car_u, egg_u);
} }
u3z(lud); u3z(lud);
@ -144,6 +140,7 @@ _behn_io_talk(u3_auto* car_u)
u3_auto_peer( u3_auto_peer(
u3_auto_plan(car_u, u3_ovum_init(0, c3__b, wir, cad)), u3_auto_plan(car_u, u3_ovum_init(0, c3__b, wir, cad)),
0,
_behn_born_news, _behn_born_news,
_behn_born_bail); _behn_born_bail);
} }

View File

@ -18,6 +18,8 @@ _fore_inject_bail(u3_ovum* egg_u, u3_noun lud)
{ {
u3_auto_bail_slog(egg_u, lud); u3_auto_bail_slog(egg_u, lud);
u3l_log("pier: injected event failed\n"); 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]. /* _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_peer(
u3_auto_plan(car_u, u3_ovum_init(0, u3k(tar), u3k(wir), u3k(cad))), 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); u3z(ovo);

View File

@ -135,6 +135,7 @@ u3_ovum_init(c3_w mil_w,
{ {
u3_ovum* egg_u = c3_malloc(sizeof(*egg_u)); u3_ovum* egg_u = c3_malloc(sizeof(*egg_u));
egg_u->car_u = 0; egg_u->car_u = 0;
egg_u->try_w = 0;
egg_u->ptr_v = 0; egg_u->ptr_v = 0;
egg_u->mil_w = mil_w; egg_u->mil_w = mil_w;
egg_u->tar = tar; egg_u->tar = tar;