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

Function runtime_connection_worker

src/daemon/runtime.c:1672–1884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1670}
1671
1672static void *runtime_connection_worker(void *opaque) {
1673 cbm_daemon_runtime_worker_t *worker = opaque;
1674 cbm_daemon_runtime_service_t *service = worker->service;
1675 cbm_daemon_frame_t frame = {0};
1676 uint8_t *payload = NULL;
1677 char requested_version[CBM_DAEMON_VERSION_TEXT_SIZE];
1678 char requested_build[CBM_DAEMON_BUILD_FINGERPRINT_SIZE];
1679
1680 int received = cbm_daemon_ipc_receive_frame_bounded(
1681 worker->connection, service->request_timeout_ms,
1682 CBM_DAEMON_ACTIVATION_SHUTDOWN_REQUEST_SIZE, &frame, &payload);
1683 if (received != 1 || frame.type != CBM_DAEMON_FRAME_REQUEST) {
1684 free(payload);
1685 runtime_worker_finish(worker);
1686 return NULL;
1687 }
1688 if (frame.flags == CBM_DAEMON_RUNTIME_OP_ACTIVATION_SHUTDOWN) {
1689 runtime_worker_handle_activation_shutdown(worker, payload, frame.length);
1690 free(payload);
1691 return NULL;
1692 }
1693 if (frame.flags == CBM_DAEMON_RUNTIME_OP_STATUS) {
1694 runtime_worker_handle_status(worker, payload, frame.length);
1695 free(payload);
1696 return NULL;
1697 }
1698 if (frame.flags == CBM_DAEMON_RUNTIME_OP_STOP) {
1699 runtime_worker_handle_stop(worker, payload, frame.length);
1700 free(payload);
1701 return NULL;
1702 }
1703 if (frame.flags != CBM_DAEMON_RUNTIME_OP_HELLO ||
1704 frame.length != CBM_DAEMON_RENDEZVOUS_REQUEST_SIZE ||
1705 !runtime_rendezvous_request_decode(payload, requested_version, requested_build)) {
1706 free(payload);
1707 runtime_worker_finish(worker);
1708 return NULL;
1709 }
1710 free(payload);
1711 payload = NULL;
1712
1713 cbm_daemon_runtime_connect_result_t hello_result;
1714 memset(&hello_result, 0, sizeof(hello_result));
1715 cbm_daemon_hello_status_t hello_status = runtime_rendezvous_compare(
1716 service->identity.semantic_version, service->identity.build_fingerprint, requested_version,
1717 requested_build, &hello_result.conflict);
1718 if (hello_status != CBM_DAEMON_HELLO_COMPATIBLE) {
1719 if (hello_status == CBM_DAEMON_HELLO_INVALID) {
1720 runtime_worker_finish(worker);
1721 return NULL;
1722 }
1723 hello_result.status = CBM_DAEMON_RUNTIME_CONNECT_CONFLICT;
1724 hello_result.hello_status = hello_status;
1725 (void)cbm_daemon_conflict_format(&hello_result.conflict, hello_result.message,
1726 sizeof(hello_result.message));
1727 if (!cbm_daemon_conflict_log_append(service->conflict_log_path, &hello_result.conflict,
1728 service->conflict_log_cap_bytes)) {
1729 /* This goes through the daemon operation-log sink, never back

Callers

nothing calls this directly

Tested by

no test coverage detected