| 604 | } bootstrap_production_context_t; |
| 605 | |
| 606 | static cbm_daemon_bootstrap_probe_status_t bootstrap_production_probe( |
| 607 | void *context, const cbm_daemon_ipc_endpoint_t *endpoint, |
| 608 | const cbm_daemon_build_identity_t *identity, uint32_t timeout_ms, |
| 609 | cbm_daemon_runtime_client_t **client_out, cbm_daemon_runtime_connect_result_t *result_out) { |
| 610 | bootstrap_production_context_t *production = context; |
| 611 | if (!production || !production->cohort || !production->cohort->manager) { |
| 612 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 613 | } |
| 614 | cbm_version_cohort_daemon_presence_t claim = |
| 615 | cbm_version_cohort_daemon_claim_presence(production->cohort->manager); |
| 616 | if (claim == CBM_VERSION_COHORT_DAEMON_ABSENT) { |
| 617 | int lifetime = cbm_daemon_ipc_lifetime_reservation_probe(endpoint); |
| 618 | if (lifetime == 0) { |
| 619 | /* Do not spend the per-connect timeout polling a generation that |
| 620 | * both independent ownership signals prove absent. The startup |
| 621 | * lock and its mandatory re-probe serialize a concurrent launch. */ |
| 622 | return CBM_DAEMON_BOOTSTRAP_PROBE_UNAVAILABLE; |
| 623 | } |
| 624 | if (lifetime != 1) { |
| 625 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 626 | } |
| 627 | } else if (claim != CBM_VERSION_COHORT_DAEMON_COORDINATED) { |
| 628 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 629 | } |
| 630 | |
| 631 | *client_out = cbm_daemon_runtime_client_connect(endpoint, identity, timeout_ms, result_out); |
| 632 | if (*client_out) { |
| 633 | return CBM_DAEMON_BOOTSTRAP_PROBE_CONNECTED; |
| 634 | } |
| 635 | |
| 636 | /* Ownership may turn over while the connection attempt is in flight. |
| 637 | * Re-observe both signals so disappearance is not sticky and a live or |
| 638 | * cleaning-up generation is never mistaken for absence. */ |
| 639 | claim = cbm_version_cohort_daemon_claim_presence(production->cohort->manager); |
| 640 | if (claim == CBM_VERSION_COHORT_DAEMON_COORDINATED) { |
| 641 | return cbm_daemon_bootstrap_classify_failed_connect(result_out, 1); |
| 642 | } |
| 643 | if (claim != CBM_VERSION_COHORT_DAEMON_ABSENT) { |
| 644 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 645 | } |
| 646 | int lifetime_status = cbm_daemon_ipc_lifetime_reservation_probe(endpoint); |
| 647 | return cbm_daemon_bootstrap_classify_failed_connect(result_out, lifetime_status); |
| 648 | } |
| 649 | |
| 650 | static cbm_version_cohort_status_t bootstrap_production_cohort_acquire( |
| 651 | void *context, const cbm_daemon_ipc_endpoint_t *endpoint, |
nothing calls this directly
no test coverage detected