Added deferred cancel to prevent context leaks
This commit is contained in:
parent
823ccf79ba
commit
fd952eefbc
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue