Skip to content

Commit d552626

Browse files
committed
optimize notify
1 parent 456b99c commit d552626

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sess.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,12 @@ func (s *UDPSession) kcpInput(data []byte) {
556556
s.mu.Unlock()
557557
}
558558

559-
s.notifyReadEvent()
559+
// notify reader
560+
s.mu.Lock()
561+
if n := s.kcp.PeekSize(); n > 0 {
562+
s.notifyReadEvent()
563+
}
564+
s.mu.Unlock()
560565

561566
if s.ackNoDelay {
562567
s.mu.Lock()

0 commit comments

Comments
 (0)