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

Function win_endpoint_generation_install

src/daemon/ipc.c:4549–4584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4547}
4548
4549static bool win_endpoint_generation_install(const cbm_daemon_ipc_endpoint_t *endpoint,
4550 const char *address) {
4551 if (!endpoint || !windows_pipe_address_valid(address)) {
4552 return false;
4553 }
4554 win_generation_address_t *snapshot = win_endpoint_generation_snapshot(endpoint);
4555 if (snapshot && strcmp(snapshot->address, address) == 0) {
4556 return true;
4557 }
4558 win_generation_address_t *candidate = calloc(1, sizeof(*candidate));
4559 if (candidate) {
4560 (void)memcpy(candidate->address, address, strlen(address) + 1U);
4561 candidate->pipe_name = utf8_to_wide(address);
4562 }
4563 if (!candidate || !candidate->pipe_name) {
4564 free(candidate ? candidate->pipe_name : NULL);
4565 free(candidate);
4566 return false;
4567 }
4568
4569 cbm_daemon_ipc_endpoint_t *mutable_endpoint = (cbm_daemon_ipc_endpoint_t *)endpoint;
4570 cbm_mutex_lock(&mutable_endpoint->generations_lock);
4571 win_generation_address_t *current =
4572 atomic_load_explicit(&mutable_endpoint->current_generation, memory_order_acquire);
4573 if (current && strcmp(current->address, address) == 0) {
4574 cbm_mutex_unlock(&mutable_endpoint->generations_lock);
4575 free(candidate->pipe_name);
4576 free(candidate);
4577 return true;
4578 }
4579 candidate->next = mutable_endpoint->generations;
4580 mutable_endpoint->generations = candidate;
4581 atomic_store_explicit(&mutable_endpoint->current_generation, candidate, memory_order_release);
4582 cbm_mutex_unlock(&mutable_endpoint->generations_lock);
4583 return true;
4584}
4585
4586static win_rendezvous_status_t win_endpoint_refresh_rendezvous(
4587 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