Fix the ordering of poll callbacks (recv, connect, send)
Because if we have a send event to signal the connection sucess + a recv event to signal something to read on the socket, we need to first finish the connect process before reading the available data. That’s what we do now.
This commit is contained in:
1 parent
4cd97f7e88
commit
6ee80ad268
1 file changed
+4
-7
@@ -205,15 +205,12 @@ int Poller::poll(const std::chrono::milliseconds& timeout)
|
||||
for (int i = 0; i < nb_events; ++i)
|
||||
{
|
||||
auto socket_handler = static_cast<SocketHandler*>(revents[i].data.ptr);
|
||||
if (revents[i].events & EPOLLIN)
|
||||
if (revents[i].events & EPOLLIN && socket_handler->is_connected())
|
||||
socket_handler->on_recv();
|
||||
else if (revents[i].events & EPOLLOUT && socket_handler->is_connected())
|
||||
socket_handler->on_send();
|
||||
else if (revents[i].events & EPOLLOUT)
|
||||
{
|
||||
if (socket_handler->is_connected())
|
||||
socket_handler->on_send();
|
||||
else
|
||||
socket_handler->connect();
|
||||
}
|
||||
socket_handler->connect();
|
||||
}
|
||||
return nb_events;
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user