Create UDT session with peer node, add usock to epoll for read, write, exception, etc events.
When peer node closes the UDT session, epoll_wait is not getting UDT_EPOLL_ERR event.
I have checked the UDT code,
1.UDT_EPOLL_ERR events are added as part of read, and write events.
// Sockets with exceptions are returned to both read and write sets.
if ((NULL != readfds) && (!p->second.m_sUDTReads.empty() || !p-second.m_sUDTExcepts.empty()))
{
readfds = p->second.m_sUDTReads;
for (set<UDTSOCKET>::const_iterator i = p->second.m_sUDTExcepts.begin(); i != p->second.m_sUDTExcepts.end(); ++ i)
readfds->insert(i);
total += p->second.m_sUDTReads.size() + p->second.m_sUDTExcepts.size();
p->second.m_sUDTExcepts.clear(); // added fix
}
if ((NULL != writefds) && (!p->second.m_sUDTWrites.empty() || !p->second.m_sUDTExcepts.empty()))
{
writefds = p->second.m_sUDTWrites;
for (set<UDTSOCKET>::const_iterator i = p->second.m_sUDTExcepts.begin(); i != p->second.m_sUDTExcepts.end(); ++ i)
writefds->insert(i);
total += p->second.m_sUDTWrites.size() + p->second.m_sUDTExcepts.size();
p->second.m_sUDTExcepts.clear(); // added fix
}
2.In CUDT::Close() function, UDT is removing usock fd from epoll monitoring. So, epoll_wait is not getting any exception event // Comment the below code to add fix
// then remove itself from all epoll monitoring
try
{
for (set<int>::iterator i = m_sPollID.begin(); i != m_sPollID.end(); ++ i)
s_UDTUnited.m_EPoll.remove_usock(*i, m_SocketID);
}
catch (...)
{
}
3.while adding usock fd to epoll_monitoring, UDT is not adding usock fd to UDT_EPOLL_ERR event.
int CEPoll::add_usock(const int eid, const UDTSOCKET& u, const int* events)
{
CGuard pg(m_EPollLock);
map<int, CEPollDesc="">::iterator p = m_mPolls.find(eid);
if (p == m_mPolls.end())
throw CUDTException(5, 13);
if (!events || (events & UDT_EPOLL_IN))
p->second.m_sUDTSocksIn.insert(u);
if (!events || (events & UDT_EPOLL_OUT))
p->second.m_sUDTSocksOut.insert(u);
// added fix for getting session close event.
if (!events || (*events & UDT_EPOLL_ERR))
p->second.m_sUDTSocksEx.insert(u);
return 0;
}