222twotwotwo commented on code in PR #142:
URL: https://github.com/apache/dubbo-getty/pull/142#discussion_r3791268163


##########
client.go:
##########
@@ -416,7 +416,28 @@ func (c *client) RunEventLoop(newSession 
NewSessionCallback) {
        c.Lock()
        c.newSession = newSession
        c.Unlock()
-       c.reConnect()
+       <-c.runReconnect()
+}
+
+func (c *client) runReconnect() <-chan struct{} {
+       done := make(chan struct{})
+       c.Lock()
+       select {
+       case <-c.done:
+               c.Unlock()
+               close(done)
+               return done
+       default:
+               c.wg.Add(1)

Review Comment:
   收到, NewSessionCallback`内调用 Client.Close() 时不会再等待当前正在执行 callback 的 goroutine 
自己。



##########
client.go:
##########
@@ -416,7 +416,28 @@ func (c *client) RunEventLoop(newSession 
NewSessionCallback) {
        c.Lock()
        c.newSession = newSession
        c.Unlock()
-       c.reConnect()
+       <-c.runReconnect()
+}
+
+func (c *client) runReconnect() <-chan struct{} {
+       done := make(chan struct{})
+       c.Lock()
+       select {
+       case <-c.done:
+               c.Unlock()
+               close(done)
+               return done
+       default:
+               c.wg.Add(1)

Review Comment:
   收到, NewSessionCallback内调用 Client.Close() 时不会再等待当前正在执行 callback 的 goroutine 
自己。



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

To unsubscribe, e-mail: [email protected]

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