Skip to content

Commit

Permalink
[fix] BasicSessionStat对连接做非空检查,防止panic
Browse files Browse the repository at this point in the history
  • Loading branch information
q191201771 committed Apr 18, 2024
1 parent d4c38c1 commit b8cbe76
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/base/basic_session_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func (s *BasicSessionStat) GetStat() StatSession {
}

func (s *BasicSessionStat) GetStatWithConn(conn IStatable) StatSession {
if conn == nil {
return s.stat
}

connStat := conn.GetStat()
s.stat.ReadBytesSum = connStat.ReadBytesSum
s.stat.WroteBytesSum = connStat.WroteBytesSum
Expand All @@ -141,6 +145,10 @@ func (s *BasicSessionStat) IsAlive() (readAlive, writeAlive bool) {
}

func (s *BasicSessionStat) IsAliveWitchConn(conn IStatable) (readAlive, writeAlive bool) {
if conn == nil {
return s.isAlive(0, 0)
}

currStat := conn.GetStat()
return s.isAlive(currStat.ReadBytesSum, currStat.WroteBytesSum)
}
Expand Down

0 comments on commit b8cbe76

Please sign in to comment.