Ensure that we initialise the purgeability of peer structures when we allocate them

This commit is contained in:
Hamish Coleman 2023-09-06 13:32:36 +01:00
parent e9659e3b9a
commit 1a598fa43b
2 changed files with 3 additions and 0 deletions

View File

@ -683,6 +683,7 @@ static void register_with_new_peer (n2n_edge_t *eee,
scan->sock = *peer;
scan->timeout = eee->conf.register_interval; /* TODO: should correspond to the peer supernode registration timeout */
scan->last_valid_time_stamp = initial_time_stamp();
scan->purgeable = true;
if(via_multicast)
scan->local = 1;
@ -1903,6 +1904,7 @@ static int check_query_peer_info (n2n_edge_t *eee, time_t now, n2n_mac_t mac) {
scan->timeout = eee->conf.register_interval; /* TODO: should correspond to the peer supernode registration timeout */
scan->last_seen = now; /* Don't change this it marks the pending peer for removal. */
scan->last_valid_time_stamp = initial_time_stamp();
scan->purgeable = true;
HASH_ADD_PEER(eee->pending_peers, scan);
}

View File

@ -528,6 +528,7 @@ struct peer_info* add_sn_to_list_by_mac_or_sock (struct peer_info **sn_list, n2n
if(peer) {
sn_selection_criterion_default(&(peer->selection_criterion));
peer->last_valid_time_stamp = initial_time_stamp();
peer->purgeable = true;
memcpy(&(peer->sock), sock, sizeof(n2n_sock_t));
memcpy(peer->mac_addr, mac, sizeof(n2n_mac_t));
HASH_ADD_PEER(*sn_list, peer);