Finer-grained start-stop synchronization

This commit is contained in:
Jason A. Donenfeld
2018-05-16 22:20:15 +02:00
parent 23eca94508
commit 846d721dfd
6 changed files with 33 additions and 5 deletions

View File

@@ -124,9 +124,11 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind Bind) {
logDebug := device.log.Debug
defer func() {
logDebug.Println("Routine: receive incoming IPv" + strconv.Itoa(IP) + " - stopped")
device.state.stopping.Done()
}()
logDebug.Println("Routine: receive incoming IPv" + strconv.Itoa(IP) + " - starting")
device.state.starting.Done()
// receive datagrams until conn is closed
@@ -257,6 +259,7 @@ func (device *Device) RoutineDecryption() {
device.state.stopping.Done()
}()
logDebug.Println("Routine: decryption worker - started")
device.state.starting.Done()
for {
select {
@@ -324,6 +327,7 @@ func (device *Device) RoutineHandshake() {
}()
logDebug.Println("Routine: handshake worker - started")
device.state.starting.Done()
var elem QueueHandshakeElement
var ok bool