device: avoid deadlock when changing private key and removing self peers
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
8cc99631d0
commit
ace50a0529
|
@ -268,7 +268,9 @@ func (device *Device) SetPrivateKey(sk NoisePrivateKey) error {
|
||||||
publicKey := sk.publicKey()
|
publicKey := sk.publicKey()
|
||||||
for key, peer := range device.peers.keyMap {
|
for key, peer := range device.peers.keyMap {
|
||||||
if peer.handshake.remoteStatic.Equals(publicKey) {
|
if peer.handshake.remoteStatic.Equals(publicKey) {
|
||||||
|
peer.handshake.mutex.RUnlock()
|
||||||
unsafeRemovePeer(device, peer, key)
|
unsafeRemovePeer(device, peer, key)
|
||||||
|
peer.handshake.mutex.RLock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue