| 968 | } bootstrap_production_context_t; |
| 969 | |
| 970 | static cbm_daemon_bootstrap_probe_status_t bootstrap_production_probe( |
| 971 | void *context, const cbm_daemon_ipc_endpoint_t *endpoint, |
| 972 | const cbm_daemon_build_identity_t *identity, uint32_t timeout_ms, |
| 973 | cbm_daemon_runtime_client_t **client_out, cbm_daemon_runtime_connect_result_t *result_out) { |
| 974 | bootstrap_production_context_t *production = context; |
| 975 | if (!production || !production->cohort || !production->cohort->manager) { |
| 976 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 977 | } |
| 978 | cbm_version_cohort_daemon_presence_t claim = |
| 979 | cbm_version_cohort_daemon_claim_presence(production->cohort->manager); |
| 980 | if (claim == CBM_VERSION_COHORT_DAEMON_ABSENT) { |
| 981 | int lifetime = cbm_daemon_ipc_lifetime_reservation_probe(endpoint); |
| 982 | if (lifetime == 0) { |
| 983 | /* Do not spend the per-connect timeout polling a generation that |
| 984 | * both independent ownership signals prove absent. The startup |
| 985 | * lock and its mandatory re-probe serialize a concurrent launch. */ |
| 986 | return CBM_DAEMON_BOOTSTRAP_PROBE_UNAVAILABLE; |
| 987 | } |
| 988 | if (lifetime != 1) { |
| 989 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 990 | } |
| 991 | } else if (claim != CBM_VERSION_COHORT_DAEMON_COORDINATED) { |
| 992 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 993 | } |
| 994 | |
| 995 | *client_out = cbm_daemon_runtime_client_connect(endpoint, identity, timeout_ms, result_out); |
| 996 | if (*client_out) { |
| 997 | return CBM_DAEMON_BOOTSTRAP_PROBE_CONNECTED; |
| 998 | } |
| 999 | |
| 1000 | /* Ownership may turn over while the connection attempt is in flight. |
| 1001 | * Re-observe both signals so disappearance is not sticky and a live or |
| 1002 | * cleaning-up generation is never mistaken for absence. */ |
| 1003 | claim = cbm_version_cohort_daemon_claim_presence(production->cohort->manager); |
| 1004 | if (claim == CBM_VERSION_COHORT_DAEMON_COORDINATED) { |
| 1005 | return cbm_daemon_bootstrap_classify_failed_connect(result_out, 1); |
| 1006 | } |
| 1007 | if (claim != CBM_VERSION_COHORT_DAEMON_ABSENT) { |
| 1008 | return CBM_DAEMON_BOOTSTRAP_PROBE_ERROR; |
| 1009 | } |
| 1010 | int lifetime_status = cbm_daemon_ipc_lifetime_reservation_probe(endpoint); |
| 1011 | return cbm_daemon_bootstrap_classify_failed_connect(result_out, lifetime_status); |
| 1012 | } |
| 1013 | |
| 1014 | static cbm_version_cohort_status_t bootstrap_production_cohort_acquire( |
| 1015 | void *context, const cbm_daemon_ipc_endpoint_t *endpoint, |
nothing calls this directly
no test coverage detected