After this attempt spawned a daemon: did that daemon (or a sibling attempt * moments earlier) record a start failure? A found record ends the wait with * its cause -- respawning a deterministically failing daemon until the * deadline only produced "active or starting" (#1828). */
| 572 | * its cause -- respawning a deterministically failing daemon until the |
| 573 | * deadline only produced "active or starting" (#1828). */ |
| 574 | static bool bootstrap_start_failure_detected(const cbm_daemon_bootstrap_config_t *config, |
| 575 | const cbm_daemon_bootstrap_ops_t *ops, |
| 576 | uint64_t spawn_wall_s, bool force, |
| 577 | uint64_t *next_check_ms, |
| 578 | cbm_daemon_bootstrap_result_t *result_out) { |
| 579 | if (spawn_wall_s == 0 || !ops->start_failure_probe) { |
| 580 | return false; |
| 581 | } |
| 582 | uint64_t now_ms = cbm_now_ms(); |
| 583 | if (!force && now_ms < *next_check_ms) { |
| 584 | return false; |
| 585 | } |
| 586 | *next_check_ms = now_ms + BOOTSTRAP_START_FAILURE_CHECK_MS; |
| 587 | uint64_t not_before_s = spawn_wall_s > BOOTSTRAP_START_FAILURE_SKEW_S |
| 588 | ? spawn_wall_s - BOOTSTRAP_START_FAILURE_SKEW_S |
| 589 | : 0; |
| 590 | cbm_daemon_bootstrap_start_failure_t failure; |
| 591 | if (ops->start_failure_probe(ops->context, config->endpoint, not_before_s, &failure) != 1) { |
| 592 | return false; |
| 593 | } |
| 594 | char logs[BOOTSTRAP_PATH_CAP]; |
| 595 | if (!cbm_daemon_bootstrap_log_directory(logs, sizeof(logs))) { |
| 596 | logs[0] = '\0'; |
| 597 | } |
| 598 | cbm_daemon_bootstrap_start_failure_format(&failure, logs, result_out->message, |
| 599 | sizeof(result_out->message)); |
| 600 | return true; |
| 601 | } |
| 602 | |
| 603 | static void bootstrap_pause(uint64_t deadline) { |
| 604 | uint64_t now = cbm_now_ms(); |
no test coverage detected