Merge branch 'cc-release-moar-boothack' into cc-release-rc-merge

* cc-release-moar-boothack:
  3. resumes without boot params
  2. restores pier on restart %play
  1. single-homes Arvo in worker process
This commit is contained in:
Joe Bryan 2018-11-21 16:36:22 -05:00
commit 66c497ad7c
9 changed files with 215 additions and 92 deletions

View File

@ -25,7 +25,8 @@
u3_noun wen; // current time, as text
u3_noun sev_l; // instance number
u3_noun sen; // instance string
u3_noun own; // owner list
u3_noun our; // identity
u3_noun fak; // c3y is fake
u3_noun sac; // space profiling

View File

@ -1234,6 +1234,11 @@
u3_noun pax, // path to pier
u3_noun sys); // path to boot pill
/* u3_pier_stay(): restart the new pier system.
*/
void
u3_pier_stay(u3_noun pax);
/* u3_pier_tank(): dump single tank.
*/
void

View File

@ -1679,6 +1679,7 @@ u3m_boot_new(c3_c* dir_c)
/* Basic initialization.
*/
memset(u3A, 0, sizeof(*u3A));
u3A->our = u3_none;
return 0;
}
@ -1708,6 +1709,7 @@ u3m_boot_pier(void)
/* Basic initialization.
*/
memset(u3A, 0, sizeof(*u3A));
u3A->our = u3_none;
return 0;
}

View File

@ -614,7 +614,8 @@ u3v_mark(void)
tot_w += u3a_mark_noun(arv_u->now);
tot_w += u3a_mark_noun(arv_u->wen);
tot_w += u3a_mark_noun(arv_u->sen);
tot_w += u3a_mark_noun(arv_u->own);
tot_w += u3a_mark_noun(arv_u->our);
tot_w += u3a_mark_noun(arv_u->fak);
tot_w += u3a_mark_noun(arv_u->roe);
tot_w += u3a_mark_noun(arv_u->key);

View File

