Skip to content

Commit

Permalink
Merge pull request #268 from xujianhai666/feat-invoker
Browse files Browse the repository at this point in the history
feat(dubbo/invoker): 修改dubbo 关闭的方式
  • Loading branch information
AlexStocks authored Dec 9, 2019
2 parents e6d7c04 + 17a63bf commit a253564
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions protocol/dubbo/dubbo_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
})
}

0 comments on commit a253564

Please sign in to comment.