vere: disk info

Fixes an apparent infinite loop in u3_disk_slog if red_u is not 0.
This commit is contained in:
Jōshin 2022-03-06 15:31:03 -05:00
parent 382f06efe9
commit 3400e55b2d
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0
3 changed files with 72 additions and 23 deletions

View File

@ -931,10 +931,15 @@
u3_disk*
u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u);
/* u3_disk_info(): print status info.
/* u3_disk_info(): status info as $mass.
*/
u3_noun
u3_disk_info(u3_disk* log_u);
/* u3_disk_slog(): print status info.
*/
void
u3_disk_info(u3_disk* log_u);
u3_disk_slog(u3_disk* log_u);
/* u3_disk_exit(): close [log_u] and dispose.
*/
@ -1317,7 +1322,7 @@
void
u3_pier_pack(u3_pier* pir_u);
/* u3_pier_info(): pier status info as noun.
/* u3_pier_info(): pier status info as $mass.
*/
u3_noun
u3_pier_info(u3_pier* pir_u);

View File

@ -644,10 +644,46 @@ u3_disk_exit(u3_disk* log_u)
#endif
}
/* u3_disk_info(): print status info.
/* u3_disk_info(): status info as a (list mass).
*/
u3_noun
u3_disk_info(u3_disk* log_u)
{
u3_read* red_u = log_u->red_u;
u3_noun lit = u3i_list(
u3_pier_mase("live", log_u->liv_o),
u3_pier_mase("event", u3i_chub(log_u->dun_d)),
u3_none);
if ( log_u->put_u.ext_u ) {
lit = u3nc(
u3_pier_mass(
c3__save,
u3i_list(
u3_pier_mase("save-start", u3i_chub(log_u->put_u.ext_u->eve_d)),
u3_pier_mase("save-final", u3i_chub(log_u->put_u.ent_u->eve_d)),
u3_none)),
lit);
}
while ( red_u ) {
lit = u3nc(
u3_pier_mass(
c3__read,
u3i_list(
u3_pier_mase("start", u3i_chub(red_u->eve_d)),
u3_pier_mase("final", u3i_chub(red_u->eve_d + red_u->len_d - 1)),
u3_none)),
lit);
red_u = red_u->nex_u;
}
return u3_pier_mass(c3__disk, lit);
}
/* u3_disk_slog(): print status info.
*/
void
u3_disk_info(u3_disk* log_u)
u3_disk_slog(u3_disk* log_u)
{
u3l_log(" disk: live=%s, event=%" PRIu64 "\n",
( c3y == log_u->liv_o ) ? "&" : "|",
@ -660,6 +696,7 @@ u3_disk_info(u3_disk* log_u)
u3l_log(" read: %" PRIu64 "-%" PRIu64 "\n",
red_u->eve_d,
(red_u->eve_d + red_u->len_d) - 1);
red_u = red_u->nex_u;
}
}

View File

@ -1457,35 +1457,38 @@ u3_pier_mase(c3_c* cod_c, u3_noun dat)
u3_noun
u3_pier_info(u3_pier* pir_u)
{
// TODO disk/lord info
u3_noun nat;
// TODO lord info
//
switch (pir_u->sat_e) {
default: {
return u3_pier_mass(u3i_string("state-unknown"), u3_nul);
}
nat = u3_pier_mass(u3i_string("state-unknown"), u3_nul);
} break;
case u3_psat_init: {
return u3_pier_mass(c3__init, u3_nul);
}
nat = u3_pier_mass(c3__init, u3_nul);
} break;
case u3_psat_boot: {
return u3_pier_mass(c3__boot, u3_nul);
}
nat = u3_pier_mass(c3__boot, u3_nul);
} break;
case u3_psat_play: {
u3_play* pay_u = pir_u->pay_u;
return u3_pier_mass(c3__play,
nat = u3_pier_mass(c3__play,
u3i_list(
u3_pier_mase("target", u3i_chub(pay_u->eve_d)),
u3_pier_mase("sent", u3i_chub(pay_u->sen_d)),
u3_pier_mase("read", u3i_chub(pay_u->req_d)),
u3_none));
}
} break;
case u3_psat_work: {
u3_work* wok_u = pir_u->wok_u;
u3_noun wok = u3_pier_mass(c3__work,
nat = u3_pier_mass(c3__work,
u3i_list(
u3_pier_mase("effects-released", u3i_chub(wok_u->fec_u.rel_d)),
u3_pier_mase("pending-any", __(wok_u->fec_u.ext_u)),
@ -1502,17 +1505,21 @@ u3_pier_info(u3_pier* pir_u)
( wok_u->wal_u
? u3i_chub(wok_u->wal_u->eve_d)
: 0)),
u3_pier_mass(c3__auto, u3_auto_info(wok_u->car_u)),
u3_none));
return u3_pier_mass(c3__pier,
u3i_list(wok, u3_pier_mass(c3__auto, u3_auto_info(wok_u->car_u)),
u3_none));
}
} break;
case u3_psat_done: {
return u3_pier_mass(c3__done, u3_nul);
}
nat = u3_pier_mass(c3__done, u3_nul);
} break;
}
return u3_pier_mass(
c3__pier,
u3i_list(
nat,
u3_disk_info(pir_u->log_u),
u3_none));
}
/* u3_pier_slog(): print status info.
@ -1581,7 +1588,7 @@ u3_pier_slog(u3_pier* pir_u)
}
if ( pir_u->log_u ) {
u3_disk_info(pir_u->log_u);
u3_disk_slog(pir_u->log_u);
}
if ( pir_u->god_u ) {