Skip to content

Commit

Permalink
Do proper locking for the cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Rebhan committed Dec 2, 2021
1 parent a1e241d commit f90749c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/snmp/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ func LoadMibsFromPath(paths []string, log telegraf.Logger) error {
folders := []string{}

// Check if we loaded that path already and skip it if so
if cache[mibPath] {
m.Lock()
cached := cache[mibPath]
cache[mibPath] = true
m.Unlock()
if cached {
continue
}
cache[mibPath] = true

appendPath(mibPath)
folders = append(folders, mibPath)
Expand Down

0 comments on commit f90749c

Please sign in to comment.