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

Function cbm_ui_log_init

src/ui/http_server.c:440–457  ·  view source on GitHub ↗

Safe for concurrent callers: only publishes INITED after cbm_mutex_init() * has completed. Callers that lose the CAS race spin until init finishes. */

Source from the content-addressed store, hash-verified

438/* Safe for concurrent callers: only publishes INITED after cbm_mutex_init()
439 * has completed. Callers that lose the CAS race spin until init finishes. */
440void cbm_ui_log_init(void) {
441 int state = atomic_load(&g_log_mutex_init);
442 if (state == CBM_LOG_MUTEX_INITED)
443 return;
444
445 state = CBM_LOG_MUTEX_UNINIT;
446 if (atomic_compare_exchange_strong(&g_log_mutex_init, &state, CBM_LOG_MUTEX_INITING)) {
447 cbm_mutex_init(&g_log_mutex);
448 cbm_mutex_init(&g_ui_log_mutex);
449 atomic_store(&g_log_mutex_init, CBM_LOG_MUTEX_INITED);
450 return;
451 }
452
453 /* Another thread is initializing — spin until done */
454 while (atomic_load(&g_log_mutex_init) != CBM_LOG_MUTEX_INITED) {
455 cbm_usleep(1000); /* 1ms */
456 }
457}
458
459/* Called only under g_log_mutex. Cache-directory changes are used by isolated
460 * tests; production has one daemon-owned path for its lifetime. */

Callers 9

ui_log_append_recordFunction · 0.85
cbm_ui_log_closeFunction · 0.85
handle_logsFunction · 0.85
handle_agent_eventsFunction · 0.85
handle_ui_log_postFunction · 0.85
handle_ui_log_getFunction · 0.85
cbm_daemon_host_runFunction · 0.85

Calls 1

cbm_mutex_initFunction · 0.85

Tested by

no test coverage detected