AlexStocks commented on a change in pull request #1045:
URL: https://github.com/apache/dubbo-go/pull/1045#discussion_r573533985
##########
File path: protocol/dubbo/dubbo_invoker.go
##########
@@ -162,27 +181,38 @@ func (di *DubboInvoker) getTimeout(invocation
*invocation_impl.RPCInvocation) ti
}
func (di *DubboInvoker) IsAvailable() bool {
- return di.client.IsAvailable()
+ client := di.getClient()
+ if client != nil {
+ return client.IsAvailable()
+ }
+
+ return false
}
// Destroy destroy dubbo client invoker.
func (di *DubboInvoker) Destroy() {
di.quitOnce.Do(func() {
+ di.BaseInvoker.Stop()
+ var times int64
for {
- if di.reqNum == 0 {
- di.reqNum = -1
- logger.Infof("dubboInvoker is
destroyed,url:{%s}", di.GetUrl().Key())
+ times = di.BaseInvoker.InvokeTimes()
+ if times == 0 {
+ di.BaseInvoker.AddInvokerTimes(-1)
+ logger.Infof("dubboInvoker is destroyed,
url:{%s}", di.GetUrl().Key())
di.BaseInvoker.Destroy()
- if di.client != nil {
- di.client.Close()
- di.client = nil
+ client := di.getClient()
+ if client != nil {
+ client.Close()
+ di.setClient(nil)
}
break
+ } else if times < 0 {
Review comment:
万一发生什么幺蛾子呢?防御性编程,这里面有日志的。
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]