[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wireguard
Subject:    [PATCH] device: make locks more efficient
From:       liuhaichao () bytedance ! com
Date:       2019-08-29 4:13:16
Message-ID: 5d6750e9.1c69fb81.3ce5f.44e5 () mx ! google ! com
[Download RAW message or body]

From: Haichao Liu <liuhaichao@bytedance.com>

Change-Id: I515c38e9911d4baeb4c2a45249c18a371864f8e1
Signed-off-by: Haichao Liu <liuhaichao@bytedance.com>
---
 device/uapi.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/device/uapi.go b/device/uapi.go
index 99cb421..c8499e2 100644
--- a/device/uapi.go
+++ b/device/uapi.go
@@ -283,12 +283,12 @@ func (device *Device) IpcSetOperation(socket *bufio.Reader) *IPCError {
 				logDebug.Println(peer, "- UAPI: Updating endpoint")
 
 				err := func() error {
-					peer.Lock()
-					defer peer.Unlock()
 					endpoint, err := CreateEndpoint(value)
 					if err != nil {
 						return err
 					}
+					peer.Lock()
+					defer peer.Unlock()
 					peer.endpoint = endpoint
 					return nil
 				}()
-- 
2.19.1

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic