Menu

#38 epoll mode can't get close event

v1.0_(example)
open
None
5
2015-02-10
2015-02-10
Hu Xiaolong
No

my application use udt's epoll mode, but i find that when one peer(client) close the udt connection, but the other peer(server) can't get the close event.
I review the source code(udt.sdk.4.11), found the reason is here(in CUDT::processCtrl):

case 5: //101 - Shutdown
m_bShutdown = true;
m_bClosing = true;
m_bBroken = true;
m_iBrokenCounter = 60;

// Signal the sender and recver if they are waiting for data. 
releaseSynch();

CTimer::triggerEvent();

break;

between releaseSynch and triggerEvent lost this code(copyed from CUDT::checkTimers):
s_UDTUnited.m_EPoll.update_events(m_SocketID, m_sPollID, UDT_EPOLL_IN | UDT_EPOLL_OUT | UDT_EPOLL_ERR, true);

I add the code and test ok!

These is another bug in epoll mode is i can't get udt epoll event when system socket close.
fix code(in CEPoll::wait) is here: add EPOLLERR mask

const int max_events = p->second.m_sLocals.size();
epoll_event ev[max_events];
int nfds = ::epoll_wait(p->second.m_iLocalID, ev, max_events, 0);

for (int i = 0; i < nfds; ++ i)
{
if ((NULL != lrfds) && (ev[i].events & (EPOLLIN | EPOLLERR)))
{
lrfds->insert(ev[i].data.fd);
++ total;
}
if ((NULL != lwfds) && (ev[i].events & (EPOLLOUT | EPOLLERR)))
{
lwfds->insert(ev[i].data.fd);
++ total;
}
}

Discussion


Log in to post a comment.