[fix] BasicSessionStat对连接做非空检查,防止panic

pull/353/head
q191201771 10 months ago
parent d4c38c17f2
commit b8cbe76f38

@ -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
@ -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)
}

Loading…
Cancel
Save