summaryrefslogtreecommitdiffhomepage
path: root/src/timers.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/timers.go')
-rw-r--r--src/timers.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/timers.go b/src/timers.go
index f2fed30..f1ed9c5 100644
--- a/src/timers.go
+++ b/src/timers.go
@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/binary"
"math/rand"
- "sync"
"sync/atomic"
"time"
)
@@ -182,7 +181,10 @@ func (peer *Peer) sendNewHandshake() error {
return err
}
-func (peer *Peer) RoutineTimerHandler(ready *sync.WaitGroup) {
+func (peer *Peer) RoutineTimerHandler() {
+
+ defer peer.routines.stopping.Done()
+
device := peer.device
logInfo := device.log.Info
@@ -203,15 +205,20 @@ func (peer *Peer) RoutineTimerHandler(ready *sync.WaitGroup) {
peer.timer.keepalivePersistent.Reset(duration)
}
- // signal that timers are reset
+ // signal synchronised setup complete
- ready.Done()
+ peer.routines.starting.Done()
// handle timer events
for {
select {
+ /* stopping */
+
+ case <-peer.routines.stop.Wait():
+ return
+
/* timers */
// keep-alive
@@ -312,9 +319,6 @@ func (peer *Peer) RoutineTimerHandler(ready *sync.WaitGroup) {
/* signals */
- case <-peer.signal.stop.Wait():
- return
-
case <-peer.signal.handshakeBegin.Wait():
peer.signal.handshakeBegin.Disable()