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

Function runtime_service_can_exit

src/daemon/runtime.c:2385–2408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2383}
2384
2385static bool runtime_service_can_exit(cbm_daemon_runtime_service_t *service, uint64_t now_ms) {
2386 bool can_exit = false;
2387 cbm_mutex_lock(&service->mutex);
2388 if (service->state == CBM_DAEMON_RUNTIME_SERVICE_STOPPING && service->active_connections == 0) {
2389 bool drained = cbm_daemon_should_exit(service->coordinator, now_ms);
2390 if (!drained && service->activation_shutdown_requested) {
2391 /* Activation can arrive while the daemon has no committed
2392 * coordinator client, so no final disconnect exists to flip the
2393 * coordinator's terminal bit. Resource emptiness is equivalent
2394 * once the runtime has atomically stopped all new admission. */
2395 drained = cbm_daemon_active_clients(service->coordinator) == 0 &&
2396 cbm_daemon_active_jobs(service->coordinator) == 0 &&
2397 cbm_daemon_active_watches(service->coordinator) == 0;
2398 }
2399 bool deadline_reached =
2400 service->stop_deadline_ms != 0 && now_ms >= service->stop_deadline_ms;
2401 can_exit = drained || deadline_reached || service->emergency_stop;
2402 if (can_exit) {
2403 service->state = CBM_DAEMON_RUNTIME_SERVICE_EXITED;
2404 }
2405 }
2406 cbm_mutex_unlock(&service->mutex);
2407 return can_exit;
2408}
2409
2410static void *runtime_accept_loop(void *opaque) {
2411 cbm_daemon_runtime_service_t *service = opaque;

Callers 1

runtime_accept_loopFunction · 0.85

Calls 6

cbm_mutex_lockFunction · 0.85
cbm_daemon_should_exitFunction · 0.85
cbm_daemon_active_jobsFunction · 0.85
cbm_mutex_unlockFunction · 0.85

Tested by

no test coverage detected