diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2018-04-18 20:29:48 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2018-04-18 20:29:48 +0200 |
commit | ac9912345b4da5034ea93f5f245ea2ce04815bd5 (patch) | |
tree | b371c03e54c7d1ee2c882fdf596b011a936d2ad7 /receive.go | |
parent | 26a56a652eeeece7677ba4f1896da34c83930652 (diff) |
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.
Diffstat (limited to 'receive.go')
-rw-r--r-- | receive.go | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -500,8 +500,8 @@ func (peer *Peer) RoutineSequentialReceiver() { logError := device.log.Error logDebug := device.log.Debug - func() { - defer peer.routines.stopping.Done() + defer func() { + peer.routines.stopping.Done() logDebug.Println(peer.String(), ": Routine, Sequential Receiver, Stopped") }() @@ -516,7 +516,11 @@ func (peer *Peer) RoutineSequentialReceiver() { case <-peer.routines.stop.Wait(): return - case elem := <-peer.queue.inbound: + case elem, ok := <-peer.queue.inbound: + + if !ok { + return + } // wait for decryption |