summaryrefslogtreecommitdiffhomepage
path: root/device/receive.go
diff options
context:
space:
mode:
authorHaichao Liu <liuhaichao@bytedance.com>2020-11-18 20:53:22 +0800
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-18 14:22:15 +0100
commit913f68ce3820801e045632cb05c6f11e0df50b47 (patch)
treefb7ef8b175cfd7372ff8c5736d24381b6d2d8086 /device/receive.go
parent60b3766b89b9cc664d9bbdc9ab34b283e0374d21 (diff)
device: add write queue mutex for peer
fix panic: send on closed channel when remove peer Signed-off-by: Haichao Liu <liuhaichao@bytedance.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device/receive.go')
-rw-r--r--device/receive.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/device/receive.go b/device/receive.go
index b53c9c0..e4a94b5 100644
--- a/device/receive.go
+++ b/device/receive.go
@@ -184,11 +184,13 @@ func (device *Device) RoutineReceiveIncoming(IP int, bind conn.Bind) {
// add to decryption queues
+ peer.queue.RLock()
if peer.isRunning.Get() {
if device.addToInboundAndDecryptionQueues(peer.queue.inbound, device.queue.decryption, elem) {
buffer = device.GetMessageBuffer()
}
}
+ peer.queue.RUnlock()
continue