summaryrefslogtreecommitdiffhomepage
path: root/timers.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2018-02-11 23:26:54 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2018-02-11 23:26:54 +0100
commit6cba91999c8b43dc979e707f7bbbaabf786f68bd (patch)
treec79cff69af5c64859b51cc83f9f05196b922e449 /timers.go
parent04ded4c63183927feba565a43fafc987dba32005 (diff)
TUN status hack was causing spam during shutdown
Diffstat (limited to 'timers.go')
-rw-r--r--timers.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/timers.go b/timers.go
index 1240c21..76dffb9 100644
--- a/timers.go
+++ b/timers.go
@@ -36,7 +36,7 @@ func (peer *Peer) KeepKeyFreshSending() {
* NOTE: Not thread safe, but called by sequential receiver!
*/
func (peer *Peer) KeepKeyFreshReceiving() {
- if peer.timer.sendLastMinuteHandshake {
+ if peer.timer.sendLastMinuteHandshake.Get() {
return
}
kp := peer.keyPairs.Current()
@@ -50,7 +50,7 @@ func (peer *Peer) KeepKeyFreshReceiving() {
send := nonce > RekeyAfterMessages || time.Now().Sub(kp.created) > RekeyAfterTimeReceiving
if send {
// do a last minute attempt at initiating a new handshake
- peer.timer.sendLastMinuteHandshake = true
+ peer.timer.sendLastMinuteHandshake.Set(true)
peer.signal.handshakeBegin.Send()
}
}
@@ -87,7 +87,7 @@ func (peer *Peer) TimerDataSent() {
*/
func (peer *Peer) TimerDataReceived() {
if !peer.timer.keepalivePassive.Start(KeepaliveTimeout) {
- peer.timer.needAnotherKeepalive = true
+ peer.timer.needAnotherKeepalive.Set(true)
}
}
@@ -238,8 +238,7 @@ func (peer *Peer) RoutineTimerHandler() {
peer.SendKeepAlive()
- if peer.timer.needAnotherKeepalive {
- peer.timer.needAnotherKeepalive = false
+ if peer.timer.needAnotherKeepalive.Swap(false) {
peer.timer.keepalivePassive.Reset(KeepaliveTimeout)
}
@@ -342,7 +341,7 @@ func (peer *Peer) RoutineTimerHandler() {
peer.timer.handshakeDeadline.Stop()
peer.signal.handshakeBegin.Enable()
- peer.timer.sendLastMinuteHandshake = false
+ peer.timer.sendLastMinuteHandshake.Set(false)
}
}
}