summaryrefslogtreecommitdiffhomepage
path: root/src/timers.c
diff options
context:
space:
mode:
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
commitf1b46dfd88e02d3b39cd054e04c505d6a0b68e98 (patch)
tree32002e4d531e35dff647d4ef51cec80411211223 /src/timers.c
parentaf7b41d800418528fda52a4112d180396e6099ee (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> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/timers.c')
-rw-r--r--src/timers.c4
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) \