fix: timeN function return final closure not be called (#21615)
VulnCheck / Analysis (push) Has been cancelled Details

This commit is contained in:
yangw 2025-10-01 14:06:01 +08:00 committed by GitHub
parent b8631cf531
commit 534f4a9fb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 8 deletions

View File

@ -106,10 +106,9 @@ func (p *scannerMetrics) log(s scannerMetric, paths ...string) func(custom map[s
// time n scanner actions. // time n scanner actions.
// Use for s < scannerMetricLastRealtime // Use for s < scannerMetricLastRealtime
func (p *scannerMetrics) timeN(s scannerMetric) func(n int) func() { func (p *scannerMetrics) timeN(s scannerMetric) func(n int) {
startTime := time.Now() startTime := time.Now()
return func(n int) func() { return func(n int) {
return func() {
duration := time.Since(startTime) duration := time.Since(startTime)
atomic.AddUint64(&p.operations[s], uint64(n)) atomic.AddUint64(&p.operations[s], uint64(n))
@ -117,7 +116,6 @@ func (p *scannerMetrics) timeN(s scannerMetric) func(n int) func() {
p.latency[s].add(duration) p.latency[s].add(duration)
} }
} }
}
} }
// time a scanner action. // time a scanner action.