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

Function win_endpoint_generation_install

src/daemon/ipc.c:5727–5762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5725}
5726
5727static bool win_endpoint_generation_install(const cbm_daemon_ipc_endpoint_t *endpoint,
5728 const char *address) {
5729 if (!endpoint || !windows_pipe_address_valid(address)) {
5730 return false;
5731 }
5732 win_generation_address_t *snapshot = win_endpoint_generation_snapshot(endpoint);
5733 if (snapshot && strcmp(snapshot->address, address) == 0) {
5734 return true;
5735 }
5736 win_generation_address_t *candidate = calloc(1, sizeof(*candidate));
5737 if (candidate) {
5738 (void)memcpy(candidate->address, address, strlen(address) + 1U);
5739 candidate->pipe_name = utf8_to_wide(address);
5740 }
5741 if (!candidate || !candidate->pipe_name) {
5742 free(candidate ? candidate->pipe_name : NULL);
5743 free(candidate);
5744 return false;
5745 }
5746
5747 cbm_daemon_ipc_endpoint_t *mutable_endpoint = (cbm_daemon_ipc_endpoint_t *)endpoint;
5748 cbm_mutex_lock(&mutable_endpoint->generations_lock);
5749 win_generation_address_t *current =
5750 atomic_load_explicit(&mutable_endpoint->current_generation, memory_order_acquire);
5751 if (current && strcmp(current->address, address) == 0) {
5752 cbm_mutex_unlock(&mutable_endpoint->generations_lock);
5753 free(candidate->pipe_name);
5754 free(candidate);
5755 return true;
5756 }
5757 candidate->next = mutable_endpoint->generations;
5758 mutable_endpoint->generations = candidate;
5759 atomic_store_explicit(&mutable_endpoint->current_generation, candidate, memory_order_release);
5760 cbm_mutex_unlock(&mutable_endpoint->generations_lock);
5761 return true;
5762}
5763
5764static win_rendezvous_status_t win_endpoint_refresh_rendezvous(
5765 const cbm_daemon_ipc_endpoint_t *endpoint) {

Calls 5

utf8_to_wideFunction · 0.85
cbm_mutex_lockFunction · 0.85
cbm_mutex_unlockFunction · 0.85

Tested by

no test coverage detected