summaryrefslogtreecommitdiffstats
path: root/src/peer.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-11-02 08:56:54 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-11-02 08:56:54 +0100
commit74b73a980b91799843f8004edd90387ac482af46 (patch)
tree837a5eadf2ab3316168f5ebf4cca954b232034cb /src/peer.c
parentcb98cbc593309d4781dfb873b018a5d4e12ad118 (diff)
downloadfastd-74b73a980b91799843f8004edd90387ac482af46.tar
fastd-74b73a980b91799843f8004edd90387ac482af46.zip
Keep track of corresonding peers in associated sockets
Diffstat (limited to 'src/peer.c')
-rw-r--r--src/peer.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/peer.c b/src/peer.c
index 9513703..cb7626f 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -149,6 +149,9 @@ static void on_disestablish(fastd_context *ctx, fastd_peer *peer) {
static inline void free_socket(fastd_context *ctx, fastd_peer *peer) {
if (peer->sock) {
if (fastd_peer_is_socket_dynamic(peer)) {
+ if (peer->sock->peer != peer)
+ exit_bug(ctx, "dynamic peer socket mismatch");
+
fastd_socket_close(ctx, peer->sock);
free(peer->sock);
}
@@ -169,14 +172,14 @@ void fastd_peer_reset_socket(fastd_context *ctx, fastd_peer *peer) {
if (ctx->sock_default_v4)
peer->sock = ctx->sock_default_v4;
else
- peer->sock = fastd_socket_open(ctx, AF_INET);
+ peer->sock = fastd_socket_open(ctx, peer, AF_INET);
break;
case AF_INET6:
if (ctx->sock_default_v6)
peer->sock = ctx->sock_default_v6;
else
- peer->sock = fastd_socket_open(ctx, AF_INET6);
+ peer->sock = fastd_socket_open(ctx, peer, AF_INET6);
}
}