feat(ha-convergence-recovery): self-restart primitive + demotion convergence (task 2.2)
This commit is contained in:
parent
c8e55947c2
commit
09103a3141
7 changed files with 337 additions and 43 deletions
|
|
@ -109,6 +109,28 @@ static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
|||
|
||||
static struct argp argp = { options, parse_opt, args_doc, doc };
|
||||
|
||||
/*
|
||||
* Saved argv for self-restart (ha-convergence-recovery Req 1.3).
|
||||
*
|
||||
* main() captures the original, NULL-terminated argv pointer before argp_parse
|
||||
* mutates the program state, so ha_self_restart can execv() the controller back
|
||||
* into existence after a demotion/rejoin convergence truncates the divergent WAL
|
||||
* suffix. argv supplied to main() is already NULL-terminated per C11 §5.1.2.2.1
|
||||
* (argv[argc] == NULL) and lives for the whole program lifetime, so storing the
|
||||
* pointer is sufficient — no copy needed.
|
||||
*/
|
||||
static char **g_saved_argv = NULL;
|
||||
|
||||
/*
|
||||
* controller_saved_argv — accessor declared in ha.h, consumed by ha_self_restart.
|
||||
* Returns the NULL-terminated argv captured by main(), or NULL if never saved
|
||||
* (e.g. unit-test binaries that do not run main()).
|
||||
*/
|
||||
char **controller_saved_argv(void)
|
||||
{
|
||||
return g_saved_argv;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
struct arguments arguments;
|
||||
|
|
@ -121,6 +143,10 @@ int main(int argc, char* argv[])
|
|||
char cert_file[XCE_MAXPATH_LEN + 1];
|
||||
char myname[XCE_MAXNAME_LEN + 1];
|
||||
|
||||
/* Capture the NULL-terminated argv for self-restart BEFORE argp_parse so a
|
||||
* later demotion/rejoin convergence can execv() the same image (Req 1.3). */
|
||||
g_saved_argv = argv;
|
||||
|
||||
memset(&arguments, 0x0, sizeof(arguments));
|
||||
arguments.conf_keep_n = 2;
|
||||
arguments.conf_stale_timeout = 86400;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue