mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-10 11:36:36 +08:00
修复流量统计
This commit is contained in:
@@ -57,21 +57,20 @@ func (s *Stats) Get(kind stats.Kind) uint64 {
|
||||
case stats.KindCurrentConns:
|
||||
return s.currentConns.Load()
|
||||
case stats.KindInputBytes:
|
||||
if s.resetTraffic {
|
||||
return s.inputBytes.Swap(0)
|
||||
}
|
||||
return s.inputBytes.Load()
|
||||
return s.inputBytes.Load() // 只获取,不自动清零
|
||||
case stats.KindOutputBytes:
|
||||
if s.resetTraffic {
|
||||
return s.outputBytes.Swap(0)
|
||||
}
|
||||
return s.outputBytes.Load()
|
||||
return s.outputBytes.Load() // 只获取,不自动清零
|
||||
case stats.KindTotalErrs:
|
||||
return s.totalErrs.Load()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (s *Stats) ResetTraffic(reportedInputBytes, reportedOutputBytes uint64) {
|
||||
s.inputBytes.Store(reportedInputBytes)
|
||||
s.outputBytes.Store(reportedOutputBytes)
|
||||
}
|
||||
|
||||
func (s *Stats) Reset() {
|
||||
s.updated.Store(false)
|
||||
s.totalConns.Store(0)
|
||||
|
||||
Reference in New Issue
Block a user