[Libreoffice-commits] online.git: wsd/ClientSession.cpp wsd/LOOLWSD.cpp

Jan Holesovsky kendy at collabora.com
Thu Mar 16 10:34:11 UTC 2017


 wsd/ClientSession.cpp |    6 ++++--
 wsd/LOOLWSD.cpp       |   16 +---------------
 2 files changed, 5 insertions(+), 17 deletions(-)

New commits:
commit b384867b3fdf460b78917695b50d5ded8e99cc66
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Thu Mar 16 11:33:35 2017 +0100

    Fix limiting of the connections.
    
    Change-Id: I9ff0aec168fd971599248fee177bf51b134e3e58

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 5ca126d..459754d 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -39,7 +39,8 @@ ClientSession::ClientSession(const std::string& id,
     _isDocumentOwner(false),
     _stop(false)
 {
-    LOG_INF("ClientSession ctor [" << getName() << "].");
+    const size_t curConnections = ++LOOLWSD::NumConnections;
+    LOG_INF("ClientSession ctor [" << getName() << "], current number of connections: " << curConnections);
 }
 
 ClientSession::~ClientSession()
@@ -680,7 +681,8 @@ bool ClientSession::forwardToClient(const std::shared_ptr<Message>& payload)
 
 void ClientSession::onDisconnect()
 {
-    LOG_INF(getName() << " Disconnected.");
+    const size_t curConnections = --LOOLWSD::NumConnections;
+    LOG_INF(getName() << " Disconnected, current # of connections: " << curConnections);
 
     const auto docBroker = getDocumentBroker();
     LOG_CHECK_RET(docBroker && "Null DocumentBroker instance", );
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index be63345..9c5fb00 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1718,22 +1718,9 @@ private:
     void onConnect(const std::weak_ptr<StreamSocket>& socket) override
     {
         _id = LOOLWSD::GenSessionId();
-        _connectionNum = ++LOOLWSD::NumConnections;
-        LOG_TRC("Connected connection #" << _connectionNum << " of " <<
-                MAX_CONNECTIONS << " max as session [" << _id << "].");
-
         _socket = socket;
     }
 
-    void onDisconnect() override
-    {
-        // FIXME: Move to ClientSession (ideally, wrap in ConnectionCounter object
-        // to wrap this global NumConnections).
-        const size_t curConnections = --LOOLWSD::NumConnections;
-        LOG_TRC("Disconnected connection #" << _connectionNum << " (of " <<
-                (curConnections + 1) << ") as session [" << _id << "].");
-    }
-
     /// Called after successful socket reads.
     void handleIncomingMessage() override
     {
@@ -2215,7 +2202,7 @@ private:
         // First Upgrade.
         WebSocketHandler ws(_socket, request);
 
-        if (_connectionNum > MAX_CONNECTIONS)
+        if (LOOLWSD::NumConnections >= MAX_CONNECTIONS)
         {
             LOG_ERR("Limit on maximum number of connections of " << MAX_CONNECTIONS << " reached.");
             shutdownLimitReached(ws);
@@ -2279,7 +2266,6 @@ private:
     // The socket that owns us (we can't own it).
     std::weak_ptr<StreamSocket> _socket;
     std::string _id;
-    size_t _connectionNum;
 };
 
 


More information about the Libreoffice-commits mailing list