You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2019/12/09 05:31:24 UTC
[dubbo-go] branch develop updated: feat(dubbo/invoker): 修改dubbo 关闭的方式
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new 17a63bf feat(dubbo/invoker): 修改dubbo 关闭的方式
new a253564 Merge pull request #268 from xujianhai666/feat-invoker
17a63bf is described below
commit 17a63bf255b828680bb05af2b47fd48af06d3383
Author: xujianhai666 <ze...@bytedance.com>
AuthorDate: Sat Nov 30 21:07:54 2019 +0800
feat(dubbo/invoker): 修改dubbo 关闭的方式
---
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 bc321a9..4582e54 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()
+ }
+ })
}