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

Method Release

pkg/sentry/socket/netstack/netstack.go:495–517  ·  view source on GitHub ↗

Release implements vfs.FileDescriptionImpl.Release.

(ctx context.Context)

Source from the content-addressed store, hash-verified

493
494// Release implements vfs.FileDescriptionImpl.Release.
495func (s *sock) Release(ctx context.Context) {
496 kernel.KernelFromContext(ctx).DeleteSocket(&s.vfsfd)
497 e, ch := waiter.NewChannelEntry(waiter.EventHUp | waiter.EventErr)
498 s.EventRegister(&e)
499 defer s.EventUnregister(&e)
500
501 s.Endpoint.Close()
502
503 // SO_LINGER option is valid only for TCP. For other socket types
504 // return after endpoint close.
505 if family, skType, _ := s.Type(); skType == linux.SOCK_STREAM && (family == linux.AF_INET || family == linux.AF_INET6) {
506 v := s.Endpoint.SocketOptions().GetLinger()
507 // The case for zero timeout is handled in tcp endpoint close function.
508 // Close is blocked until either:
509 // 1. The endpoint state is not in any of the states: FIN-WAIT1,
510 // CLOSING and LAST_ACK.
511 // 2. Timeout is reached.
512 if v.Enabled && v.Timeout != 0 {
513 _, _ = ctx.BlockWithTimeout(ch, true, v.Timeout)
514 }
515 }
516 s.namespace.DecRef(ctx)
517}
518
519// Epollable implements FileDescriptionImpl.Epollable.
520func (s *sock) Epollable() bool {

Callers

nothing calls this directly

Calls 11

EventRegisterMethod · 0.95
EventUnregisterMethod · 0.95
TypeMethod · 0.95
KernelFromContextFunction · 0.92
NewChannelEntryFunction · 0.92
DeleteSocketMethod · 0.80
GetLingerMethod · 0.80
CloseMethod · 0.65
SocketOptionsMethod · 0.65
BlockWithTimeoutMethod · 0.65
DecRefMethod · 0.65

Tested by

no test coverage detected