mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 01:45:44 +03:00
Added deferred cancel to prevent context leaks
This commit is contained in:
@@ -37,7 +37,8 @@ func Init() error {
|
||||
}
|
||||
|
||||
var cpuInfo []cpu.InfoStat
|
||||
ctx, _ := context.WithTimeout(context.Background(), cpuInfoTimeout)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cpuInfoTimeout)
|
||||
defer cancel()
|
||||
if cpuInfo, err = cpu.InfoWithContext(ctx); err != nil {
|
||||
merrs = multierror.Append(merrs, fmt.Errorf("Unable to obtain CPU information: %v", err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user