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

Function cbm_daemon_client_connected

src/daemon/daemon.c:415–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

413}
414
415cbm_daemon_client_id_t cbm_daemon_client_connected(cbm_daemon_coordinator_t *coordinator,
416 uint64_t now_ms) {
417 if (!coordinator) {
418 return CBM_DAEMON_CLIENT_ID_INVALID;
419 }
420
421 cbm_daemon_client_t *client = malloc(sizeof(*client));
422 if (!client) {
423 return CBM_DAEMON_CLIENT_ID_INVALID;
424 }
425
426 cbm_mutex_lock(&coordinator->mutex);
427 if (coordinator->state != CBM_DAEMON_COORDINATOR_RUNNING) {
428 cbm_mutex_unlock(&coordinator->mutex);
429 free(client);
430 return CBM_DAEMON_CLIENT_ID_INVALID;
431 }
432 cbm_daemon_client_id_t client_id = issue_client_id_locked(coordinator);
433 if (client_id == CBM_DAEMON_CLIENT_ID_INVALID) {
434 cbm_mutex_unlock(&coordinator->mutex);
435 free(client);
436 return CBM_DAEMON_CLIENT_ID_INVALID;
437 }
438 client->id = client_id;
439 client->last_heartbeat_ms = now_ms;
440 client->next = coordinator->clients;
441 coordinator->clients = client;
442 coordinator->client_count++;
443 cbm_mutex_unlock(&coordinator->mutex);
444 return client_id;
445}
446
447bool cbm_daemon_client_disconnected(cbm_daemon_coordinator_t *coordinator,
448 cbm_daemon_client_id_t client_id, uint64_t now_ms) {

Callers 2

runtime_worker_admitFunction · 0.85
test_daemon.cFile · 0.85

Calls 3

cbm_mutex_lockFunction · 0.85
cbm_mutex_unlockFunction · 0.85
issue_client_id_lockedFunction · 0.85

Tested by

no test coverage detected