fingerprinters accessing node information should be thread safe
This commit is contained in:
parent
64badc3562
commit
b7bcd0b59f
|
@ -100,15 +100,20 @@ func (fm *FingerprintManager) setupDrivers(drivers []string) error {
|
|||
func (fm *FingerprintManager) fingerprint(name string, f fingerprint.Fingerprint) (bool, error) {
|
||||
request := &cstructs.FingerprintRequest{Config: fm.getConfig(), Node: fm.node}
|
||||
var response cstructs.FingerprintResponse
|
||||
if err := f.Fingerprint(request, &response); err != nil {
|
||||
|
||||
fm.nodeLock.Lock()
|
||||
err := f.Fingerprint(request, &response)
|
||||
fm.nodeLock.Unlock()
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
fm.nodeLock.Lock()
|
||||
if node := fm.updateNode(&response); node != nil {
|
||||
fm.nodeLock.Lock()
|
||||
fm.node = node
|
||||
fm.nodeLock.Unlock()
|
||||
}
|
||||
fm.nodeLock.Unlock()
|
||||
|
||||
return response.Detected, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue