Release implements vfs.FileDescriptionImpl.Release.
(ctx context.Context)
| 493 | |
| 494 | // Release implements vfs.FileDescriptionImpl.Release. |
| 495 | func (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. |
| 520 | func (s *sock) Epollable() bool { |
nothing calls this directly
no test coverage detected