Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:plonk/peercast-yt into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
plonk committed Jan 27, 2022
2 parents dcf0bed + e978f7a commit 1f63c2b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/common/chanpacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,25 @@ void ChanPacketBuffer::readPacket(ChanPacket &pack)
{
unsigned int tim = sys->getTime();

lock.lock();

if (readPos < firstPos)
{
lock.unlock();
throw StreamException("Read too far behind");
}

while (readPos >= writePos)
{
lock.unlock();
sys->sleepIdle();
if ((sys->getTime() - tim) > 30)
{
throw TimeoutException();
}
lock.lock();
}
lock.lock();

pack = packets[readPos%MAX_PACKETS];
readPos++;
lock.unlock();
Expand Down

0 comments on commit 1f63c2b

Please sign in to comment.