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

Henry Castro hcastro at collabora.com
Wed Sep 28 20:02:36 UTC 2016


 loolwsd/FileServer.cpp |    1 -
 loolwsd/LOOLWSD.cpp    |   24 ++++++++++++++----------
 2 files changed, 14 insertions(+), 11 deletions(-)

New commits:
commit fe2004a06fab4d5bf48a7c8ac0203648c3f29b4c
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Sep 28 16:01:53 2016 -0400

    loolwsd: rework bccu#2022, User warning on hitting limit

diff --git a/loolwsd/FileServer.cpp b/loolwsd/FileServer.cpp
index 3337c04..b140cb1 100644
--- a/loolwsd/FileServer.cpp
+++ b/loolwsd/FileServer.cpp
@@ -251,7 +251,6 @@ void FileServerRequestHandler::preprocessFile(HTTPServerRequest& request, HTTPSe
     Poco::replaceInPlace(preprocess, std::string("%ACCESS_TOKEN_TTL%"), accessTokenTtl);
     Poco::replaceInPlace(preprocess, std::string("%HOST%"), host);
     Poco::replaceInPlace(preprocess, std::string("%VERSION%"), std::string(LOOLWSD_VERSION_HASH));
-    Poco::replaceInPlace(preprocess, std::string("%CODE%"), Poco::format(LOOLWSD_CODE, MAX_SESSIONS, MAX_SESSIONS, std::string(LOOLWSD_PRODUCT), std::string(LOOLWSD_URL), std::string(LOOLWSD_URL)));
 
     response.setContentType("text/html");
     response.setContentLength(preprocess.length());
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 1c4d4a7..740e048 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -19,6 +19,11 @@
 /* Default document used in the start test URI */
 #define LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH "test/data/hello-world.odt"
 
+/* PRODUCT */
+#define LOOLWSD_PRODUCT "LibreOffice Online"
+
+/* PRODUCT URL */
+#define LOOLWSD_URL "https://wiki.documentfoundation.org/Development/LibreOffice_Online"
 
 // This is the main source for the loolwsd program. LOOL uses several loolwsd processes: one main
 // parent process that listens on the TCP port and accepts connections from LOOL clients, and a
@@ -533,6 +538,14 @@ private:
     {
         Log::info("Starting GET request handler for session [" + id + "].");
 
+#if MAX_CONNECTIONS > 0
+        if (++LOOLWSD::NumConnections > MAX_CONNECTIONS)
+        {
+            Log::error("Maximum number of connections reached.");
+            throw WebSocketErrorMessageException(Poco::format(SERVICE_UNAVALABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS, std::string(LOOLWSD_PRODUCT), std::string(LOOLWSD_URL), std::string(LOOLWSD_URL)));
+        }
+#endif
+
         // indicator to the client that document broker is searching
         std::string status("statusindicator: find");
         Log::trace("Sending to Client [" + status + "].");
@@ -634,7 +647,7 @@ private:
             {
                 --LOOLWSD::NumDocBrokers;
                 Log::error("Maximum number of open documents reached.");
-                throw WebSocketErrorMessageException(SERVICE_UNAVALABLE_LIMIT_REACHED);
+                throw WebSocketErrorMessageException(Poco::format(SERVICE_UNAVALABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS, std::string(LOOLWSD_PRODUCT), std::string(LOOLWSD_URL), std::string(LOOLWSD_URL)));
             }
 #endif
 
@@ -852,15 +865,6 @@ public:
                 request, response))
             return;
 
-#if MAX_CONNECTIONS > 0
-        if (++LOOLWSD::NumConnections > MAX_CONNECTIONS)
-        {
-            --LOOLWSD::NumConnections;
-            Log::error("Maximum number of connections reached.");
-            throw WebSocketErrorMessageException(SERVICE_UNAVALABLE_LIMIT_REACHED);
-        }
-#endif
-
         handleClientRequest(request,response);
 
 #if MAX_CONNECTIONS > 0


More information about the Libreoffice-commits mailing list