From fcc5bcad1add369b7b9e0a25cc63b88dfb83e5fe Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 25 Jul 2013 13:49:01 +0200 Subject: Improve handling of similar remote resolves --- src/peer.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/peer.h') diff --git a/src/peer.h b/src/peer.h index 1b6303e..7d85c39 100644 --- a/src/peer.h +++ b/src/peer.h @@ -82,6 +82,8 @@ struct fastd_peer_eth_addr { struct fastd_remote { fastd_remote_t *next; + unsigned ref; + fastd_remote_config_t *config; fastd_peer_address_t address; struct timespec last_resolve; @@ -143,7 +145,7 @@ static inline bool fastd_peer_config_is_floating(const fastd_peer_config_t *conf return (!config->remotes || config->floating); } -bool fastd_peer_remote_matches_dynamic(const fastd_remote_config_t *remote, const fastd_peer_address_t *addr); +bool fastd_remote_matches_dynamic(const fastd_remote_config_t *remote, const fastd_peer_address_t *addr); static inline bool fastd_peer_is_floating(const fastd_peer_t *peer) { return peer->config ? fastd_peer_config_is_floating(peer->config) : true; @@ -163,7 +165,16 @@ static inline bool fastd_peer_is_established(const fastd_peer_t *peer) { } } -static inline bool fastd_peer_remote_is_dynamic(const fastd_remote_t *remote) { +static inline void fastd_remote_ref(fastd_remote_t *remote) { + remote->ref++; +} + +static inline void fastd_remote_unref(fastd_remote_t *remote) { + if(!--remote->ref) + free(remote); +} + +static inline bool fastd_remote_is_dynamic(const fastd_remote_t *remote) { return remote->config->hostname; } -- cgit v1.2.3