diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-27 15:53:21 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-27 15:53:21 +0100 |
commit | ace50a0529bdd69f32f637ee84845bde45de07b6 (patch) | |
tree | 4ed51afd93d3c2a60267ee2fd97a517f7120ca44 | |
parent | 8cc99631d025f5013e40f8a5a7b3370bff1c577e (diff) |
device: avoid deadlock when changing private key and removing self peers
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | device/device.go | 2 |
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() } } |