summaryrefslogtreecommitdiffstats
path: root/src/peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/peer.c b/src/peer.c
index ecb7e2c..e7574ef 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -25,6 +25,7 @@
#include "peer.h"
+#include "peer_hashtable.h"
#include "poll.h"
#include <arpa/inet.h>
@@ -272,6 +273,8 @@ static void delete_peer(fastd_context_t *ctx, fastd_peer_t *peer) {
}
}
+ fastd_peer_hashtable_remove(ctx, peer);
+
ctx->conf->protocol->free_peer_state(ctx, peer);
if (!peer->config)
@@ -392,6 +395,7 @@ static inline void reset_peer_address(fastd_context_t *ctx, fastd_peer_t *peer)
if (fastd_peer_is_established(peer))
fastd_peer_reset(ctx, peer);
+ fastd_peer_hashtable_remove(ctx, peer);
memset(&peer->address, 0, sizeof(fastd_peer_address_t));
}
@@ -455,7 +459,13 @@ bool fastd_peer_claim_address(fastd_context_t *ctx, fastd_peer_t *new_peer, fast
}
}
+ fastd_peer_hashtable_remove(ctx, new_peer);
+
new_peer->address = *remote_addr;
+
+ if (remote_addr->sa.sa_family != AF_UNSPEC)
+ fastd_peer_hashtable_insert(ctx, new_peer);
+
if (sock && sock->addr && sock != new_peer->sock) {
free_socket(ctx, new_peer);
new_peer->sock = sock;