[Libreoffice-commits] online.git: 2 commits - loolwsd/LOOLWSD.cpp loolwsd/test

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun Oct 23 21:14:34 UTC 2016


 loolwsd/LOOLWSD.cpp          |   21 ++++++++++++++++++++-
 loolwsd/test/httpwserror.cpp |    8 +++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

New commits:
commit 30df646311db4a4a273486431f96caf0a18fd89a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 23 13:42:56 2016 -0400

    loolwsd: check for termination flag before loading new documents
    
    Change-Id: I4b7117ba255dd81f28ed1279814048e4311c2473
    Reviewed-on: https://gerrit.libreoffice.org/30211
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index df8a417..6694f81 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -667,6 +667,12 @@ private:
         {
             std::unique_lock<std::mutex> DocBrokersLock(DocBrokersMutex);
 
+            if (TerminationFlag)
+            {
+                Log::error("Termination flag set. No loading new session [" + id + "]");
+                return;
+            }
+
             // Lookup this document.
             auto it = DocBrokers.find(docKey);
             if (it != DocBrokers.end())
@@ -719,6 +725,12 @@ private:
                     timedOut = false;
                     break;
                 }
+
+                if (TerminationFlag)
+                {
+                    Log::error("Termination flag set. No loading new session [" + id + "]");
+                    return;
+                }
             }
 
             if (timedOut)
@@ -728,6 +740,12 @@ private:
             }
         }
 
+        if (TerminationFlag)
+        {
+            Log::error("Termination flag set. No loading new session [" + id + "]");
+            return;
+        }
+
         bool newDoc = false;
         if (!docBroker)
         {
commit 0287d7141df581805ecab863c719e27f9f60cab8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 23 13:42:20 2016 -0400

    loolwsd: logs around testMaxConnections
    
    Change-Id: I0f9dc957fb95d501626e321b4e15472d077c0301
    Reviewed-on: https://gerrit.libreoffice.org/30210
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index a526829..df8a417 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -979,7 +979,8 @@ public:
         if (++LOOLWSD::NumConnections > MAX_CONNECTIONS)
         {
             --LOOLWSD::NumConnections;
-            Log::error("Maximum number of connections reached.");
+            Log::error() << "Limit on maximum number of connections of "
+                         << MAX_CONNECTIONS << " reached." << Log::end;
             // accept hand shake
             WebSocket ws(request, response);
             shutdownLimitReached(ws);
diff --git a/loolwsd/test/httpwserror.cpp b/loolwsd/test/httpwserror.cpp
index 1e35593..011806b 100644
--- a/loolwsd/test/httpwserror.cpp
+++ b/loolwsd/test/httpwserror.cpp
@@ -140,22 +140,28 @@ void HTTPWSError::testMaxConnections()
     const auto testname = "maxConnections ";
     try
     {
+        std::cerr << "Opening max number of connections: " << MAX_CONNECTIONS << std::endl;
+
         // Load a document.
         std::string docPath;
         std::string docURL;
-        std::vector<std::shared_ptr<Poco::Net::WebSocket>> views;
 
         getDocumentPathAndURL("empty.odt", docPath, docURL);
         Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, docURL);
         auto socket = loadDocAndGetSocket(_uri, docURL, testname);
+        std::cerr << "Opened connect #1 of " << MAX_CONNECTIONS << std::endl;
 
+        std::vector<std::shared_ptr<Poco::Net::WebSocket>> views;
         for(int it = 1; it < MAX_CONNECTIONS; it++)
         {
             std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(_uri));
             auto ws = std::make_shared<Poco::Net::WebSocket>(*session, request, _response);
             views.emplace_back(ws);
+            std::cerr << "Opened connect #" << (it+1) << " of " << MAX_CONNECTIONS << std::endl;
         }
 
+        std::cerr << "Opening one more connection beyond the limit." << std::endl;
+
         // try to connect MAX_CONNECTIONS + 1
         std::unique_ptr<Poco::Net::HTTPClientSession> session(createSession(_uri));
         Poco::Net::WebSocket socketN(*session, request, _response);


More information about the Libreoffice-commits mailing list