summaryrefslogtreecommitdiffhomepage
path: root/src/timers.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-08-04 21:12:26 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-08-05 14:47:59 +0200
commita2e40a5e2886955add016c45cff948bebbd712dc (patch)
treecd763701d9cf6723f131f128cf0f1d9064929893 /src/timers.c
parent56c62a67e844458fdb7543702481aceb58056594 (diff)
timers: do not send out double keepalive
It's possible that a persistent keepalive that comes before a normal keepalive will not invalidate the normal keepalive, and then we'll needlessly send two keepalives. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/timers.c')
-rw-r--r--src/timers.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/timers.c b/src/timers.c
index d515265..ca34e7d 100644
--- a/src/timers.c
+++ b/src/timers.c
@@ -90,8 +90,11 @@ static void queued_expired_zero_key_material(struct work_struct *work)
static void expired_send_persistent_keepalive(unsigned long ptr)
{
peer_get_from_ptr(ptr);
- if (likely(peer->persistent_keepalive_interval))
+ if (likely(peer->persistent_keepalive_interval)) {
+ if (likely(peer->timers_enabled))
+ del_timer(&peer->timer_send_keepalive);
packet_send_keepalive(peer);
+ }
peer_put(peer);
}