mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05: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() {
|
func statsThread() {
|
||||||
var numClientIP, numConnections uint64
|
var numClientIP, numConnections uint64
|
||||||
prevTime := time.Now()
|
prevTime := time.Now()
|
||||||
|
deadline := time.After(statsInterval)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case v := <-statsChannel:
|
case v := <-statsChannel:
|
||||||
|
@ -29,7 +30,7 @@ func statsThread() {
|
||||||
numClientIP += 1
|
numClientIP += 1
|
||||||
}
|
}
|
||||||
numConnections += 1
|
numConnections += 1
|
||||||
case <-time.After(statsInterval):
|
case <-deadline:
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
log.Printf("in the past %.g s, %d/%d connections had client_ip",
|
log.Printf("in the past %.g s, %d/%d connections had client_ip",
|
||||||
(now.Sub(prevTime)).Seconds(),
|
(now.Sub(prevTime)).Seconds(),
|
||||||
|
@ -37,6 +38,7 @@ func statsThread() {
|
||||||
numClientIP = 0
|
numClientIP = 0
|
||||||
numConnections = 0
|
numConnections = 0
|
||||||
prevTime = now
|
prevTime = now
|
||||||
|
deadline = time.After(statsInterval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue