From 7cc32809fd6eb0c8869946c6e75e0278056528b4 Mon Sep 17 00:00:00 2001
From: xujianhai666 <zero.xu@bytedance.com>
Date: Sat, 30 Nov 2019 21:07:54 +0800
Subject: [PATCH] =?UTF-8?q?feat(dubbo/invoker):=20=E4=BF=AE=E6=94=B9dubbo?=
 =?UTF-8?q?=20=E5=85=B3=E9=97=AD=E7=9A=84=E6=96=B9=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 protocol/dubbo/dubbo_invoker.go | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go
index bc321a97a..4582e54c2 100644
--- a/protocol/dubbo/dubbo_invoker.go
+++ b/protocol/dubbo/dubbo_invoker.go
@@ -42,8 +42,8 @@ var (
 
 type DubboInvoker struct {
 	protocol.BaseInvoker
-	client      *Client
-	destroyLock sync.Mutex
+	client   *Client
+	quitOnce sync.Once
 }
 
 func NewDubboInvoker(url common.URL, client *Client) *DubboInvoker {
@@ -97,19 +97,11 @@ func (di *DubboInvoker) Invoke(invocation protocol.Invocation) protocol.Result {
 }
 
 func (di *DubboInvoker) Destroy() {
-	if di.IsDestroyed() {
-		return
-	}
-	di.destroyLock.Lock()
-	defer di.destroyLock.Unlock()
-
-	if di.IsDestroyed() {
-		return
-	}
+	di.quitOnce.Do(func() {
+		di.BaseInvoker.Destroy()
 
-	di.BaseInvoker.Destroy()
-
-	if di.client != nil {
-		di.client.Close() // close client
-	}
+		if di.client != nil {
+			di.client.Close()
+		}
+	})
 }
-- 
GitLab