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

fix epoll event loss problem #1843

Merged
merged 4 commits into from
Mar 9, 2021
Merged
Changes from all commits
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
24 changes: 19 additions & 5 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7554,13 +7554,27 @@ int CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
}
else
{
if (m_config.bSynRecving)
{
// signal a waiting "recv" call if there is any data available
CSync::lock_signal(m_RecvDataCond, m_RecvLock);
UniqueLock rdlock (m_RecvLock);
CSync rdcond (m_RecvDataCond, rdlock);
if (m_config.bSynRecving)
{
// signal a waiting "recv" call if there is any data available
rdcond.signal_locked(rdlock);
}
// acknowledge any waiting epolls to read
// fix SRT_EPOLL_IN event loss but rcvbuffer still have data:
// 1. user call receive/receivemessage(about line number:6482)
// 2. after read/receive, if rcvbuffer is empty, will set SRT_EPOLL_IN event to false
// 3. but if we do not do some lock work here, will cause some sync problems between threads:
// (1) user thread: call receive/receivemessage
// (2) user thread: read data
// (3) user thread: no data in rcvbuffer, set SRT_EPOLL_IN event to false
// (4) receive thread: receive data and set SRT_EPOLL_IN to true
// (5) user thread: set SRT_EPOLL_IN to false
// 4. so , m_RecvLock must be used here to protect epoll event
s_UDTUnited.m_EPoll.update_events(m_SocketID, m_sPollID, SRT_EPOLL_IN, true);
}
// acknowledge any waiting epolls to read
s_UDTUnited.m_EPoll.update_events(m_SocketID, m_sPollID, SRT_EPOLL_IN, true);
#if ENABLE_EXPERIMENTAL_BONDING
if (m_parent->m_GroupOf)
{
Expand Down