mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-08-15 10:48:51 +02:00
Fixed read from closed channel
A premature waitgroup .Done resulted in reading from closed channel. This caused a nil-pointer deref & crash. Added additional debugging when closing routines.
This commit is contained in:
14
send.go
14
send.go
@ -320,13 +320,16 @@ func (device *Device) RoutineEncryption() {
|
||||
*/
|
||||
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())
|
||||
|
||||
defer func() {
|
||||
peer.routines.stopping.Done()
|
||||
logDebug.Println(peer.String(), ": Routine, Sequential sender, Stopped")
|
||||
}()
|
||||
|
||||
peer.routines.starting.Done()
|
||||
|
||||
for {
|
||||
@ -337,7 +340,12 @@ func (peer *Peer) RoutineSequentialSender() {
|
||||
"Routine, sequential sender, stopped for", peer.String())
|
||||
return
|
||||
|
||||
case elem := <-peer.queue.outbound:
|
||||
case elem, ok := <-peer.queue.outbound:
|
||||
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
elem.mutex.Lock()
|
||||
if elem.IsDropped() {
|
||||
continue
|
||||
|
Reference in New Issue
Block a user