diff options
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-18 16:01:44 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-18 16:05:40 +0200
commitf6f8ea6c1b8e7d8cfeb671bfc6fbad1e2cfa6c38 (patch)
parentchacha20poly1305: add mips32 implementation (diff)
timers: round up instead of down in slack_time
On systems with a 100hz tick, this causes handshakes to be retried in slightly less than 5 seconds, which means they aren't sent at all. This has the effect of the handshakes entirely stopping their retry cycle until the next data packet is sent. Reported-by: Andrew He <andrewhe@mit.edu>
1 files changed, 2 insertions, 2 deletions
diff --git a/src/timers.c b/src/timers.c
index 3fc34e4..dee556d 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -17,10 +17,10 @@
* Timer for, if enabled, sending an empty authenticated packet every user-specified seconds
-/* This rounds the time down to the closest power of two of the closest quarter second. */
+/* This rounds the time up to the closest power of two of the closest tenth second. */
static inline unsigned long slack_time(unsigned long time)
- return time & ~(roundup_pow_of_two(HZ / 4) - 1);
+ return time | roundup_pow_of_two(HZ / 10);
#define peer_get_from_timer(timer_name) \