close(device.signals.stop)
+ device.RemoveAllPeers()
+
device.state.stopping.Wait()
device.FlushPacketQueues()
- device.RemoveAllPeers()
device.rate.limiter.Close()
device.state.changing.Set(false)
// check if dropped
if elem.IsDropped() {
- device.PutInboundElement(elem)
continue
}
if err != nil {
elem.Drop()
device.PutMessageBuffer(elem.buffer)
- elem.buffer = nil
}
elem.mutex.Unlock()
}
for {
if elem.buffer != nil {
device.PutMessageBuffer(elem.buffer)
+ elem.buffer = nil
}
select {
logDebug.Println(peer, "- Routine: sequential receiver - stopped")
peer.routines.stopping.Done()
if elem != nil {
- if elem.buffer != nil {
+ if !elem.IsDropped() {
device.PutMessageBuffer(elem.buffer)
}
device.PutInboundElement(elem)
for {
if elem != nil {
- if elem.buffer != nil {
+ if !elem.IsDropped() {
device.PutMessageBuffer(elem.buffer)
}
device.PutInboundElement(elem)
+ elem = nil
}
select {
device := peer.device
logDebug := device.log.Debug
- defer func() {
- logDebug.Println(peer, "- Routine: nonce worker - stopped")
- peer.queue.packetInNonceQueueIsAwaitingKey.Set(false)
- peer.routines.stopping.Done()
- }()
-
flush := func() {
for {
select {
}
}
+ defer func() {
+ flush()
+ logDebug.Println(peer, "- Routine: nonce worker - stopped")
+ peer.queue.packetInNonceQueueIsAwaitingKey.Set(false)
+ peer.routines.stopping.Done()
+ }()
+
peer.routines.starting.Done()
logDebug.Println(peer, "- Routine: nonce worker - started")
logDebug := device.log.Debug
defer func() {
+ for {
+ select {
+ case elem, ok := <-device.queue.encryption:
+ if ok && !elem.IsDropped() {
+ elem.Drop()
+ device.PutMessageBuffer(elem.buffer)
+ elem.mutex.Unlock()
+ }
+ default:
+ goto out
+ }
+ }
+ out:
logDebug.Println("Routine: encryption worker - stopped")
device.state.stopping.Done()
}()
// check if dropped
if elem.IsDropped() {
- device.PutOutboundElement(elem)
continue
}
logError := device.log.Error
defer func() {
+ for {
+ select {
+ case elem, ok := <-peer.queue.outbound:
+ if ok {
+ if !elem.IsDropped() {
+ device.PutMessageBuffer(elem.buffer)
+ elem.Drop()
+ }
+ device.PutOutboundElement(elem)
+ elem.mutex.Unlock()
+ }
+ default:
+ goto out
+ }
+ }
+ out:
logDebug.Println(peer, "- Routine: sequential sender - stopped")
peer.routines.stopping.Done()
}()