More robust solution to close deadlock

This commit is contained in:
Jason A. Donenfeld
2018-05-05 06:00:38 +02:00
parent 09a9bc2899
commit a46401bbb1
3 changed files with 33 additions and 31 deletions

12
send.go
View File

@@ -274,17 +274,7 @@ func (device *Device) RoutineEncryption() {
logDebug := device.log.Debug
defer func() {
for {
select {
case elem, ok := <-device.queue.encryption:
if ok {
elem.Drop()
}
default:
goto out
}
}
out:
device.state.stopping.Done()
logDebug.Println("Routine: encryption worker - stopped")
}()