summaryrefslogtreecommitdiffhomepage
path: root/device
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-01-27 15:53:21 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-27 15:53:21 +0100
commitace50a0529bdd69f32f637ee84845bde45de07b6 (patch)
tree4ed51afd93d3c2a60267ee2fd97a517f7120ca44 /device
parent8cc99631d025f5013e40f8a5a7b3370bff1c577e (diff)
device: avoid deadlock when changing private key and removing self peers
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device')
-rw-r--r--device/device.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/device/device.go b/device/device.go
index 47c4944..e769a20 100644
--- a/device/device.go
+++ b/device/device.go
@@ -268,7 +268,9 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
publicKey := sk.publicKey()
for key, peer := range device.peers.keyMap {
if peer.handshake.remoteStatic.Equals(publicKey) {
+ peer.handshake.mutex.RUnlock()
unsafeRemovePeer(device, peer, key)
+ peer.handshake.mutex.RLock()
}
}