MCPcopy
hub / github.com/google/gvisor / NewSocket

Function NewSocket

pkg/unet/unet.go:82–98  ·  view source on GitHub ↗

NewSocket returns a socket from an existing FD. NewSocket takes ownership of fd.

(fd int)

Source from the content-addressed store, hash-verified

80//
81// NewSocket takes ownership of fd.
82func NewSocket(fd int) (*Socket, error) {
83 // fd must be non-blocking for non-blocking unix.Accept in
84 // ServerSocket.Accept.
85 if err := unix.SetNonblock(fd, true); err != nil {
86 return nil, err
87 }
88
89 efd, err := eventfd.Create()
90 if err != nil {
91 return nil, err
92 }
93
94 return &Socket{
95 fd: atomicbitops.FromInt32(int32(fd)),
96 efd: efd,
97 }, nil
98}
99
100// finish completes use of s.fd by evicting any waiters, closing the gate, and
101// closing the event FD.

Callers 15

initClientAndGetRootMethod · 0.92
SocketEmitterFunction · 0.92
NewGoferClientFunction · 0.92
createNullSocketFunction · 0.92
ExecuteMethod · 0.92
ExecuteMethod · 0.92
NewSocketFunction · 0.92
startGoferFunction · 0.92

Calls 2

CreateFunction · 0.92
FromInt32Function · 0.92

Tested by 2

startGoferFunction · 0.74
newClosedSocketFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…