summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-11-17 01:27:47 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-11-17 01:27:47 +0100
commit5082b5a4d2ec52b90e6d7ed178e462a6f0ff6f3e (patch)
treeb3a4e5197bde749bcb7f3dd5354743854325847e /src/fastd.h
parentcca293a6d474b2bd02a5fbfb1f2fae6179c395d6 (diff)
downloadfastd-5082b5a4d2ec52b90e6d7ed178e462a6f0ff6f3e.tar
fastd-5082b5a4d2ec52b90e6d7ed178e462a6f0ff6f3e.zip
Use task queue for peer resets and keepalives
This makes it unnecessary to iterate over all peers for maintenance, and desynchronizes different peers' keepalives.
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/fastd.h b/src/fastd.h
index 9d44b21..bc5433c 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -533,6 +533,17 @@ static inline bool fastd_timed_out(fastd_timeout_t timeout) {
return timeout <= ctx.now;
}
+/** Returns the minimum of two fastd_timeout_t values */
+static inline fastd_timeout_t fastd_timeout_min(fastd_timeout_t a, fastd_timeout_t b) {
+ return (a < b) ? a : b;
+}
+
+/** Updates a timeout, ensuring it can only increase */
+static inline void fastd_timeout_advance(fastd_timeout_t *a, fastd_timeout_t v) {
+ if (*a < v)
+ *a = v;
+}
+
/** Updates the current time */
static inline void fastd_update_time(void) {
struct timespec ts;