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

Function runtime_accept_loop

src/daemon/runtime.c:2090–2125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2088}
2089
2090static void *runtime_accept_loop(void *opaque) {
2091 cbm_daemon_runtime_service_t *service = opaque;
2092 for (;;) {
2093 runtime_reap_completed_workers(service);
2094 cbm_mutex_lock(&service->mutex);
2095 cbm_daemon_runtime_service_state_t state = service->state;
2096 cbm_mutex_unlock(&service->mutex);
2097 if (state == CBM_DAEMON_RUNTIME_SERVICE_EXITED) {
2098 break;
2099 }
2100 if (state == CBM_DAEMON_RUNTIME_SERVICE_STOPPING) {
2101 runtime_service_interrupt_connections(service);
2102 if (runtime_service_can_exit(service, cbm_now_ms())) {
2103 break;
2104 }
2105 uint64_t tick_deadline = runtime_deadline_after(1);
2106 runtime_wait_tick(tick_deadline);
2107 continue;
2108 }
2109
2110 cbm_daemon_ipc_connection_t *connection = NULL;
2111 int accepted =
2112 cbm_daemon_ipc_accept(service->listener, RUNTIME_ACCEPT_POLL_MS, &connection);
2113 if (accepted == 1 && connection) {
2114 runtime_accept_connection(service, connection);
2115 } else if (accepted < 0) {
2116 /* IPC intentionally combines invalid-peer and listener errors.
2117 * Retry while RUNNING so one hostile peer cannot stop the daemon. */
2118 uint64_t tick_deadline = runtime_deadline_after(1);
2119 runtime_wait_tick(tick_deadline);
2120 }
2121 }
2122 runtime_reap_completed_workers(service);
2123 atomic_store_explicit(&service->accept_thread_done, true, memory_order_release);
2124 return NULL;
2125}
2126
2127static char *runtime_string_copy_bounded(const char *value, size_t capacity) {
2128 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