From 67ca668ff36577e70ca1a07564b8d6e81d9d6905 Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Fri, 8 Feb 2019 13:00:30 +0100 Subject: [PATCH] Poll bug, poll, should check the current number of fds, not the max --- lib/cpp_utils/Poll.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/cpp_utils/Poll.cpp b/lib/cpp_utils/Poll.cpp index 9202369..161946f 100644 --- a/lib/cpp_utils/Poll.cpp +++ b/lib/cpp_utils/Poll.cpp @@ -21,7 +21,11 @@ Poll::Poll( StreamConnection *connection, , m_num_of_fds(0) { TRACE; + + // We could initialize each .events = -1 so poll would skip them m_fds = new pollfd[m_maxclients+1]; // plus the server socket + + addFd( m_connection->getSocket(), POLLIN | POLLPRI ); } @@ -40,7 +44,7 @@ void Poll::startPolling() m_polling = true; while ( m_polling ) { - int ret = poll( m_fds , m_maxclients, m_timeOut); + int ret = poll( m_fds , m_num_of_fds, m_timeOut); if ( ret == -1 ) { LOG( Logger::ERR, errnoToString("ERROR polling. ").c_str() );