Skip to content

Commit

Permalink
[core] Fixed CUnitQueue::getNextAvailUnit(..)
Browse files Browse the repository at this point in the history
Refers to issue #486 getting available uit to receive a packet
  • Loading branch information
maxsharabayko committed Jun 9, 2020
1 parent 03b9f7b commit 16d1ece
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions srtcore/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,21 @@ CUnit *CUnitQueue::getNextAvailUnit()
if (m_iCount >= m_iSize)
return NULL;

CQEntry *entrance = m_pCurrQueue;

int units_checked = 0;
do
{
for (CUnit *sentinel = m_pCurrQueue->m_pUnit + m_pCurrQueue->m_iSize - 1; m_pAvailUnit != sentinel;
++m_pAvailUnit)
const CUnit *end = m_pCurrQueue->m_pUnit + m_pCurrQueue->m_iSize;
for (; m_pAvailUnit != end; ++m_pAvailUnit, ++units_checked)
{
if (m_pAvailUnit->m_iFlag == CUnit::FREE)
{
return m_pAvailUnit;

if (m_pCurrQueue->m_pUnit->m_iFlag == CUnit::FREE)
{
m_pAvailUnit = m_pCurrQueue->m_pUnit;
return m_pAvailUnit;
}
}

m_pCurrQueue = m_pCurrQueue->m_pNext;
m_pAvailUnit = m_pCurrQueue->m_pUnit;
} while (m_pCurrQueue != entrance);
} while (units_checked < m_iSize);

increase();

Expand Down

0 comments on commit 16d1ece

Please sign in to comment.