wenxuwan commented on a change in pull request #1045:
URL: https://github.com/apache/dubbo-go/pull/1045#discussion_r573600852



##########
File path: protocol/dubbo/dubbo_invoker.go
##########
@@ -87,15 +93,28 @@ func (di *DubboInvoker) Invoke(ctx context.Context, 
invocation protocol.Invocati
                err    error
                result protocol.RPCResult
        )
-       if atomic.LoadInt64(&di.reqNum) < 0 {
+       if !di.BaseInvoker.IsAvailable() {
                // Generally, the case will not happen, because the invoker has 
been removed
                // from the invoker list before destroy,so no new request will 
enter the destroyed invoker
                logger.Warnf("this dubboInvoker is destroyed")
-               result.Err = ErrDestroyedInvoker
+               result.Err = protocol.ErrDestroyedInvoker
+               return &result
+       }
+
+       client := di.getClient()

Review comment:
       这个地方个人感觉完全可以把锁提出来
   
   di.clientGuard.RLock()
   client := di.client
   defer di.clientGuard.RUnlock()
   
   这样可以保证有请求的时候,不会说获取到client之后,到后面的client.call的时候,报链接关闭的错误。
   
   
   




----------------------------------------------------------------
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]

Reply via email to