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/07/06 01:09:17 UTC

[GitHub] [dubbo-getty] wongoo commented on a change in pull request #56: Ftr: delete session.handleLoop

wongoo commented on a change in pull request #56:
URL: https://github.com/apache/dubbo-getty/pull/56#discussion_r664174265



##########
File path: session.go
##########
@@ -477,56 +495,12 @@ func (s *session) run() {
 		return
 	}
 
-	// start read/write gr
-	atomic.AddInt32(&(s.grNum), 2)
-	go s.handleLoop()
-	go s.handlePackage()
-}
-
-func (s *session) handleLoop() {
-	var (
-		wsFlag  bool
-		wsConn  *gettyWSConn
-		counter gxtime.CountWatch
-	)
-
-	defer func() {
-		if r := recover(); r != nil {
-			const size = 64 << 10
-			rBuf := make([]byte, size)
-			rBuf = rBuf[:runtime.Stack(rBuf, false)]
-			log.Errorf("[session.handleLoop] panic session %s: err=%s\n%s", s.sessionToken(), r, rBuf)
-		}
-
-		grNum := atomic.AddInt32(&(s.grNum), -1)
-		s.listener.OnClose(s)
-		log.Infof("%s, [session.handleLoop] goroutine exit now, left gr num %d", s.Stat(), grNum)
-		s.gc()
-	}()
-
-	wsConn, wsFlag = s.Connection.(*gettyWSConn)
-LOOP:
-	for {
-		select {
-		case <-s.done:
-			// this case branch assure the (session)handleLoop gr will exit after (session)handlePackage gr.
-			<-s.rDone
-			counter.Start()
-			if counter.Count() > s.wait.Nanoseconds() {
-				log.Infof("%s, [session.handleLoop] got done signal ", s.Stat())
-				break LOOP
-			}
-
-		case <-wheel.After(s.period):
-			if wsFlag {
-				err := wsConn.writePing()
-				if err != nil {
-					log.Warnf("wsConn.writePing() = error:%+v", perrors.WithStack(err))
-				}
-			}
-			s.listener.OnCron(s)
-		}
+	s.grNum.Add(1)

Review comment:
       move the statement `s.grNum.Add(1)` just before  `go s.handlePackage()` 




-- 
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: notifications-unsubscribe@dubbo.apache.org

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