summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-05-17 11:55:22 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-05-17 11:55:22 +0200
commitf863ed2c2d9000d95aad7f2a0a27212acf86c692 (patch)
tree8ab7fdc047f13f36566d35d0be50f943eaf8374d
parente9536fe57e7857d100574164ff189684855942b0 (diff)
downloadfastd-f863ed2c2d9000d95aad7f2a0a27212acf86c692.tar
fastd-f863ed2c2d9000d95aad7f2a0a27212acf86c692.zip
Fix handling of unsuccessful resolve
-rw-r--r--src/peer.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/peer.c b/src/peer.c
index 3118ffc..a1fb774 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -269,21 +269,23 @@ bool fastd_peer_address_equal(const fastd_peer_address *addr1, const fastd_peer_
}
bool fastd_peer_claim_address(fastd_context *ctx, fastd_peer *new_peer, const fastd_peer_address *addr) {
- fastd_peer *peer;
- for (peer = ctx->peers; peer; peer = peer->next) {
- if (fastd_peer_address_equal(&peer->address, addr)) {
- if (peer == new_peer)
- break;
-
- if (fastd_peer_is_floating(peer) || fastd_peer_is_dynamic(peer)) {
- if (fastd_peer_is_established(peer))
- fastd_peer_reset(ctx, peer);
-
- memset(&peer->address, 0, sizeof(fastd_peer_address));
- break;
- }
- else {
- return false;
+ if (addr->sa.sa_family != AF_UNSPEC) {
+ fastd_peer *peer;
+ for (peer = ctx->peers; peer; peer = peer->next) {
+ if (fastd_peer_address_equal(&peer->address, addr)) {
+ if (peer == new_peer)
+ break;
+
+ if (fastd_peer_is_floating(peer) || fastd_peer_is_dynamic(peer)) {
+ if (fastd_peer_is_established(peer))
+ fastd_peer_reset(ctx, peer);
+
+ memset(&peer->address, 0, sizeof(fastd_peer_address));
+ break;
+ }
+ else {
+ return false;
+ }
}
}
}