updater: minimize vulns' lock duration in the NVD metadata fetcher

This commit is contained in:
Quentin Machu 2016-11-18 18:05:20 +01:00
parent e38b67a513
commit 1c3daa23b9

View File

@ -105,7 +105,6 @@ func (fetcher *NVDMetadataFetcher) AddMetadata(vulnerability *updater.Vulnerabil
if nvdMetadata, ok := fetcher.metadata[vulnerability.Name]; ok {
vulnerability.Lock.Lock()
defer vulnerability.Lock.Unlock()
// Create Metadata map if necessary.
if vulnerability.Metadata == nil {
@ -113,6 +112,8 @@ func (fetcher *NVDMetadataFetcher) AddMetadata(vulnerability *updater.Vulnerabil
}
vulnerability.Metadata[metadataKey] = nvdMetadata
vulnerability.Lock.Unlock()
}
return nil