mirror of
https://github.com/urbit/shrub.git
synced 2024-12-18 15:55:00 +03:00
vere: adds dedicated replay command: play
This commit is contained in:
parent
67ef11117f
commit
82d5738df4
@ -9,6 +9,7 @@
|
||||
#include "rsignal.h"
|
||||
#include <vere/serf.h>
|
||||
#include "vere/vere.h"
|
||||
#include "vere/mars.h"
|
||||
#if !defined(U3_OS_mingw)
|
||||
#include <sigsegv.h>
|
||||
#endif
|
||||
@ -649,6 +650,7 @@ _cw_usage(c3_c* bin_c)
|
||||
" %s info %.*s print pier info:\n",
|
||||
" %s meld %.*s deduplicate snapshot:\n",
|
||||
" %s pack %.*s defragment snapshot:\n",
|
||||
" %s play %.*s recompute events:\n",
|
||||
" %s prep %.*s prepare for upgrade:\n",
|
||||
" %s next %.*s request upgrade:\n",
|
||||
" %s queu %.*s<at-event> cue state:\n",
|
||||
@ -1768,6 +1770,113 @@ _cw_pack(c3_i argc, c3_c* argv[])
|
||||
u3m_stop();
|
||||
}
|
||||
|
||||
/* _cw_play_slog(): print during replay.
|
||||
*/
|
||||
static void
|
||||
_cw_play_slog(u3_noun hod)
|
||||
{
|
||||
u3_pier_tank(0, 0, u3k(u3t(hod)));
|
||||
u3z(hod);
|
||||
}
|
||||
|
||||
/* _cw_play(): replay events, but better.
|
||||
*/
|
||||
static void
|
||||
_cw_play(c3_i argc, c3_c* argv[])
|
||||
{
|
||||
c3_i ch_i, lid_i;
|
||||
c3_w arg_w;
|
||||
|
||||
static struct option lop_u[] = {
|
||||
{ "loom", required_argument, NULL, c3__loom },
|
||||
{ "no-demand", no_argument, NULL, 6 },
|
||||
{ "replay-to", required_argument, NULL, 'n' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
u3_Host.dir_c = _main_pier_run(argv[0]);
|
||||
|
||||
while ( -1 != (ch_i=getopt_long(argc, argv, "n:", lop_u, &lid_i)) ) {
|
||||
switch ( ch_i ) {
|
||||
case 6: { // no-demand
|
||||
u3_Host.ops_u.map = c3n;
|
||||
u3C.wag_w |= u3o_no_demand;
|
||||
} break;
|
||||
|
||||
case c3__loom: {
|
||||
c3_w lom_w;
|
||||
c3_o res_o = _main_readw(optarg, u3a_bits + 3, &lom_w);
|
||||
if ( (c3n == res_o) || (lom_w < 20) ) {
|
||||
fprintf(stderr, "error: --loom must be >= 20 and <= %u\r\n", u3a_bits + 2);
|
||||
exit(1);
|
||||
}
|
||||
u3_Host.ops_u.lom_y = lom_w;
|
||||
} break;
|
||||
|
||||
case 'n': {
|
||||
u3_Host.ops_u.til_c = strdup(optarg);
|
||||
break;
|
||||
}
|
||||
|
||||
case '?': {
|
||||
fprintf(stderr, "invalid argument\r\n");
|
||||
exit(1);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
// argv[optind] is always "play"
|
||||
//
|
||||
|
||||
if ( !u3_Host.dir_c ) {
|
||||
if ( optind + 1 < argc ) {
|
||||
u3_Host.dir_c = argv[optind + 1];
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "invalid command, pier required\r\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
optind++;
|
||||
}
|
||||
|
||||
if ( optind + 1 != argc ) {
|
||||
fprintf(stderr, "invalid command\r\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// XX handle SIGTSTP so that the lockfile is not orphaned?
|
||||
//
|
||||
u3_disk* log_u = _cw_disk_init(u3_Host.dir_c); // XX s/b try_aquire lock
|
||||
|
||||
u3C.wag_w |= u3o_hashless;
|
||||
u3m_boot(u3_Host.dir_c, (size_t)1 << u3_Host.ops_u.lom_y);
|
||||
u3C.slog_f = _cw_play_slog;
|
||||
|
||||
{
|
||||
u3_mars mar_u = {
|
||||
.log_u = log_u,
|
||||
.dir_c = u3_Host.dir_c,
|
||||
.sen_d = u3A->eve_d,
|
||||
.dun_d = u3A->eve_d,
|
||||
.mug_l = u3r_mug(u3A->roc)
|
||||
};
|
||||
c3_d eve_d = 0;
|
||||
c3_c* eve_c = u3_Host.ops_u.til_c;
|
||||
|
||||
if ( u3_Host.ops_u.til_c ) {
|
||||
if ( 1 != sscanf(eve_c, "%" PRIu64 "", &eve_d) ) {
|
||||
fprintf(stderr, "mars: replay-to invalid: '%s'\r\n", eve_c);
|
||||
}
|
||||
}
|
||||
|
||||
u3_mars_play(&mar_u, eve_d);
|
||||
}
|
||||
|
||||
u3_disk_exit(log_u);
|
||||
u3m_stop();
|
||||
}
|
||||
|
||||
/* _cw_prep(): prepare for upgrade
|
||||
*/
|
||||
static void
|
||||
@ -2061,6 +2170,7 @@ _cw_utils(c3_i argc, c3_c* argv[])
|
||||
// [%meld dir=@t] :: deduplicate
|
||||
// [?(%next %upgrade) dir=@t] :: upgrade
|
||||
// [%pack dir=@t] :: defragment
|
||||
// [%play dir=@t] :: recompute
|
||||
// [%prep dir=@t] :: prep upgrade
|
||||
// [%queu dir=@t eve=@ud] :: cue state
|
||||
// [?(%vere %fetch-vere) dir=@t] :: download vere
|
||||
@ -2101,6 +2211,7 @@ _cw_utils(c3_i argc, c3_c* argv[])
|
||||
case c3__meld: _cw_meld(argc, argv); return 1;
|
||||
case c3__next: _cw_next(argc, argv); return 2; // continue on
|
||||
case c3__pack: _cw_pack(argc, argv); return 1;
|
||||
case c3__play: _cw_play(argc, argv); return 1;
|
||||
case c3__prep: _cw_prep(argc, argv); return 2; // continue on
|
||||
case c3__queu: _cw_queu(argc, argv); return 1;
|
||||
case c3__vere: _cw_vere(argc, argv); return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user