AlexStocks / getty

a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Apache License 2.0
886 stars 184 forks source link

counter bug in session.go handleLoop() function #32

Closed chinaerserver closed 4 years ago

chinaerserver commented 4 years ago

in handleLoop() function select case <-s.done: branch

counter.Start() if counter.Count() > s.wait.Nanoseconds() {   log.Info("%s, [session.handleLoop] got done signal ", s.Stat())   break LOOP }

if counter doesn't reach session exit waiting time , this if-branch will not hit so it cannot break loop. however close(s. done) will tigger only once, if for-loop continue running ,case <-s.done will never reach. so exit wait delay will not perform as expected.

In my opinion, judging exit waiting timeout should appear in select default case or using while counter.Count() > s.wait.Nanoseconds() {} to confirm timeout exit as expected.

AlexStocks commented 4 years ago

cc @watermelo @fangyincheng . pls check it.

chinaerserver commented 4 years ago

I am worried about that in handleLoop() function if using writer encode pkg fail ,why still loop and doing nothing? Why not panic to stop for-looping

Enan01 commented 3 years ago

I am worried about that in handleLoop() function if using writer encode pkg fail ,why still loop and doing nothing? Why not panic to stop for-looping

I also want to know why?