diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-01-26 06:00:04 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-01-26 06:00:04 +0100 |
commit | 26cf96bea0e07df934c807b78c2d77383556c1ce (patch) | |
tree | fffd28e2ea258df38422dcdfe169b9a4b3b27049 /src/fastd.c | |
parent | 76d955efa5fcd46fd325015d6cd3a389f8d9bb93 (diff) | |
download | fastd-26cf96bea0e07df934c807b78c2d77383556c1ce.tar fastd-26cf96bea0e07df934c807b78c2d77383556c1ce.zip |
Switch to the new timeout helpers where possible
Diffstat (limited to 'src/fastd.c')
-rw-r--r-- | src/fastd.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/fastd.c b/src/fastd.c index dadfe7b..532c8be 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -558,13 +558,13 @@ static inline int handshake_timeout(fastd_context_t *ctx) { if (!ctx->handshake_queue.next) return -1; - fastd_peer_t *peer = container_of(ctx->handshake_queue.next, fastd_peer_t, handshake_entry); + fastd_peer_t *peer = container_of(ctx->handshake_queue.next, fastd_peer_t, handshake_entry); - int diff_msec = timespec_diff(&peer->next_handshake, &ctx->now); - if (diff_msec < 0) - return 0; - else - return diff_msec; + int diff_msec = timespec_diff(&peer->next_handshake, &ctx->now); + if (diff_msec < 0) + return 0; + else + return diff_msec; } static void handle_input(fastd_context_t *ctx) { @@ -647,7 +647,7 @@ static void cleanup_peers(fastd_context_t *ctx) { next = peer->next; if (fastd_peer_is_temporary(peer) || fastd_peer_is_established(peer)) { - if (timespec_diff(&ctx->now, &peer->seen) > (int)ctx->conf->peer_stale_time*1000) { + if (fastd_timed_out(ctx, &peer->timeout)) { if (fastd_peer_is_temporary(peer)) { fastd_peer_delete(ctx, peer); } @@ -678,7 +678,7 @@ static void maintenance(fastd_context_t *ctx) { if (!fastd_peer_is_established(peer)) continue; - if (timespec_diff(&ctx->now, &peer->last_send) < (int)ctx->conf->keepalive_timeout*1000) + if (!fastd_timed_out(ctx, &peer->keepalive_timeout)) continue; pr_debug2(ctx, "sending keepalive to %P", peer); @@ -915,8 +915,7 @@ int main(int argc, char *argv[]) { update_time(&ctx); - ctx.next_keepalives = ctx.now; - ctx.next_keepalives.tv_sec += conf.keepalive_interval; + ctx.next_keepalives = fastd_in_seconds(&ctx, conf.keepalive_interval); ctx.unknown_handshakes[0].timeout = ctx.now; |