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

Method Close

pkg/unet/unet.go:115–132  ·  view source on GitHub ↗

Close closes the socket.

()

Source from the content-addressed store, hash-verified

113
114// Close closes the socket.
115func (s *Socket) Close() error {
116 // Set the FD in the socket to -1, to ensure that all future calls to
117 // FD/Release get nothing and Close calls return immediately.
118 fd := int(s.fd.Swap(-1))
119 if fd < 0 {
120 // Already closed or closing.
121 return unix.EBADF
122 }
123
124 // Shutdown the socket to cancel any pending accepts.
125 s.shutdown(fd)
126
127 if err := s.finish(); err != nil {
128 return err
129 }
130
131 return unix.Close(fd)
132}
133
134// Release releases ownership of the socket FD.
135//

Callers 6

StartMethod · 0.95
CreateMethod · 0.95
newClosedSocketFunction · 0.95
SocketPairFunction · 0.95
createNullSocketFunction · 0.95
startGoferFunction · 0.95

Calls 4

shutdownMethod · 0.95
finishMethod · 0.95
CloseMethod · 0.65
SwapMethod · 0.45

Tested by 2

newClosedSocketFunction · 0.76
startGoferFunction · 0.76