diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go index 7e12775a4d..7bd40fe8e4 100644 --- a/pkg/tcpip/transport/tcp/endpoint.go +++ b/pkg/tcpip/transport/tcp/endpoint.go @@ -688,6 +688,7 @@ func (e *Endpoint) LockUser() { // Finally just give up and wait for the Lock. e.mu.Lock() e.ownedByUser.Store(1) + return // +checklocksforce: this locks e.snd.ep.mu } // UnlockUser will check if there are any segments already queued for processing @@ -753,6 +754,7 @@ func (e *Endpoint) AssertLockHeld(locked *Endpoint) { if e != locked { panic("AssertLockHeld failed: locked endpoint != asserting endpoint") } + return // +checklocksforce } // TryLock is a helper that calls TryLock on the endpoint's mutex and diff --git a/tools/checklocks/test/branches.go b/tools/checklocks/test/branches.go index 247885a49c..d1ea0e58f0 100644 --- a/tools/checklocks/test/branches.go +++ b/tools/checklocks/test/branches.go @@ -22,6 +22,7 @@ func testInconsistentReturn(tc *oneGuardStruct) { // +checklocksfail if x := rand.Intn(10); x%2 == 1 { tc.mu.Lock() } + return } func testConsistentBranching(tc *oneGuardStruct) { @@ -53,6 +54,7 @@ func testInconsistentBranching(tc *oneGuardStruct) { // +checklocksfail:2 if x%2 == 1 { tc.mu.Unlock() // +checklocksforce } + return } func testUnboundedLocks(tc []*oneGuardStruct) { diff --git a/tools/checklocks/test/methods.go b/tools/checklocks/test/methods.go index b67657b61d..c974fa252a 100644 --- a/tools/checklocks/test/methods.go +++ b/tools/checklocks/test/methods.go @@ -96,6 +96,7 @@ func standaloneFunctionWithGuard(a *testMethodsWithParameters) { a.guardedField = 1 a.mu.Unlock() a.guardedField = 1 // +checklocksfail + return // +checklocksfail } type testMethodsWithEmbedded struct {