MCPcopy Create free account
hub / github.com/pion/ice / recvLoop

Method recvLoop

candidate_base.go:257–287  ·  view source on GitHub ↗
(initializedCh <-chan struct{})

Source from the content-addressed store, hash-verified

255}
256
257func (c *candidateBase) recvLoop(initializedCh <-chan struct{}) {
258 agent := c.agent()
259
260 defer close(c.closedCh)
261
262 select {
263 case <-initializedCh:
264 case <-c.closeCh:
265 return
266 }
267
268 bufPtr, ok := bufferPool.Get().(*[]byte)
269 if !ok {
270 return
271 }
272 defer bufferPool.Put(bufPtr)
273 buf := *bufPtr
274
275 for {
276 n, srcAddr, err := c.conn.ReadFrom(buf)
277 if err != nil {
278 if !errors.Is(err, io.EOF) && !errors.Is(err, net.ErrClosed) {
279 agent.log.Warnf("Failed to read from candidate %s: %v", c, err)
280 }
281
282 return
283 }
284
285 c.handleInboundPacket(buf[:n], srcAddr)
286 }
287}
288
289func (c *candidateBase) validateSTUNTrafficCache(addr net.Addr) bool {
290 if candidate, ok := c.remoteCandidateCaches.Load(toAddrPort(addr)); ok {

Callers 1

startMethod · 0.95

Calls 4

agentMethod · 0.95
handleInboundPacketMethod · 0.95
ReadFromMethod · 0.45
WarnfMethod · 0.45

Tested by

no test coverage detected