summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2016-02-22 16:56:13 +0100
committerFlorent Le Coz <louiz@louiz.org>2016-02-22 17:03:15 +0100
commit6ee80ad26858eeee9a99b448320025ca439eee55 (patch)
tree3c56f025fdcecfb2b5d2c4d298e917b805be7c85
parent4cd97f7e88e31103f224d28cee84e78b7a35c2e7 (diff)
downloadbiboumi-6ee80ad26858eeee9a99b448320025ca439eee55.tar.gz
biboumi-6ee80ad26858eeee9a99b448320025ca439eee55.tar.bz2
biboumi-6ee80ad26858eeee9a99b448320025ca439eee55.tar.xz
biboumi-6ee80ad26858eeee9a99b448320025ca439eee55.zip
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.
-rw-r--r--louloulibs/network/poller.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/louloulibs/network/poller.cpp b/louloulibs/network/poller.cpp
index 329e1c8..50e9806 100644
--- a/louloulibs/network/poller.cpp
+++ b/louloulibs/network/poller.cpp
@@ -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