MCPcopy Create free account
hub / github.com/Haivision/srt / worker_RetrieveUnit

Method worker_RetrieveUnit

srtcore/queue.cpp:1387–1441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1385}
1386
1387srt::EReadStatus srt::CRcvQueue::worker_RetrieveUnit(int32_t& w_id, CUnit*& w_unit, sockaddr_any& w_addr)
1388{
1389#if !USE_BUSY_WAITING
1390 // This might be not really necessary, and probably
1391 // not good for extensive bidirectional communication.
1392 m_pTimer->tick();
1393#endif
1394
1395 // check waiting list, if new socket, insert it to the list
1396 while (ifNewEntry())
1397 {
1398 CUDT* ne = getNewEntry();
1399 if (ne)
1400 {
1401 HLOGC(qrlog.Debug,
1402 log << CUDTUnited::CONID(ne->m_SocketID)
1403 << " SOCKET pending for connection - ADDING TO RCV QUEUE/MAP");
1404 m_pRcvUList->insert(ne);
1405 m_pHash->insert(ne->m_SocketID, ne);
1406 }
1407 }
1408 // find next available slot for incoming packet
1409 w_unit = m_pUnitQueue->getNextAvailUnit();
1410 if (!w_unit)
1411 {
1412 // no space, skip this packet
1413 CPacket temp;
1414 temp.allocate(m_szPayloadSize);
1415 THREAD_PAUSED();
1416 EReadStatus rst = m_pChannel->recvfrom((w_addr), (temp));
1417 THREAD_RESUMED();
1418 // Note: this will print nothing about the packet details unless heavy logging is on.
1419 LOGC(qrlog.Error, log << CONID() << "LOCAL STORAGE DEPLETED. Dropping 1 packet: " << temp.Info());
1420
1421 // Be transparent for RST_ERROR, but ignore the correct
1422 // data read and fake that the packet was dropped.
1423 return rst == RST_ERROR ? RST_ERROR : RST_AGAIN;
1424 }
1425
1426 w_unit->m_Packet.setLength(m_szPayloadSize);
1427
1428 // reading next incoming packet, recvfrom returns -1 is nothing has been received
1429 THREAD_PAUSED();
1430 EReadStatus rst = m_pChannel->recvfrom((w_addr), (w_unit->m_Packet));
1431 THREAD_RESUMED();
1432
1433 if (rst == RST_OK)
1434 {
1435 w_id = w_unit->m_Packet.id();
1436 HLOGC(qrlog.Debug,
1437 log << "INCOMING PACKET: FROM=" << w_addr.str() << " BOUND=" << m_pChannel->bindAddressAny().str() << " "
1438 << w_unit->m_Packet.Info());
1439 }
1440 return rst;
1441}
1442
1443srt::EConnectStatus srt::CRcvQueue::worker_ProcessConnectionRequest(CUnit* unit, const sockaddr_any& addr)
1444{

Callers 1

workerMethod · 0.95

Calls 9

getNextAvailUnitMethod · 0.80
allocateMethod · 0.80
setLengthMethod · 0.80
tickMethod · 0.45
insertMethod · 0.45
recvfromMethod · 0.45
InfoMethod · 0.45
idMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected