mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Document confusing defer behavior in mount.go.
PiperOrigin-RevId: 416100664
This commit is contained in:
committed by
gVisor bot
parent
597dc4f7f0
commit
a9938e0f14
@@ -297,6 +297,11 @@ func (vfs *VirtualFilesystem) UmountAt(ctx context.Context, creds *auth.Credenti
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// This defer statement is encapsulated in a function because vd.mount can be
|
||||
// modified in the block below. The arguments to defer are evaluated during
|
||||
// the construction of a defer statement, so if vd.DecRef() was not
|
||||
// encapsulated, the vd structure and its underlying pointers _at this point_
|
||||
// would be copied and DecRefd at the end of this function.
|
||||
defer func() {
|
||||
vd.DecRef(ctx)
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user