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)
| 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. |
| 151 | func (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. |
no test coverage detected