mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Fix periodic stats reporting.
The time interval was being reset every time a new connection came in.
This commit is contained in:
parent
99604ff15a
commit
085f253757
1 changed files with 3 additions and 1 deletions
|
@ -22,6 +22,7 @@ var (
|
|||
func statsThread() {
|
||||
var numClientIP, numConnections uint64
|
||||
prevTime := time.Now()
|
||||
deadline := time.After(statsInterval)
|
||||
for {
|
||||
select {
|
||||
case v := <-statsChannel:
|
||||
|
@ -29,7 +30,7 @@ func statsThread() {
|
|||
numClientIP += 1
|
||||
}
|
||||
numConnections += 1
|
||||
case <-time.After(statsInterval):
|
||||
case <-deadline:
|
||||
now := time.Now()
|
||||
log.Printf("in the past %.g s, %d/%d connections had client_ip",
|
||||
(now.Sub(prevTime)).Seconds(),
|
||||
|
@ -37,6 +38,7 @@ func statsThread() {
|
|||
numClientIP = 0
|
||||
numConnections = 0
|
||||
prevTime = now
|
||||
deadline = time.After(statsInterval)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue