Work on timer teardown + bug fixes
Added waitgroups to peer struct for routine start / stop synchronisation
This commit is contained in:
parent
d73f960aab
commit
1dd590b91b
8 changed files with 102 additions and 47 deletions
11
src/send.go
11
src/send.go
|
|
@ -192,7 +192,7 @@ func (peer *Peer) RoutineNonce() {
|
|||
for {
|
||||
NextPacket:
|
||||
select {
|
||||
case <-peer.signal.stop.Wait():
|
||||
case <-peer.routines.stop.Wait():
|
||||
return
|
||||
|
||||
case elem := <-peer.queue.nonce:
|
||||
|
|
@ -217,7 +217,7 @@ func (peer *Peer) RoutineNonce() {
|
|||
logDebug.Println("Clearing queue for", peer.String())
|
||||
peer.FlushNonceQueue()
|
||||
goto NextPacket
|
||||
case <-peer.signal.stop.Wait():
|
||||
case <-peer.routines.stop.Wait():
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
@ -309,15 +309,20 @@ func (device *Device) RoutineEncryption() {
|
|||
* The routine terminates then the outbound queue is closed.
|
||||
*/
|
||||
func (peer *Peer) RoutineSequentialSender() {
|
||||
|
||||
defer peer.routines.stopping.Done()
|
||||
|
||||
device := peer.device
|
||||
|
||||
logDebug := device.log.Debug
|
||||
logDebug.Println("Routine, sequential sender, started for", peer.String())
|
||||
|
||||
peer.routines.starting.Done()
|
||||
|
||||
for {
|
||||
select {
|
||||
|
||||
case <-peer.signal.stop.Wait():
|
||||
case <-peer.routines.stop.Wait():
|
||||
logDebug.Println(
|
||||
"Routine, sequential sender, stopped for", peer.String())
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue