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

Function cbm_daemon_client_connected

src/daemon/daemon.c:393–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391}
392
393cbm_daemon_client_id_t cbm_daemon_client_connected(cbm_daemon_coordinator_t *coordinator,
394 uint64_t now_ms) {
395 if (!coordinator) {
396 return CBM_DAEMON_CLIENT_ID_INVALID;
397 }
398
399 cbm_daemon_client_t *client = malloc(sizeof(*client));
400 if (!client) {
401 return CBM_DAEMON_CLIENT_ID_INVALID;
402 }
403
404 cbm_mutex_lock(&coordinator->mutex);
405 if (coordinator->state != CBM_DAEMON_COORDINATOR_RUNNING) {
406 cbm_mutex_unlock(&coordinator->mutex);
407 free(client);
408 return CBM_DAEMON_CLIENT_ID_INVALID;
409 }
410 cbm_daemon_client_id_t client_id = issue_client_id_locked(coordinator);
411 if (client_id == CBM_DAEMON_CLIENT_ID_INVALID) {
412 cbm_mutex_unlock(&coordinator->mutex);
413 free(client);
414 return CBM_DAEMON_CLIENT_ID_INVALID;
415 }
416 client->id = client_id;
417 client->last_heartbeat_ms = now_ms;
418 client->next = coordinator->clients;
419 coordinator->clients = client;
420 coordinator->client_count++;
421 cbm_mutex_unlock(&coordinator->mutex);
422 return client_id;
423}
424
425bool cbm_daemon_client_disconnected(cbm_daemon_coordinator_t *coordinator,
426 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