From 2a6dd2ed926ddc44cd98d8c940aa01f830213ea0 Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Fri, 21 Jul 2017 15:17:43 +0200 Subject: Fixed UAPI deadlock --- src/config.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/config.go') diff --git a/src/config.go b/src/config.go index d92e8d7..2d9ac50 100644 --- a/src/config.go +++ b/src/config.go @@ -106,17 +106,17 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { key := parts[0] value := parts[1] + fmt.Println(key, value) + switch key { /* interface configuration */ case "private_key": + var sk NoisePrivateKey if value == "" { - device.mutex.Lock() - device.privateKey = NoisePrivateKey{} - device.mutex.Unlock() + device.SetPrivateKey(sk) } else { - var sk NoisePrivateKey err := sk.FromHex(value) if err != nil { logError.Println("Failed to set private_key:", err) @@ -183,9 +183,7 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { switch key { case "remove": - peer.mutex.Lock() device.RemovePeer(peer.handshake.remoteStatic) - peer.mutex.Unlock() logDebug.Println("Removing", peer.String()) peer = nil @@ -236,7 +234,6 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError { return &IPCError{Code: ipcErrorInvalidValue} } ones, _ := network.Mask.Size() - logError.Println(network, ones, network.IP) device.routingTable.Insert(network.IP, uint(ones), peer) default: -- cgit v1.2.3