Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fixed packet drop when reading from members #1784

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2078,21 +2078,36 @@ vector<CUDTSocket*> CUDTGroup::recv_WaitForReadReady(const vector<CUDTSocket*>&
// will be surely empty. This will be checked then same way as when
// reading from every socket resulted in error.
vector<CUDTSocket*> readReady;
readReady.reserve(sready.size());
for (CEPoll::fmap_t::const_iterator i = sready.begin(); i != sready.end(); ++i)
readReady.reserve(aliveMembers.size());
for (vector<CUDTSocket*>::const_iterator sockiter = aliveMembers.begin(); sockiter != aliveMembers.end(); ++sockiter)
{
if (i->second & SRT_EPOLL_ERR)
continue; // broken already
CUDTSocket* sock = *sockiter;
const CEPoll::fmap_t::const_iterator ready_iter = sready.find(sock->m_SocketID);
if (ready_iter != sready.end())
{
if (ready_iter->second & SRT_EPOLL_ERR)
continue; // broken already

if ((ready_iter->second & SRT_EPOLL_IN) == 0)
continue; // not ready for reading

if ((i->second & SRT_EPOLL_IN) == 0)
continue; // not ready for reading
readReady.push_back(*sockiter);
}
else
{
// No reqd-readiness on the socket, but could have missed or not yet handled, so check the state manually
steady_clock::time_point tsbpdtime;
int current_pkt_seq = 0;

// Check if this socket is in aheads
// If so, don't read from it, wait until the ahead is flushed.
SRTSOCKET id = i->first;
CUDTSocket* ps = m_pGlobal->locateSocket_LOCKED(id);
if (ps)
readReady.push_back(ps);
int32_t skiptoseqno = SRT_SEQNO_NONE;
bool passack = true; // Get next packet to wait for even if not acked
const bool rxready = sock->core().m_pRcvBuffer->getRcvFirstMsg((tsbpdtime), (passack), (skiptoseqno), (current_pkt_seq));
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved

if (rxready)
{
readReady.push_back(sock);
}
}
}

leaveCS(CUDT::s_UDTUnited.m_GlobControlLock);
Expand Down