Skip to content

Commit bc7fd08

Browse files
Uzair Nawazgvisor-bot
authored andcommitted
Fix checklock errors discovered by #12347
The changes in #12347 led to additional errors being reported in existing code. This PR addresses those issues with additional annotations. FUTURE_COPYBARA_INTEGRATE_REVIEW=#12379 from uzairnawaz:fix-new-checklock-errors 9871b5a PiperOrigin-RevId: 844243954
1 parent 7d4e598 commit bc7fd08

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

pkg/tcpip/transport/tcp/endpoint.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ func (e *Endpoint) LockUser() {
688688
// Finally just give up and wait for the Lock.
689689
e.mu.Lock()
690690
e.ownedByUser.Store(1)
691+
return // +checklocksforce: this locks e.snd.ep.mu
691692
}
692693

693694
// UnlockUser will check if there are any segments already queued for processing
@@ -753,6 +754,7 @@ func (e *Endpoint) AssertLockHeld(locked *Endpoint) {
753754
if e != locked {
754755
panic("AssertLockHeld failed: locked endpoint != asserting endpoint")
755756
}
757+
return // +checklocksforce
756758
}
757759

758760
// TryLock is a helper that calls TryLock on the endpoint's mutex and

tools/checklocks/test/branches.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func testInconsistentReturn(tc *oneGuardStruct) { // +checklocksfail
2222
if x := rand.Intn(10); x%2 == 1 {
2323
tc.mu.Lock()
2424
}
25+
return
2526
}
2627

2728
func testConsistentBranching(tc *oneGuardStruct) {
@@ -53,6 +54,7 @@ func testInconsistentBranching(tc *oneGuardStruct) { // +checklocksfail:2
5354
if x%2 == 1 {
5455
tc.mu.Unlock() // +checklocksforce
5556
}
57+
return
5658
}
5759

5860
func testUnboundedLocks(tc []*oneGuardStruct) {

tools/checklocks/test/methods.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func standaloneFunctionWithGuard(a *testMethodsWithParameters) {
9696
a.guardedField = 1
9797
a.mu.Unlock()
9898
a.guardedField = 1 // +checklocksfail
99+
return // +checklocksfail
99100
}
100101

101102
type testMethodsWithEmbedded struct {

0 commit comments

Comments
 (0)