@ -235,6 +235,14 @@ _king_exit(u3_noun exit)
void
_king_pier(u3_noun pier)
{
if ( (c3n == u3du(pier)) ||
(c3n == u3ud(u3t(pier))) ) {
u3m_p("king: invalid pier", pier);
exit(1);
}
u3_pier_stay(u3k(u3t(pier)));
u3z(pier);
}
/* _king_root(): root parser
@ -296,49 +304,54 @@ _boothack_cb(uv_connect_t *conn, int status)
{
u3_mojo *moj_u = conn->data;
u3_atom mat;
u3_atom pax, sys, who, tic, sec;
{
if ( !u3_Host.ops_u.pil_c ) {
// fprintf(stderr, "boot: new ship must specify pill (-B)\r\n");
// exit(1);
sys = 0;
}
else sys = u3i_string(u3_Host.ops_u.pil_c);
}
{
u3_noun whu;
if ( !u3_Host.ops_u.who_c ) {
fprintf(stderr, "boot: new ship must specify identity (-w)\r\n");
exit(1);
}
whu = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.who_c));
if ( u3_nul == whu ) {
fprintf(stderr, "boot: malformed identity (-w)\r\n");
exit(1);
}
who = u3k(u3t(whu));
u3z(whu);
}
if ( c3y == u3_Host.ops_u.fak ) {
fprintf(stderr, "boot: F A K E ship with null security\r\n");
sec = 0;
tic = 0;
}
else {
fprintf(stderr, "boot: real ships not yet supported\r\n");
exit(1);
}
u3_atom who, tic, sec, pax, sys;
u3_noun dom;
pax = u3i_string(u3_Host.dir_c);
mat = u3ke_jam(u3nc(c3__doom,
u3nc(c3__boot,
u3nq(who, tic, sec, u3nc(pax, sys)))));
if ( c3n == u3_Host.ops_u.nuu ) {
dom = u3nt(c3__pier, u3_nul, pax);
}
else {
if ( !u3_Host.ops_u.pil_c ) {
// XX download default pill
//
fprintf(stderr, "boot: new ship must specify pill (-B)\r\n");
exit(1);
}
else sys = u3i_string(u3_Host.ops_u.pil_c);
{
u3_noun whu;
if ( !u3_Host.ops_u.who_c ) {
fprintf(stderr, "boot: new ship must specify identity (-w)\r\n");
exit(1);
}
whu = u3dc("slaw", 'p', u3i_string(u3_Host.ops_u.who_c));
if ( u3_nul == whu ) {
fprintf(stderr, "boot: malformed identity (-w)\r\n");
exit(1);
}
who = u3k(u3t(whu));
u3z(whu);
}
if ( c3y == u3_Host.ops_u.fak ) {
fprintf(stderr, "boot: F A K E ship with null security\r\n");
sec = 0;
tic = 0;
}
else {
fprintf(stderr, "boot: real ships not yet supported\r\n");
exit(1);
}
dom = u3nc(c3__boot, u3nq(who, tic, sec, u3nc(pax, sys)));
}
mat = u3ke_jam(u3nc(c3__doom, dom));
u3_newt_write(moj_u, mat, 0);
}

View File

@ -141,17 +141,17 @@ _main_getopt(c3_i argc, c3_c** argv)
}
}
if ( u3_Host.ops_u.fak != c3y ) {
fprintf(stderr, "this is the development build and cannot connect\r\n");
fprintf(stderr, "to the live network; always run this build with -F.\r\n");
fprintf(stderr, "to install a live client: %s\r\n",
"http://urbit.org/docs/using/install/");
exit(1); /* (avoid simple usage msg) */
}
/* fill in any missing security data, etc
*/
if ( u3_Host.ops_u.nuu == c3y ) {
if ( u3_Host.ops_u.fak != c3y ) {
fprintf(stderr, "this is the development build and cannot connect\r\n");
fprintf(stderr, "to the live network; always run this build with -F.\r\n");
fprintf(stderr, "to install a live client: %s\r\n",
"http://urbit.org/docs/using/install/");
exit(1); /* (avoid simple usage msg) */
}
if ( u3_Host.ops_u.who_c == 0 ) {
fprintf(stderr, "comets are not yet supported; identify with -w\r\n");
return c3n;

View File

@ -1205,21 +1205,57 @@ _pier_work_poke(void* vod_p,
else {
/* the worker process starts with a %play task,
** which tells us where to start playback
** (and who we are, if it knows)
*/
if ( 0 == pir_u->log_u ) {
switch ( u3h(jar) ) {
default: goto error;
case c3__play: {
if ( (c3n == u3r_trel(jar, 0, &p_jar, &q_jar)) ||
c3_d lav_d;
c3_l mug_l;
if ( (c3n == u3r_qual(u3t(jar), 0, &p_jar, &q_jar, &r_jar)) ||
(c3n == u3ud(p_jar)) ||
(u3r_met(6, p_jar) != 1) ||
(c3n == u3ud(q_jar)) ||
(u3r_met(5, p_jar) != 1) )
(u3r_met(5, p_jar) != 1) ||
(c3n == u3du(r_jar)) ||
(c3n == u3ud(u3h(r_jar))) ||
((c3y != u3t(r_jar)) && (c3n != u3t(r_jar))) )
{
goto error;
if ( u3_nul == u3t(jar) ) {
lav_d = 1ULL;
mug_l = 0;
}
else {
goto error;
}
}
_pier_play(pir_u, u3r_chub(0, p_jar), u3r_word(0, q_jar));
if ( u3_nul != u3t(jar) ) {
lav_d = u3r_chub(0, p_jar);
mug_l = u3r_word(0, q_jar);
// single-home
//
{
u3_atom who = u3h(r_jar);
c3_d who_d[2];
u3r_chubs(0, 2, who_d, who);
c3_assert( ( (0 == pir_u->who_d[0]) &&
(0 == pir_u->who_d[1]) ) ||
( (who_d[0] == pir_u->who_d[0]) &&
(who_d[1] == pir_u->who_d[1]) ) );
pir_u->fak_o = u3t(r_jar);
pir_u->who_d[0] = who_d[0];
pir_u->who_d[1] = who_d[1];
}
}
_pier_play(pir_u, lav_d, mug_l);
u3z(jar); u3z(mat);
break;
@ -1378,6 +1414,7 @@ u3_pier_create(c3_c* pax_c, c3_c* sys_c)
*/
{
pir_u = c3_malloc(sizeof *pir_u);
memset(pir_u, 0, sizeof(*pir_u));
pir_u->pax_c = c3_malloc(1 + strlen(pax_c));
strcpy(pir_u->pax_c, pax_c);
@ -1920,11 +1957,7 @@ u3_pier_stub(void)
/* _pier_boot_make(): create/load a pier.
*/
static u3_pier*
_pier_boot_make(u3_noun who,
u3_noun tic,
u3_noun sec,
u3_noun pax,
u3_noun sys)
_pier_boot_make(u3_noun pax, u3_noun sys)
{
c3_c* pax_c = u3r_string(pax);
c3_c* sys_c = u3r_string(sys);
@ -1935,25 +1968,8 @@ _pier_boot_make(u3_noun who,
u3z(pax); free(pax_c);
u3z(sys); free(sys_c);
{
u3_noun how = u3dc("scot", 'p', u3k(who));
pir_u->who_c = u3r_string(how);
u3z(how);
fprintf(stderr, "boot: ship: %s\r\n", pir_u->who_c);
}
u3r_chubs(0, 2, pir_u->who_d, who);
u3r_chubs(0, 1, pir_u->tic_d, tic);
u3r_chubs(0, 1, pir_u->sec_d, sec);
pir_u->por_s = 0;
u3z(tic);
u3z(sec);
u3z(who);
_pier_loop_init_pier(pir_u);
return pir_u;
}
@ -1970,7 +1986,31 @@ u3_pier_boot(u3_noun who, // identity
/* make/load pier
*/
pir_u = _pier_boot_make(who, tic, sec, pax, sys);
pir_u = _pier_boot_make(pax, sys);
/* set boot params
*/
{
{
u3_noun how = u3dc("scot", 'p', u3k(who));
pir_u->who_c = u3r_string(how);
u3z(how);
fprintf(stderr, "boot: ship: %s\r\n", pir_u->who_c);
}
u3r_chubs(0, 2, pir_u->who_d, who);
u3r_chubs(0, 1, pir_u->tic_d, tic);
u3r_chubs(0, 1, pir_u->sec_d, sec);
u3z(tic);
u3z(sec);
u3z(who);
}
/* initialize boot i/o
*/
_pier_loop_init_pier(pir_u);
/* initialize polling handle
*/
@ -1984,3 +2024,29 @@ u3_pier_boot(u3_noun who, // identity
/* XX: _pier_loop_exit() should be called somewhere, but is not.
*/
}
/* u3_pier_stay(): resume the new pier system.
*/
void
u3_pier_stay(u3_noun pax)
{
u3_pier* pir_u;
/* make/load pier
*/
pir_u = _pier_boot_make(pax, u3_nul);
/* initialize polling handle
*/
uv_prepare_init(u3_Host.lup_u, &pir_u->pep_u);
uv_prepare_start(&pir_u->pep_u, _pier_loop_prepare);
_pier_loop_init_pier(pir_u);
/* initialize loop - move to _pier_boot_make().
*/
_pier_loop_init();
/* XX: _pier_loop_exit() should be called somewhere, but is not.
*/
}

View File

@ -111,13 +111,10 @@ _reck_kick_term(u3_pier* pir_u, u3_noun pox, c3_l tid_l, u3_noun fav)
case c3__init: p_fav = u3t(fav);
{
u3A->own = u3nc(u3k(p_fav), u3A->own);
u3_noun hox = u3dc("scot", 'p', u3k(p_fav));
c3_c* nam_c = u3r_string(hox);
// uL(fprintf(uH, "kick: init: %s\n", nam_c));
free(nam_c); u3z(pox); u3z(hox); u3z(fav); return c3y;
// king ignores %init
// u3A->own = u3nc(u3k(p_fav), u3A->own);
// uL(fprintf(uH, "kick: init: %d\n", p_fav));
u3z(pox); u3z(fav); return c3y;
} break;
case c3__mass: p_fav = u3t(fav);
@ -226,8 +223,8 @@ _reck_kick_ames(u3_pier* pir_u, u3_noun pox, u3_noun fav)
default: break;
case c3__init: p_fav = u3t(fav);
{
u3A->own = u3nc(u3k(p_fav), u3A->own);
// king ignores %init
// u3A->own = u3nc(u3k(p_fav), u3A->own);
// uL(fprintf(uH, "kick: init: %d\n", p_fav));
u3z(pox); u3z(fav); return c3y;
} break;
@ -315,8 +312,8 @@ _reck_kick_spec(u3_pier* pir_u, u3_noun pox, u3_noun fav)
case c3__init: p_fav = u3t(fav);
{
u3A->own = u3nc(u3k(p_fav), u3A->own);
// king ignores %init
// u3A->own = u3nc(u3k(p_fav), u3A->own);
// uL(fprintf(uH, "kick: init: %d\n", p_fav));
u3z(pox); u3z(fav); return c3y;
} break;

View File

@ -37,9 +37,12 @@
**
** ++ plea :: from serf to lord
** $% $: $play :: send events
** p/@ :: first number expected
** q/@ :: mug of state (or 0 to boot)
** == ::
** $= p ::
** %- unit :: ~ if no snapshot
** $: p=@ :: first number expected
** q=@ :: mug of state
** r=[our=@p fak=?] :: [identity fake?]
** == == ::
** $: $done :: event executed unchanged
** p/@ :: number of this event
** q/@ :: mug of state (or 0)
@ -208,6 +211,33 @@ _serf_poke_live(c3_d evt_d, // event number
u3_noun vir = u3k(u3h(u3t(gon)));
u3_noun cor = u3k(u3t(u3t(gon)));
// single-home
//
// XX revise when real keys are supported
// XX dispatch on evt_d, wire, or card tag?
//
if ( 6ULL == evt_d ) {
// vir=[[wire %veal @p] ~]
// fec=[%veal @p]
//
u3_noun fec = u3t(u3h(vir));
c3_assert( c3__veal == u3h(fec) );
c3_assert( u3_none == u3A->our );
u3A->our = u3k(u3t(fec));
u3A->fak = c3y;
{
u3_noun nam = u3dc("scot", 'p', u3k(u3A->our));
c3_c* nam_c = u3r_string(nam);
fprintf(stderr, "boot: ship: %s%s\r\n", nam_c,
(c3y == u3A->fak) ? " (fake)" : "");
free(nam_c);
u3z(nam);
}
}
_serf_sure(ovo, vir, cor);
}
}
@ -355,11 +385,19 @@ _serf_poke(void* vod_p, u3_noun mat)
void
u3_serf_boot(void)
{
c3_d nex_d = u3A->ent_d + 1ULL;
c3_d nex_d = 1ULL;
u3_noun dat = u3_nul;
if ( u3_none != u3A->our ) {
nex_d = u3A->ent_d + 1ULL;
dat = u3nc(u3_nul, u3nt(u3i_chubs(1, &nex_d),
0, // XX u3r_mug(u3A->roc),
u3nc(u3k(u3A->our), u3k(u3A->fak))));
}
fprintf(stderr, "serf: play %lld\r\n", nex_d);
_serf_send(u3nt(c3__play, u3i_chubs(1, &nex_d), 0));
_serf_send(u3nc(c3__play, dat));
}
/* u3_serf_main(): main() when run as urbit-client