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
@@ -97,7 +97,7 @@ func (*socketProvider) Socket(t *kernel.Task, stype linux.SockType, protocol int
|
||||
}
|
||||
|
||||
d := socket.NewDirent(t, netlinkSocketDevice)
|
||||
defer d.DecRef()
|
||||
defer d.DecRef(t)
|
||||
return fs.NewFile(t, d, fs.FileFlags{Read: true, Write: true, NonSeekable: true}, s), nil
|
||||
}
|
||||
|
||||
|
||||
@@ -140,14 +140,14 @@ func NewSocket(t *kernel.Task, skType linux.SockType, protocol Protocol) (*Socke
|
||||
// Bind the endpoint for good measure so we can connect to it. The
|
||||
// bound address will never be exposed.
|
||||
if err := ep.Bind(tcpip.FullAddress{Addr: "dummy"}, nil); err != nil {
|
||||
ep.Close()
|
||||
ep.Close(t)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create a connection from which the kernel can write messages.
|
||||
connection, err := ep.(transport.BoundEndpoint).UnidirectionalConnect(t)
|
||||
if err != nil {
|
||||
ep.Close()
|
||||
ep.Close(t)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -164,9 +164,9 @@ func NewSocket(t *kernel.Task, skType linux.SockType, protocol Protocol) (*Socke
|
||||
}
|
||||
|
||||
// Release implements fs.FileOperations.Release.
|
||||
func (s *socketOpsCommon) Release() {
|
||||
s.connection.Release()
|
||||
s.ep.Close()
|
||||
func (s *socketOpsCommon) Release(ctx context.Context) {
|
||||
s.connection.Release(ctx)
|
||||
s.ep.Close(ctx)
|
||||
|
||||
if s.bound {
|
||||
s.ports.Release(s.protocol.Protocol(), s.portID)
|
||||
@@ -621,7 +621,7 @@ func (s *socketOpsCommon) sendResponse(ctx context.Context, ms *MessageSet) *sys
|
||||
if len(bufs) > 0 {
|
||||
// RecvMsg never receives the address, so we don't need to send
|
||||
// one.
|
||||
_, notify, err := s.connection.Send(bufs, cms, tcpip.FullAddress{})
|
||||
_, notify, err := s.connection.Send(ctx, bufs, cms, tcpip.FullAddress{})
|
||||
// If the buffer is full, we simply drop messages, just like
|
||||
// Linux.
|
||||
if err != nil && err != syserr.ErrWouldBlock {
|
||||
@@ -648,7 +648,7 @@ func (s *socketOpsCommon) sendResponse(ctx context.Context, ms *MessageSet) *sys
|
||||
// Add the dump_done_errno payload.
|
||||
m.Put(int64(0))
|
||||
|
||||
_, notify, err := s.connection.Send([][]byte{m.Finalize()}, cms, tcpip.FullAddress{})
|
||||
_, notify, err := s.connection.Send(ctx, [][]byte{m.Finalize()}, cms, tcpip.FullAddress{})
|
||||
if err != nil && err != syserr.ErrWouldBlock {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -57,14 +57,14 @@ func NewVFS2(t *kernel.Task, skType linux.SockType, protocol Protocol) (*SocketV
|
||||
// Bind the endpoint for good measure so we can connect to it. The
|
||||
// bound address will never be exposed.
|
||||
if err := ep.Bind(tcpip.FullAddress{Addr: "dummy"}, nil); err != nil {
|
||||
ep.Close()
|
||||
ep.Close(t)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create a connection from which the kernel can write messages.
|
||||
connection, err := ep.(transport.BoundEndpoint).UnidirectionalConnect(t)
|
||||
if err != nil {
|
||||
ep.Close()
|
||||
ep.Close(t)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user