fix: extra lock on init for safety (#10199)

This commit is contained in:
Mya 2021-12-01 10:02:38 -07:00 committed by GitHub
parent 69afb140ad
commit b4ef429302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -15,11 +15,12 @@ import (
// must init, append path for each directory, load module for every file
// or gosmi will fail without saying why
var m sync.Mutex
var once sync.Once
func LoadMibsFromPath(paths []string, log telegraf.Logger) error {
m.Lock()
defer m.Unlock()
gosmi.Init()
once.Do(gosmi.Init)
var folders []string
for _, mibPath := range paths {
gosmi.AppendPath(mibPath)