| 4616 | } |
| 4617 | |
| 4618 | static bool win_endpoint_generation_install(const cbm_daemon_ipc_endpoint_t *endpoint, |
| 4619 | const char *address) { |
| 4620 | if (!endpoint || !windows_pipe_address_valid(address)) { |
| 4621 | return false; |
| 4622 | } |
| 4623 | win_generation_address_t *snapshot = win_endpoint_generation_snapshot(endpoint); |
| 4624 | if (snapshot && strcmp(snapshot->address, address) == 0) { |
| 4625 | return true; |
| 4626 | } |
| 4627 | win_generation_address_t *candidate = calloc(1, sizeof(*candidate)); |
| 4628 | if (candidate) { |
| 4629 | (void)memcpy(candidate->address, address, strlen(address) + 1U); |
| 4630 | candidate->pipe_name = utf8_to_wide(address); |
| 4631 | } |
| 4632 | if (!candidate || !candidate->pipe_name) { |
| 4633 | free(candidate ? candidate->pipe_name : NULL); |
| 4634 | free(candidate); |
| 4635 | return false; |
| 4636 | } |
| 4637 | |
| 4638 | cbm_daemon_ipc_endpoint_t *mutable_endpoint = (cbm_daemon_ipc_endpoint_t *)endpoint; |
| 4639 | cbm_mutex_lock(&mutable_endpoint->generations_lock); |
| 4640 | win_generation_address_t *current = |
| 4641 | atomic_load_explicit(&mutable_endpoint->current_generation, memory_order_acquire); |
| 4642 | if (current && strcmp(current->address, address) == 0) { |
| 4643 | cbm_mutex_unlock(&mutable_endpoint->generations_lock); |
| 4644 | free(candidate->pipe_name); |
| 4645 | free(candidate); |
| 4646 | return true; |
| 4647 | } |
| 4648 | candidate->next = mutable_endpoint->generations; |
| 4649 | mutable_endpoint->generations = candidate; |
| 4650 | atomic_store_explicit(&mutable_endpoint->current_generation, candidate, memory_order_release); |
| 4651 | cbm_mutex_unlock(&mutable_endpoint->generations_lock); |
| 4652 | return true; |
| 4653 | } |
| 4654 | |
| 4655 | static win_rendezvous_status_t win_endpoint_refresh_rendezvous( |
| 4656 | const cbm_daemon_ipc_endpoint_t *endpoint) { |
no test coverage detected