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

Method blockingAccept

pkg/sentry/socket/unix/unix.go:151–168  ·  view source on GitHub ↗

blockingAccept implements a blocking version of accept(2), that is, if no connections are ready to be accept, it will block until one becomes ready.

(t *kernel.Task, peerAddr *transport.Address)

Source from the content-addressed store, hash-verified

149// blockingAccept implements a blocking version of accept(2), that is, if no
150// connections are ready to be accept, it will block until one becomes ready.
151func (s *Socket) blockingAccept(t *kernel.Task, peerAddr *transport.Address) (transport.Endpoint, *syserr.Error) {
152 // Register for notifications.
153 e, ch := waiter.NewChannelEntry(waiter.ReadableEvents)
154 s.EventRegister(&e)
155 defer s.EventUnregister(&e)
156
157 // Try to accept the connection; if it fails, then wait until we get a
158 // notification.
159 for {
160 if ep, err := s.ep.Accept(t, peerAddr); err != syserr.ErrWouldBlock {
161 return ep, err
162 }
163
164 if err := t.Block(ch); err != nil {
165 return nil, syserr.FromError(err)
166 }
167 }
168}
169
170// Accept implements the linux syscall accept(2) for sockets backed by
171// a transport.Endpoint.

Callers 1

AcceptMethod · 0.95

Calls 6

EventRegisterMethod · 0.95
EventUnregisterMethod · 0.95
NewChannelEntryFunction · 0.92
FromErrorFunction · 0.92
AcceptMethod · 0.65
BlockMethod · 0.65

Tested by

no test coverage detected