Skip to content

Commit 4429aaf

Browse files
committed
Tweak the lock
1 parent cdfb109 commit 4429aaf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/orchestrator/internal/sandbox/uffd/userfaultfd/userfaultfd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,9 @@ func (u *Userfaultfd) Unregister() error {
279279
func (u *Userfaultfd) Dirty() *block.Tracker {
280280
// This will be at worst cancelled when the uffd is closed.
281281
u.settleRequests.Lock()
282-
// Intentionally not using defer—we just need to write lock and write unlock the mutex, to be sure all the RLock calls are released.
283-
u.settleRequests.Unlock() //nolint:staticcheck
282+
// The locking here would work even without using defer (just lock-then-unlock the mutex), but at this point let's make it lock to the clone,
283+
// so it is consistent even if there is a another uffd call after.
284+
defer u.settleRequests.Unlock()
284285

285286
return u.missingRequests.Clone()
286287
}

0 commit comments

Comments
 (0)