diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-07 20:59:20 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-07 20:59:20 +0100 |
commit | a1d244771e7528b9a1766e36d18950360983b8d9 (patch) | |
tree | 6123f8f2e90149925e323d90550f5a478b621e9d /src/timers.c | |
parent | 573fe64489ce2b08d4afce0901ba02ff505b5b98 (diff) |
send: simplify handshake initiation queueing and introduce lock
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/timers.c')
-rw-r--r-- | src/timers.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/timers.c b/src/timers.c index 3f176e3..8cc2104 100644 --- a/src/timers.c +++ b/src/timers.c @@ -37,11 +37,12 @@ static void expired_retransmit_handshake(unsigned long ptr) * of a partial exchange. */ if (likely(peer->timer_kill_ephemerals.data)) mod_timer(&peer->timer_kill_ephemerals, jiffies + (REJECT_AFTER_TIME * 3)); - peer_put(peer); - return; + goto out; } - packet_queue_send_handshake_initiation(peer); /* Takes our reference. */ + packet_queue_handshake_initiation(peer); ++peer->timer_handshake_attempts; +out: + peer_put(peer); } static void expired_send_keepalive(unsigned long ptr) @@ -59,7 +60,8 @@ static void expired_new_handshake(unsigned long ptr) { peer_get_from_ptr(ptr); pr_debug("Retrying handshake with peer %Lu (%pISpfsc) because we stopped hearing back after %d seconds\n", peer->internal_id, &peer->endpoint_addr, (KEEPALIVE_TIMEOUT + REKEY_TIMEOUT) / HZ); - packet_queue_send_handshake_initiation(peer); /* Takes our reference. */ + packet_queue_handshake_initiation(peer); + peer_put(peer); } static void expired_kill_ephemerals(unsigned long ptr) |