wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
From: liuhaichao@bytedance.com
To: wireguard@lists.zx2c4.com
Cc: liuhaichao <liuhaichao@bytedance.com>
Subject: [PATCH] device: make locks more efficient
Date: Wed, 31 Jul 2019 10:57:16 +0800	[thread overview]
Message-ID: <5d41039d.1c69fb81.343ad.3704@mx.google.com> (raw)

From: liuhaichao <liuhaichao@bytedance.com>

Change-Id: I515c38e9911d4baeb4c2a45249c18a371864f8e1
---
 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

             reply	other threads:[~2019-08-21 15:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-31  2:57 liuhaichao [this message]
2019-08-27 22:57 ` [PATCH] device: make locks more efficient Jason A. Donenfeld
2019-08-29  4:13 liuhaichao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5d41039d.1c69fb81.343ad.3704@mx.google.com \
    --to=liuhaichao@bytedance.com \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).