mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Plumbing context.Context to DecRef() and Release().
context is passed to DecRef() and Release() which is needed for SO_LINGER implementation. PiperOrigin-RevId: 324672584
This commit is contained in:
committed by
gVisor bot
parent
ef11bb936b
commit
b2ae7ea1bb
@@ -58,7 +58,7 @@ func (c *scmRights) Clone() transport.RightsControlMessage {
|
||||
}
|
||||
|
||||
// Release implements transport.RightsControlMessage.Release.
|
||||
func (c *scmRights) Release() {
|
||||
func (c *scmRights) Release(ctx context.Context) {
|
||||
for _, fd := range c.fds {
|
||||
syscall.Close(fd)
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func NewFD(ctx context.Context, mnt *vfs.Mount, hostFD int, opts *NewFDOptions)
|
||||
d.Init(i)
|
||||
|
||||
// i.open will take a reference on d.
|
||||
defer d.DecRef()
|
||||
defer d.DecRef(ctx)
|
||||
|
||||
// For simplicity, fileDescription.offset is set to 0. Technically, we
|
||||
// should only set to 0 on files that are not seekable (sockets, pipes,
|
||||
@@ -168,9 +168,9 @@ type filesystem struct {
|
||||
devMinor uint32
|
||||
}
|
||||
|
||||
func (fs *filesystem) Release() {
|
||||
func (fs *filesystem) Release(ctx context.Context) {
|
||||
fs.VFSFilesystem().VirtualFilesystem().PutAnonBlockDevMinor(fs.devMinor)
|
||||
fs.Filesystem.Release()
|
||||
fs.Filesystem.Release(ctx)
|
||||
}
|
||||
|
||||
func (fs *filesystem) PrependPath(ctx context.Context, vfsroot, vd vfs.VirtualDentry, b *fspath.Builder) error {
|
||||
@@ -431,12 +431,12 @@ func (i *inode) SetStat(ctx context.Context, fs *vfs.Filesystem, creds *auth.Cre
|
||||
}
|
||||
|
||||
// DecRef implements kernfs.Inode.
|
||||
func (i *inode) DecRef() {
|
||||
i.AtomicRefCount.DecRefWithDestructor(i.Destroy)
|
||||
func (i *inode) DecRef(ctx context.Context) {
|
||||
i.AtomicRefCount.DecRefWithDestructor(ctx, i.Destroy)
|
||||
}
|
||||
|
||||
// Destroy implements kernfs.Inode.
|
||||
func (i *inode) Destroy() {
|
||||
func (i *inode) Destroy(context.Context) {
|
||||
if i.wouldBlock {
|
||||
fdnotifier.RemoveFD(int32(i.hostFD))
|
||||
}
|
||||
@@ -542,7 +542,7 @@ func (f *fileDescription) Stat(ctx context.Context, opts vfs.StatOptions) (linux
|
||||
}
|
||||
|
||||
// Release implements vfs.FileDescriptionImpl.
|
||||
func (f *fileDescription) Release() {
|
||||
func (f *fileDescription) Release(context.Context) {
|
||||
// noop
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ func NewConnectedEndpoint(ctx context.Context, hostFD int, addr string, saveable
|
||||
}
|
||||
|
||||
// Send implements transport.ConnectedEndpoint.Send.
|
||||
func (c *ConnectedEndpoint) Send(data [][]byte, controlMessages transport.ControlMessages, from tcpip.FullAddress) (int64, bool, *syserr.Error) {
|
||||
func (c *ConnectedEndpoint) Send(ctx context.Context, data [][]byte, controlMessages transport.ControlMessages, from tcpip.FullAddress) (int64, bool, *syserr.Error) {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
@@ -216,7 +216,7 @@ func (c *ConnectedEndpoint) EventUpdate() {
|
||||
}
|
||||
|
||||
// Recv implements transport.Receiver.Recv.
|
||||
func (c *ConnectedEndpoint) Recv(data [][]byte, creds bool, numRights int, peek bool) (int64, int64, transport.ControlMessages, bool, tcpip.FullAddress, bool, *syserr.Error) {
|
||||
func (c *ConnectedEndpoint) Recv(ctx context.Context, data [][]byte, creds bool, numRights int, peek bool) (int64, int64, transport.ControlMessages, bool, tcpip.FullAddress, bool, *syserr.Error) {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
@@ -317,8 +317,8 @@ func (c *ConnectedEndpoint) destroyLocked() {
|
||||
|
||||
// Release implements transport.ConnectedEndpoint.Release and
|
||||
// transport.Receiver.Release.
|
||||
func (c *ConnectedEndpoint) Release() {
|
||||
c.ref.DecRefWithDestructor(func() {
|
||||
func (c *ConnectedEndpoint) Release(ctx context.Context) {
|
||||
c.ref.DecRefWithDestructor(ctx, func(context.Context) {
|
||||
c.mu.Lock()
|
||||
c.destroyLocked()
|
||||
c.mu.Unlock()
|
||||
@@ -347,8 +347,8 @@ func (e *SCMConnectedEndpoint) Init() error {
|
||||
|
||||
// Release implements transport.ConnectedEndpoint.Release and
|
||||
// transport.Receiver.Release.
|
||||
func (e *SCMConnectedEndpoint) Release() {
|
||||
e.ref.DecRefWithDestructor(func() {
|
||||
func (e *SCMConnectedEndpoint) Release(ctx context.Context) {
|
||||
e.ref.DecRefWithDestructor(ctx, func(context.Context) {
|
||||
e.mu.Lock()
|
||||
if err := syscall.Close(e.fd); err != nil {
|
||||
log.Warningf("Failed to close host fd %d: %v", err)
|
||||
|
||||
@@ -67,12 +67,12 @@ func (t *TTYFileDescription) ForegroundProcessGroup() *kernel.ProcessGroup {
|
||||
}
|
||||
|
||||
// Release implements fs.FileOperations.Release.
|
||||
func (t *TTYFileDescription) Release() {
|
||||
func (t *TTYFileDescription) Release(ctx context.Context) {
|
||||
t.mu.Lock()
|
||||
t.fgProcessGroup = nil
|
||||
t.mu.Unlock()
|
||||
|
||||
t.fileDescription.Release()
|
||||
t.fileDescription.Release(ctx)
|
||||
}
|
||||
|
||||
// PRead implements vfs.FileDescriptionImpl.
|
||||
|
||||
Reference in New Issue
Block a user