Lock access to S.cache
This commit is contained in:
parent
5b967134e8
commit
d15586390a
@ -335,9 +335,12 @@ func (S *Scanner) searchSymbolInPid(pid int) (offset uint64, found bool) {
|
||||
func (S *Scanner) findSymbolInELF(pathname string) (offset uint64, found bool) {
|
||||
|
||||
// 0. Return the value from the cache, if found.
|
||||
S.RLock()
|
||||
if offset, found = S.cache[pathname]; found {
|
||||
S.RUnlock()
|
||||
return offset, found
|
||||
}
|
||||
S.RUnlock()
|
||||
|
||||
// 1. Open the file with the ELF-parser
|
||||
file, err := elf.Open(pathname)
|
||||
@ -390,7 +393,9 @@ func (S *Scanner) findSymbolInELF(pathname string) (offset uint64, found bool) {
|
||||
|
||||
// 6. Store this calculation in our cache so that we don't to touch
|
||||
// this file again.
|
||||
S.Lock()
|
||||
S.cache[pathname] = vmOffset
|
||||
S.Unlock()
|
||||
|
||||
return vmOffset, true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user