vere: adds basic info printfs on SIGINFO/SIGUSR1

This commit is contained in:
Joe Bryan 2020-06-25 01:37:31 -07:00
parent d96a05e387
commit b860e8cd63
7 changed files with 201 additions and 4 deletions

View File

@ -538,6 +538,7 @@
*/
typedef struct _u3_auto_cb {
void (*talk_f)(struct _u3_auto*);
void (*info_f)(struct _u3_auto*);
c3_o (*kick_f)(struct _u3_auto*, u3_noun, u3_noun);
void (*exit_f)(struct _u3_auto*); // XX close_cb?
} u3_auto_cb;
@ -760,6 +761,11 @@
u3_auto*
u3_auto_init(u3_pier* pir_u);
/* u3_auto_info(): print status info.
*/
void
u3_auto_info(u3_auto* car_u);
/* u3_auto_exit(): close all drivers.
*/
void
@ -831,6 +837,11 @@
u3_disk*
u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u);
/* u3_disk_info(): print status info.
*/
void
u3_disk_info(u3_disk* log_u);
/* u3_disk_exit(): close [log_u] and dispose.
*/
void
@ -880,6 +891,11 @@
c3_d key_d[4],
u3_lord_cb cb_u);
/* u3_lord_info(): print status info.
*/
void
u3_lord_info(u3_lord* god_u);
/* u3_lord_exit(): shutdown gracefully.
*/
void
@ -1224,6 +1240,11 @@
c3_o
u3_pier_pack(u3_pier* pir_u);
/* u3_pier_info(): print status info.
*/
void
u3_pier_info(u3_pier* pir_u);
/* u3_pier_boot(): start the new pier system.
*/
u3_pier*
@ -1288,6 +1309,11 @@
u3_pier*
u3_king_stub(void);
/* u3_king_info(): print status info.
*/
void
u3_king_info(void);
/* u3_king_done(): all piers closed
*/
void

View File

@ -339,12 +339,42 @@ u3_auto_exit(u3_auto* car_u)
}
}
/* u3_auto_info(): print status info.
*/
void
u3_auto_info(u3_auto* car_u)
{
u3_auto* nex_u;
u3l_log(" drivers:\n");
while ( car_u ) {
nex_u = car_u->nex_u;
u3l_log(" %.*s: live=%s, queue=%u\n",
u3r_met(3, car_u->nam_m),
(c3_c*)&car_u->nam_m,
( c3y == car_u->liv_o ) ? "&" : "|",
car_u->dep_w);
// XX details
//
if ( car_u->io.info_f ) {
c3_l cod_l = u3a_lush(car_u->nam_m);
car_u->io.info_f(car_u);
u3a_lop(cod_l);
}
car_u = nex_u;
}
}
/* _auto_link(): validate and link initalized [car_u]
*/
static u3_auto*
_auto_link(u3_auto* car_u, u3_pier* pir_u, u3_auto* nex_u)
{
// assert that io callbacks are present
// assert that io callbacks are present (info_f is optional)
//
c3_assert( car_u->io.talk_f );
c3_assert( car_u->io.kick_f );

View File

@ -645,6 +645,37 @@ u3_disk_exit(u3_disk* log_u)
c3_free(log_u);
}
/* u3_disk_info(): print status info.
*/
void
u3_disk_info(u3_disk* log_u)
{
u3l_log(" disk: live=%s, event=%" PRIu64 "\n",
( c3y == log_u->liv_o ) ? "&" : "|",
log_u->dun_d);
{
u3_read* red_u = log_u->red_u;
while ( red_u ) {
u3l_log(" read: %" PRIu64 "-%" PRIu64 "\n",
red_u->eve_d,
(red_u->eve_d + red_u->len_d) - 1);
}
}
if ( log_u->put_u.ext_u ) {
if ( log_u->put_u.ext_u != log_u->put_u.ent_u ) {
u3l_log(" save: %" PRIu64 "-%" PRIu64 "\n",
log_u->put_u.ext_u->eve_d,
log_u->put_u.ent_u->eve_d);
}
else {
u3l_log(" save: %" PRIu64 "\n", log_u->put_u.ext_u->eve_d);
}
}
}
/* u3_disk_init(): load or create pier directories and event log.
*/
u3_disk*

View File

