Skip to content

Commit

Permalink
Merge pull request #108 from takewofly/fix_on_message
Browse files Browse the repository at this point in the history
fix: when session is closed, no need do OnMessage
  • Loading branch information
AlexStocks authored Mar 16, 2024
2 parents 93d91b4 + 582f4ca commit 71b8185
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ func (s *session) run() {

func (s *session) addTask(pkg interface{}) {
f := func() {
// If the session is closed, there is no need to perform CPU-intensive operations.
if s.IsClosed() {
log.Errorf("[Id:%d, name=%s, endpoint=%s] Session is closed", s.ID(), s.name, s.EndPoint())
return
}
s.listener.OnMessage(s, pkg)
s.IncReadPkgNum()
}
Expand Down

0 comments on commit 71b8185

Please sign in to comment.