Skip to contentSkip to conversation

device: make locks more efficient

PATCH In review [email protected] 2 participants 2 messages Aug 21, 2019 – Aug 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 device: make locks more efficient

From: liuhaichao <[email protected]>

Change-Id: I515c38e9911d4baeb4c2a45249c18a371864f8e1

---
 device/uapi.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
device/uapi.go +2 -2
index 99cb421..c8499e2 100644
@@ -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
 				}()
Signature · 6 lines
2.19.1

_______________________________________________
WireGuard mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/wireguard