summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-08-24 01:46:30 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-08-24 01:46:30 +0200
commit6a178be29fcd28b2bdae5b5c59a11cda2e5109ba (patch)
tree1d54198f143a334377919e524a2d1bb5cadbb7a5 /src
parentb54d87d26f787a15d1991c6b6c03dfc915922ba6 (diff)
downloadfastd-6a178be29fcd28b2bdae5b5c59a11cda2e5109ba.tar
fastd-6a178be29fcd28b2bdae5b5c59a11cda2e5109ba.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/peer.c28
1 files changed, 6 insertions, 22 deletions
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
}
}