From 6b0ffb5fc2eca537e2cfaf24acb8a4d2ca9b99f1 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Mon, 26 May 2014 22:27:43 +0200 Subject: If both write and read events are available on a socket, only do the read Because the read handler may discover that the connection has been closed, and then remove the socket from the poller. It that case it is no longer valid to try to call the write handler (which may try to reconnect, but since that socket is no longer managed, this is not OK). --- src/network/poller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/poller.cpp b/src/network/poller.cpp index dbea856..708fe23 100644 --- a/src/network/poller.cpp +++ b/src/network/poller.cpp @@ -185,7 +185,7 @@ int Poller::poll(const std::chrono::milliseconds& timeout) auto socket_handler = static_cast(revents[i].data.ptr); if (revents[i].events & EPOLLIN) socket_handler->on_recv(); - if (revents[i].events & EPOLLOUT) + else if (revents[i].events & EPOLLOUT) { if (socket_handler->is_connected()) socket_handler->on_send(); -- cgit v1.2.3