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

Function runtime_connection_worker

src/daemon/runtime.c:1711–1943  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1709}
1710
1711static void *runtime_connection_worker(void *opaque) {
1712 cbm_daemon_runtime_worker_t *worker = opaque;
1713 cbm_daemon_runtime_service_t *service = worker->service;
1714 cbm_daemon_frame_t frame = {0};
1715 uint8_t *payload = NULL;
1716 char requested_version[CBM_DAEMON_VERSION_TEXT_SIZE];
1717 char requested_build[CBM_DAEMON_BUILD_FINGERPRINT_SIZE];
1718
1719 int received = cbm_daemon_ipc_receive_frame_bounded(
1720 worker->connection, service->request_timeout_ms,
1721 CBM_DAEMON_ACTIVATION_SHUTDOWN_REQUEST_SIZE, &frame, &payload);
1722 if (received != 1 || frame.type != CBM_DAEMON_FRAME_REQUEST) {
1723 free(payload);
1724 runtime_worker_finish(worker);
1725 return NULL;
1726 }
1727 if (frame.flags == CBM_DAEMON_RUNTIME_OP_ACTIVATION_SHUTDOWN) {
1728 runtime_worker_handle_activation_shutdown(worker, payload, frame.length);
1729 free(payload);
1730 return NULL;
1731 }
1732 if (frame.flags == CBM_DAEMON_RUNTIME_OP_STATUS) {
1733 runtime_worker_handle_status(worker, payload, frame.length);
1734 free(payload);
1735 return NULL;
1736 }
1737 if (frame.flags == CBM_DAEMON_RUNTIME_OP_STOP) {
1738 runtime_worker_handle_stop(worker, payload, frame.length);
1739 free(payload);
1740 return NULL;
1741 }
1742 if (frame.flags != CBM_DAEMON_RUNTIME_OP_HELLO ||
1743 frame.length != CBM_DAEMON_RENDEZVOUS_REQUEST_SIZE ||
1744 !runtime_rendezvous_request_decode(payload, requested_version, requested_build)) {
1745 free(payload);
1746 runtime_worker_finish(worker);
1747 return NULL;
1748 }
1749 free(payload);
1750 payload = NULL;
1751
1752 cbm_daemon_runtime_connect_result_t hello_result;
1753 memset(&hello_result, 0, sizeof(hello_result));
1754 cbm_daemon_hello_status_t hello_status = runtime_rendezvous_compare(
1755 service->identity.semantic_version, service->identity.build_fingerprint, requested_version,
1756 requested_build, &hello_result.conflict);
1757 if (hello_status != CBM_DAEMON_HELLO_COMPATIBLE) {
1758 if (hello_status == CBM_DAEMON_HELLO_INVALID) {
1759 runtime_worker_finish(worker);
1760 return NULL;
1761 }
1762 hello_result.status = CBM_DAEMON_RUNTIME_CONNECT_CONFLICT;
1763 hello_result.hello_status = hello_status;
1764 (void)cbm_daemon_conflict_format(&hello_result.conflict, hello_result.message,
1765 sizeof(hello_result.message));
1766 if (!cbm_daemon_conflict_log_append(service->conflict_log_path, &hello_result.conflict,
1767 service->conflict_log_cap_bytes)) {
1768 /* This goes through the daemon operation-log sink, never back

Callers

nothing calls this directly

Tested by

no test coverage detected