@ -29,7 +29,7 @@
/* u3_ames: ames networking.
*/
typedef struct _u3_ames { // packet network state
u3_auto car_u; // driver
u3_auto car_u; // driver
union { //
uv_udp_t wax_u; //
uv_handle_t had_u; //
@ -701,6 +701,15 @@ _ames_io_exit(u3_auto* car_u)
uv_close(&sam_u->had_u, _ames_exit_cb);
}
/* _ames_io_info(): print status info.
*/
static void
_ames_io_info(u3_auto* car_u)
{
u3_ames* sam_u = (u3_ames*)car_u;
u3l_log(" dropped: %" PRIu64 "\n", sam_u->dop_d);
}
/* u3_ames_io_init(): initialize ames I/O.
*/
u3_auto*
@ -727,6 +736,7 @@ u3_ames_io_init(u3_pier* pir_u)
car_u->nam_m = c3__ames;
car_u->liv_o = c3n;
car_u->io.talk_f = _ames_io_talk;
car_u->io.info_f = _ames_io_info;
car_u->io.kick_f = _ames_io_kick;
car_u->io.exit_f = _ames_io_exit;
@ -735,5 +745,4 @@ u3_ames_io_init(u3_pier* pir_u)
// car_u->ev.bail_f = ...;
return car_u;
}
}

View File

@ -581,6 +581,12 @@ _daemon_sign_cb(uv_signal_t* sil_u, c3_i num_i)
u3_term_ef_winc();
break;
}
case SIGUSR1:
case SIGINFO: {
u3_king_info();
break;
}
}
}
@ -751,6 +757,14 @@ _king_forall(void (*pir_f)(u3_pier*))
}
}
/* u3_king_info(): print status info.
*/
void
u3_king_info(void)
{
_king_forall(u3_pier_info);
}
/* _king_forall_unlink(): run on all piers, unlinking from king.
*/
static void

View File

@ -975,6 +975,18 @@ _lord_on_serf_bail(void* ptr_v,
_lord_bail(god_u);
}
/* u3_lord_info(): print status info.
*/
void
u3_lord_info(u3_lord* god_u)
{
u3l_log(" lord: live=%s, event=%" PRIu64 ", mug=%x, queue=%u\n",
( c3y == god_u->liv_o ) ? "&" : "|",
god_u->eve_d,
god_u->mug_l,
god_u->dep_w);
}
/* u3_lord_init(): instantiate child process.
*/
u3_lord*

View File

@ -992,6 +992,81 @@ _pier_on_lord_live(void* vod_p)
}
}
/* u3_pier_info(): print status info.
*/
void
u3_pier_info(u3_pier* pir_u)
{
switch ( pir_u->sat_e ) {
default: {
u3l_log("pier: unknown state: %u\r\n", pir_u->sat_e);
} break;
case u3_psat_init: {
u3l_log("pier: init\n");
} break;
case u3_psat_boot: {
u3l_log("pier: boot\n");
} break;
case u3_psat_play: {
u3l_log("pier: play\n");
{
u3_play* pay_u = pir_u->pay_u;
u3l_log(" target: %" PRIu64 "\n", pay_u->eve_d);
u3l_log(" sent: %" PRIu64 "\n", pay_u->sen_d);
u3l_log(" read: %" PRIu64 "\n", pay_u->req_d);
}
} break;
case u3_psat_work: {
u3l_log("pier: work\n");
{
u3_work* wok_u = pir_u->wok_u;
u3l_log(" effects:\n");
u3l_log(" released: %" PRIu64 "\n", wok_u->fec_u.rel_d);
if ( wok_u->fec_u.ext_u ) {
if ( wok_u->fec_u.ext_u != wok_u->fec_u.ent_u ) {
u3l_log(" pending %" PRIu64 "-%" PRIu64 "\n",
wok_u->fec_u.ext_u->eve_d,
wok_u->fec_u.ent_u->eve_d);
}
else {
u3l_log(" pending %" PRIu64 "\n", wok_u->fec_u.ext_u->eve_d);
}
}
if ( wok_u->wal_u ) {
u3l_log("wall: %" PRIu64 "\n", wok_u->wal_u->eve_d);
}
if ( wok_u->car_u ) {
u3_auto_info(wok_u->car_u);
}
}
} break;
case u3_psat_done: {
u3l_log("pier: done\n");
} break;
}
if ( pir_u->log_u ) {
u3_disk_info(pir_u->log_u);
}
if ( pir_u->god_u ) {
u3_lord_info(pir_u->god_u);
}
}
/* _pier_init(): create a pier, loading existing.
*/
static u3_pier*