2022-01-14 09:12:21 +00:00
|
|
|
// These are all non recursive rlocks. Testing to make sure there are no false positives
|
|
|
|
package testdata
|
|
|
|
|
2022-02-02 14:11:31 +00:00
|
|
|
func (resource *ProtectResource) NestedRLockWithDefer() string {
|
2022-01-14 09:12:21 +00:00
|
|
|
resource.RLock()
|
|
|
|
defer resource.RUnlock()
|
2022-02-02 14:11:31 +00:00
|
|
|
return resource.GetResource() // want `found recursive read lock call`
|
2022-01-14 09:12:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (resource *NestedProtectResource) NonNestedRLockDifferentRLocks() {
|
|
|
|
resource.RLock()
|
|
|
|
resource.GetNestedPResource() // get nested resource uses RLock, but at a deeper level in the struct
|
|
|
|
resource.RUnlock()
|
|
|
|
}
|
2022-04-05 16:39:48 +00:00
|
|
|
|
|
|
|
func (resource *ProtectResource) NestedLockWithDefer() string {
|
|
|
|
resource.Lock()
|
|
|
|
defer resource.Unlock()
|
|
|
|
return resource.GetResourceLocked() // want `found recursive lock call`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (resource *NestedProtectResource) NonNestedLockDifferentLocks() {
|
|
|
|
resource.Lock()
|
|
|
|
resource.GetNestedPResourceLocked() // get nested resource uses RLock, but at a deeper level in the struct
|
|
|
|
resource.Unlock()
|
|
|
|
}
|