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

Function runtime_accept_loop

src/daemon/runtime.c:2031–2066  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2029}
2030
2031static void *runtime_accept_loop(void *opaque) {
2032 cbm_daemon_runtime_service_t *service = opaque;
2033 for (;;) {
2034 runtime_reap_completed_workers(service);
2035 cbm_mutex_lock(&service->mutex);
2036 cbm_daemon_runtime_service_state_t state = service->state;
2037 cbm_mutex_unlock(&service->mutex);
2038 if (state == CBM_DAEMON_RUNTIME_SERVICE_EXITED) {
2039 break;
2040 }
2041 if (state == CBM_DAEMON_RUNTIME_SERVICE_STOPPING) {
2042 runtime_service_interrupt_connections(service);
2043 if (runtime_service_can_exit(service, cbm_now_ms())) {
2044 break;
2045 }
2046 uint64_t tick_deadline = runtime_deadline_after(1);
2047 runtime_wait_tick(tick_deadline);
2048 continue;
2049 }
2050
2051 cbm_daemon_ipc_connection_t *connection = NULL;
2052 int accepted =
2053 cbm_daemon_ipc_accept(service->listener, RUNTIME_ACCEPT_POLL_MS, &connection);
2054 if (accepted == 1 && connection) {
2055 runtime_accept_connection(service, connection);
2056 } else if (accepted < 0) {
2057 /* IPC intentionally combines invalid-peer and listener errors.
2058 * Retry while RUNNING so one hostile peer cannot stop the daemon. */
2059 uint64_t tick_deadline = runtime_deadline_after(1);
2060 runtime_wait_tick(tick_deadline);
2061 }
2062 }
2063 runtime_reap_completed_workers(service);
2064 atomic_store_explicit(&service->accept_thread_done, true, memory_order_release);
2065 return NULL;
2066}
2067
2068static char *runtime_string_copy_bounded(const char *value, size_t capacity) {
2069 size_t length = 0;

Callers

nothing calls this directly

Calls 10

cbm_mutex_lockFunction · 0.85
cbm_mutex_unlockFunction · 0.85
runtime_service_can_exitFunction · 0.85
cbm_now_msFunction · 0.85
runtime_deadline_afterFunction · 0.85
runtime_wait_tickFunction · 0.85
cbm_daemon_ipc_acceptFunction · 0.85

Tested by

no test coverage detected