You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/05/14 01:55:49 UTC

[GitHub] [pulsar-client-go] rueian commented on a change in pull request #248: Call pending callbacks of connection after run loop stopped (#239)

rueian commented on a change in pull request #248:
URL: https://github.com/apache/pulsar-client-go/pull/248#discussion_r424827494



##########
File path: pulsar/internal/connection.go
##########
@@ -656,18 +662,20 @@ func (c *connection) Close() {
 
 	c.log.Info("Connection closed")
 	c.state = connectionClosed
-	if c.cnx != nil {
-		c.cnx.Close()
-	}
+	c.TriggerClose()
 	c.pingTicker.Stop()
 	c.pingCheckTicker.Stop()
 
 	for _, listener := range c.listeners {
 		listener.ConnectionClosed()
 	}
 
-	for _, req := range c.pendingReqs {
+	if c.runLoopStoppedCh != nil {

Review comment:
       Do you mean reusing the `closeCh?
   
   It seems that the `closeCh` is a signal to instruct the `run()` loop to exit. However we would not know when the `run()` has finished its job without a dedicated signal.
   
   Therefore, the `runLoopStoppedCh` is the dedicated signal and is responsible to indicating the `run()` loop stopped.
   When `runLoopStoppedCh` closed, we are able do further cleanup resources shared with the `run()` loop.

##########
File path: pulsar/internal/connection.go
##########
@@ -656,18 +662,20 @@ func (c *connection) Close() {
 
 	c.log.Info("Connection closed")
 	c.state = connectionClosed
-	if c.cnx != nil {
-		c.cnx.Close()
-	}
+	c.TriggerClose()
 	c.pingTicker.Stop()
 	c.pingCheckTicker.Stop()
 
 	for _, listener := range c.listeners {
 		listener.ConnectionClosed()
 	}
 
-	for _, req := range c.pendingReqs {
+	if c.runLoopStoppedCh != nil {

Review comment:
       Do you mean reusing the `closeCh`?
   
   It seems that the `closeCh` is a signal to instruct the `run()` loop to exit. However we would not know when the `run()` has finished its job without a dedicated signal.
   
   Therefore, the `runLoopStoppedCh` is the dedicated signal and is responsible to indicating the `run()` loop stopped.
   When `runLoopStoppedCh` closed, we are able do further cleanup resources shared with the `run()` loop.




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