MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / bootstrap_fake_probe

Function bootstrap_fake_probe

tests/test_daemon_bootstrap.c:124–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124static cbm_daemon_bootstrap_probe_status_t bootstrap_fake_probe(
125 void *opaque, const cbm_daemon_ipc_endpoint_t *endpoint,
126 const cbm_daemon_build_identity_t *identity, uint32_t timeout_ms,
127 cbm_daemon_runtime_client_t **client_out, cbm_daemon_runtime_connect_result_t *result_out) {
128 (void)endpoint;
129 (void)identity;
130 (void)timeout_ms;
131 bootstrap_fake_ops_t *fake = opaque;
132 atomic_fetch_add(&fake->probe_count, 1);
133 memset(result_out, 0, sizeof(*result_out));
134 *client_out = NULL;
135 int reserved_remaining = atomic_load(&fake->reserved_probes_remaining);
136 while (reserved_remaining > 0 &&
137 !atomic_compare_exchange_weak(&fake->reserved_probes_remaining, &reserved_remaining,
138 reserved_remaining - 1)) {}
139 if (reserved_remaining > 0) {
140 if (reserved_remaining == 1 && atomic_load(&fake->connect_after_reserved)) {
141 atomic_store(&fake->available, true);
142 }
143 return CBM_DAEMON_BOOTSTRAP_PROBE_RESERVED;
144 }
145 int terminal_remaining = atomic_load(&fake->terminal_probes_remaining);
146 while (terminal_remaining > 0 &&
147 !atomic_compare_exchange_weak(&fake->terminal_probes_remaining, &terminal_remaining,
148 terminal_remaining - 1)) {}
149 if (terminal_remaining > 0) {
150 return CBM_DAEMON_BOOTSTRAP_PROBE_TERMINAL;
151 }
152 if (fake->forced_probe == CBM_DAEMON_BOOTSTRAP_PROBE_RESERVED) {
153 return fake->forced_probe;
154 }
155 if (fake->forced_probe == CBM_DAEMON_BOOTSTRAP_PROBE_CONFLICT) {
156 result_out->status = CBM_DAEMON_RUNTIME_CONNECT_CONFLICT;
157 result_out->hello_status = CBM_DAEMON_HELLO_BUILD_CONFLICT;
158 snprintf(result_out->message, sizeof(result_out->message),
159 "CBM daemon could not start: conflicting versions");
160 return fake->forced_probe;
161 }
162 if (fake->forced_probe == CBM_DAEMON_BOOTSTRAP_PROBE_TERMINAL) {
163 return fake->forced_probe;
164 }
165 if (atomic_load(&fake->available) && atomic_load(&fake->connect_requires_unlocked) &&
166 atomic_load(&fake->lock_held) != 0) {
167 return CBM_DAEMON_BOOTSTRAP_PROBE_RESERVED;
168 }
169 if (atomic_load(&fake->available)) {
170 result_out->status = CBM_DAEMON_RUNTIME_CONNECT_ACCEPTED;
171 result_out->hello_status = CBM_DAEMON_HELLO_COMPATIBLE;
172 result_out->client_id = 1;
173 *client_out = (cbm_daemon_runtime_client_t *)(uintptr_t)1;
174 return CBM_DAEMON_BOOTSTRAP_PROBE_CONNECTED;
175 }
176 return CBM_DAEMON_BOOTSTRAP_PROBE_UNAVAILABLE;
177}
178
179static cbm_version_cohort_status_t bootstrap_fake_cohort_acquire(
180 void *opaque, const cbm_daemon_ipc_endpoint_t *endpoint,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected