[Libreoffice-commits] online.git: Branch 'private/Ashod/nonblocking' - net/loolnb.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Feb 20 03:50:55 UTC 2017


 net/loolnb.cpp |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

New commits:
commit a6b7d9c9cec8a4fd2c93bf34c99c351ccf1baab2
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Feb 19 12:10:28 2017 -0500

    nb: server socket should accept only on POLLIN
    
    Change-Id: I50e9a7f78e51bbf7e42e3eafde6e32d6538f5657
    Reviewed-on: https://gerrit.libreoffice.org/34442
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/net/loolnb.cpp b/net/loolnb.cpp
index 52f048d..fd74964 100644
--- a/net/loolnb.cpp
+++ b/net/loolnb.cpp
@@ -365,18 +365,21 @@ public:
         return POLLIN;
     }
 
-    HandleResult handlePoll( int /* events */ ) override
+    HandleResult handlePoll( int events ) override
     {
-        std::shared_ptr<Socket> clientSocket = accept();
-        if (!clientSocket)
+        if (events & POLLIN)
         {
-            const std::string msg = "Failed to accept. (errno: ";
-            throw std::runtime_error(msg + std::strerror(errno) + ")");
+            std::shared_ptr<Socket> clientSocket = accept();
+            if (!clientSocket)
+            {
+                const std::string msg = "Failed to accept. (errno: ";
+                throw std::runtime_error(msg + std::strerror(errno) + ")");
+            }
+
+            std::cout << "Accepted client #" << clientSocket->getFD() << std::endl;
+            _clientPoller.insertNewSocket(clientSocket);
         }
 
-        std::cout << "Accepted client #" << clientSocket->getFD() << std::endl;
-        _clientPoller.insertNewSocket(clientSocket);
-
         return Socket::HandleResult::CONTINUE;
     }
 };


More information about the Libreoffice-commits mailing list