You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/02/07 09:54:42 UTC

[GitHub] [dubbo-go] wenxuwan commented on a change in pull request #1045: Imp: destroy invoker smoothly

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



##########
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 check not needed




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org