summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-12-16 19:27:07 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-12-16 19:27:07 +0100
commit4475652054616ded16485341b081abf42cc6c08e (patch)
tree30b3f62bd4107766630e486cf67b8fcf117f9cd8 /src
parentc91f3ac6acf933a8dd89cca33081cfd4dfeabadc (diff)
downloadfastd-4475652054616ded16485341b081abf42cc6c08e.tar
fastd-4475652054616ded16485341b081abf42cc6c08e.zip
resolve: save a timestamp in the resolve return to ensure we don't confuse remotes before and after reconfiguration
Diffstat (limited to 'src')
-rw-r--r--src/fastd.c2
-rw-r--r--src/fastd.h5
-rw-r--r--src/resolve.c5
3 files changed, 10 insertions, 2 deletions
diff --git a/src/fastd.c b/src/fastd.c
index a9cb0c4..31bb90a 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -516,7 +516,7 @@ static void handle_resolve_returns(fastd_context_t *ctx) {
fastd_remote_t *remote;
for (remote = peer->remotes; remote; remote = remote->next) {
- if (remote == resolve_return.remote)
+ if (remote == resolve_return.remote && timespec_equal(&remote->last_resolve, &resolve_return.resolve_time))
break;
}
diff --git a/src/fastd.h b/src/fastd.h
index b170bb5..30e4bc4 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -80,6 +80,7 @@ union fastd_peer_address {
struct fastd_resolve_return {
fastd_remote_t *remote;
+ struct timespec resolve_time;
fastd_peer_address_t addr;
};
@@ -394,6 +395,10 @@ static inline bool timespec_after(const struct timespec *tp1, const struct times
(tp1->tv_sec == tp2->tv_sec && tp1->tv_nsec > tp2->tv_nsec));
}
+static inline bool timespec_equal(const struct timespec *tp1, const struct timespec *tp2) {
+ return (tp1->tv_sec == tp2->tv_sec && tp1->tv_nsec == tp2->tv_nsec);
+}
+
/* returns (tp1 - tp2) in milliseconds */
static inline int timespec_diff(const struct timespec *tp1, const struct timespec *tp2) {
return ((tp1->tv_sec - tp2->tv_sec))*1000 + (tp1->tv_nsec - tp2->tv_nsec)/1e6;
diff --git a/src/resolve.c b/src/resolve.c
index 9631c48..8dcdb2d 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -34,6 +34,7 @@
typedef struct resolv_arg {
fastd_context_t *ctx;
fastd_remote_t *remote;
+ struct timespec resolve_time;
char *hostname;
fastd_peer_address_t constraints;
} resolv_arg_t;
@@ -71,7 +72,8 @@ static void* resolve_peer(void *varg) {
}
fastd_resolve_return_t ret = {
- .remote = arg->remote
+ .remote = arg->remote,
+ .resolve_time = arg->resolve_time,
};
if (!error) {
@@ -113,6 +115,7 @@ void fastd_resolve_peer(fastd_context_t *ctx, fastd_peer_t *peer, fastd_remote_t
arg->ctx = ctx;
arg->remote = remote;
+ arg->resolve_time = ctx->now;
arg->hostname = strdup(remote->config->hostname);
arg->constraints = remote->config->address;