fix a potential unexpected closing while bucket has exhausted

This commit is contained in:
xtaci
2020-02-20 17:13:26 +08:00
parent d2d7690bcc
commit 80072d9b5c
+6 -2
View File
@@ -392,8 +392,12 @@ func (s *Session) keepalive() {
s.notifyBucket() // force a signal to the recvLoop
case <-tickerTimeout.C:
if !atomic.CompareAndSwapInt32(&s.dataReady, 1, 0) {
s.Close()
return
// recvLoop main block on bucket == 0, in this case,
// session should not be closed.
if atomic.LoadInt32(&s.bucket) > 0 {
s.Close()
return
}
}
case <-s.die:
return