| 573 | } bootstrap_production_context_t; |
| 574 | |
| 575 | static cbm_daemon_bootstrap_probe_status_t bootstrap_production_probe( |
| 576 | void *context, const cbm_daemon_ipc_endpoint_t *endpoint, |
| 577 | const cbm_daemon_build_identity_t *identity, uint32_t timeout_ms, |
| 578 | cbm_daemon_runtime_client_t **client_out, cbm_daemon_runtime_connect_result_t *result_out) { |
| 579 | bootstrap_production_context_t *production = context; |
| 580 | if (!production || !production->cohort || !production->cohort->manager) { |
| 581 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 582 | } |
| 583 | cbm_version_cohort_daemon_presence_t claim = |
| 584 | cbm_version_cohort_daemon_claim_presence(production->cohort->manager); |
| 585 | if (claim == CBM_VERSION_COHORT_DAEMON_ABSENT) { |
| 586 | int lifetime = cbm_daemon_ipc_lifetime_reservation_probe(endpoint); |
| 587 | if (lifetime == 0) { |
| 588 | /* Do not spend the per-connect timeout polling a generation that |
| 589 | * both independent ownership signals prove absent. The startup |
| 590 | * lock and its mandatory re-probe serialize a concurrent launch. */ |
| 591 | return CBM_DAEMON_BOOTSTRAP_PROBE_UNAVAILABLE; |
| 592 | } |
| 593 | if (lifetime != 1) { |
| 594 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 595 | } |
| 596 | } else if (claim != CBM_VERSION_COHORT_DAEMON_COORDINATED) { |
| 597 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 598 | } |
| 599 | |
| 600 | *client_out = cbm_daemon_runtime_client_connect(endpoint, identity, timeout_ms, result_out); |
| 601 | if (*client_out) { |
| 602 | return CBM_DAEMON_BOOTSTRAP_PROBE_CONNECTED; |
| 603 | } |
| 604 | |
| 605 | /* Ownership may turn over while the connection attempt is in flight. |
| 606 | * Re-observe both signals so disappearance is not sticky and a live or |
| 607 | * cleaning-up generation is never mistaken for absence. */ |
| 608 | claim = cbm_version_cohort_daemon_claim_presence(production->cohort->manager); |
| 609 | if (claim == CBM_VERSION_COHORT_DAEMON_COORDINATED) { |
| 610 | return cbm_daemon_bootstrap_classify_failed_connect(result_out, 1); |
| 611 | } |
| 612 | if (claim != CBM_VERSION_COHORT_DAEMON_ABSENT) { |
| 613 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 614 | } |
| 615 | int lifetime_status = cbm_daemon_ipc_lifetime_reservation_probe(endpoint); |
| 616 | return cbm_daemon_bootstrap_classify_failed_connect(result_out, lifetime_status); |
| 617 | } |
| 618 | |
| 619 | static cbm_version_cohort_status_t bootstrap_production_cohort_acquire( |
| 620 | void *context, const cbm_daemon_ipc_endpoint_t *endpoint, |
nothing calls this directly
no test coverage detected