From 6a178be29fcd28b2bdae5b5c59a11cda2e5109ba Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 24 Aug 2014 01:46:30 +0200 Subject: Instead of replacing changed peers, delete and re-add them This ensures they get a new ID, so asychronous replies for the old config aren't associated with the new one. --- src/peer.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/peer.c b/src/peer.c index c48b112..0cc4f2d 100644 --- a/src/peer.c +++ b/src/peer.c @@ -693,22 +693,6 @@ static inline bool peer_configs_equal(const fastd_peer_t *peer1, const fastd_pee return true; } -/** Replaces a peer with a new configuration */ -static void replace_peer(fastd_peer_t *old, fastd_peer_t *new) { - reset_peer(old); - - new->id = old->id; - - new->protocol_state = old->protocol_state; - old->protocol_state = NULL; - - fastd_peer_t tmp = *old; - *old = *new; - *new = tmp; - - fastd_peer_free(new); -} - /** Adds a new peer */ bool fastd_peer_add(fastd_peer_t *peer) { if (!peer->key) { @@ -744,17 +728,17 @@ bool fastd_peer_add(fastd_peer_t *peer) { return true; } + else { + pr_verbose("peer %P has changed", peer); + } - pr_verbose("peer %P has changed, resetting...", peer); - - replace_peer(other, peer); - return true; + fastd_peer_delete(other); + break; #ifdef WITH_DYNAMIC_PEERS case CONFIG_DYNAMIC: pr_verbose("dynamic peer %P is now configured as %P", other, peer); - replace_peer(other, peer); - return true; + fastd_peer_delete(other); #endif } } -- cgit v1.2.3