wsd/LOOLWSD.cpp |   58 ++++++++++++++++++++++++++++----------------------------
 wsd/LOOLWSD.hpp |    4 +++
 2 files changed, 33 insertions(+), 29 deletions(-)

New commits:
commit 4d9d769d950e6555de4392fb10c82efa53002611
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Mon Mar 16 16:19:37 2020 +0000
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Mon Mar 16 19:36:42 2020 +0100

    Expose disk space and session checks via LOOLWSD class.
    
    Change-Id: I7b135d325147694cc33946b34a29ab96b2e2b918
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90577
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index ecceaca34..177360dbc 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -256,8 +256,31 @@ inline void shutdownLimitReached(const 
std::shared_ptr<ProtocolHandlerInterface>
 }
 #endif
 
-inline void checkSessionLimitsAndWarnClients()
+#if !MOBILEAPP
+/// Internal implementation to alert all clients
+/// connected to any document.
+void alertAllUsersInternal(const std::string& msg)
+{
+    std::lock_guard<std::mutex> docBrokersLock(DocBrokersMutex);
+
+    LOG_INF("Alerting all users: [" << msg << "]");
+
+    if (UnitWSD::get().filterAlertAllusers(msg))
+        return;
+
+    for (auto& brokerIt : DocBrokers)
+    {
+        std::shared_ptr<DocumentBroker> docBroker = brokerIt.second;
+        docBroker->addCallback([msg, docBroker](){ 
docBroker->alertAllUsers(msg); });
+    }
+}
+#endif
+
+} // end anonymous namespace
+
+void LOOLWSD::checkSessionLimitsAndWarnClients()
 {
+#if !ENABLE_SUPPORT_KEY
 #if !MOBILEAPP
     ssize_t docBrokerCount = DocBrokers.size() - 
ConvertToBroker::getInstanceCount();
     if (LOOLWSD::MaxDocuments < 10000 &&
@@ -276,29 +299,10 @@ inline void checkSessionLimitsAndWarnClients()
         }
     }
 #endif
-}
-
-#if !MOBILEAPP
-/// Internal implementation to alert all clients
-/// connected to any document.
-void alertAllUsersInternal(const std::string& msg)
-{
-    std::lock_guard<std::mutex> docBrokersLock(DocBrokersMutex);
-
-    LOG_INF("Alerting all users: [" << msg << "]");
-
-    if (UnitWSD::get().filterAlertAllusers(msg))
-        return;
-
-    for (auto& brokerIt : DocBrokers)
-    {
-        std::shared_ptr<DocumentBroker> docBroker = brokerIt.second;
-        docBroker->addCallback([msg, docBroker](){ 
docBroker->alertAllUsers(msg); });
-    }
-}
 #endif
+}
 
-static void checkDiskSpaceAndWarnClients(const bool cacheLastCheck)
+void LOOLWSD::checkDiskSpaceAndWarnClients(const bool cacheLastCheck)
 {
 #if !MOBILEAPP
     try
@@ -317,8 +321,6 @@ static void checkDiskSpaceAndWarnClients(const bool 
cacheLastCheck)
 #endif
 }
 
-}
-
 /// Remove dead and idle DocBrokers.
 /// The client of idle document should've greyed-out long ago.
 /// Returns true if at least one is removed.
@@ -378,7 +380,7 @@ static int forkChildren(const int number)
 
     if (number > 0)
     {
-        checkDiskSpaceAndWarnClients(false);
+        LOOLWSD::checkDiskSpaceAndWarnClients(false);
 
 #ifdef KIT_IN_PROCESS
         forkLibreOfficeKit(LOOLWSD::ChildRoot, LOOLWSD::SysTemplate, 
LOOLWSD::LoTemplate, LO_JAIL_SUBPATH, number);
@@ -2874,12 +2876,10 @@ private:
                                 // Add and load the session.
                                 docBroker->addSession(clientSession);
 
-                                checkDiskSpaceAndWarnClients(true);
-#if !ENABLE_SUPPORT_KEY
+                                LOOLWSD::checkDiskSpaceAndWarnClients(true);
                                 // Users of development versions get just an 
info
                                 // when reaching max documents or connections
-                                checkSessionLimitsAndWarnClients();
-#endif
+                                LOOLWSD::checkSessionLimitsAndWarnClients();
                             }
                             catch (const UnauthorizedRequestException& exc)
                             {
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 166de2817..383263314 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -191,6 +191,10 @@ public:
     /// child kit processes and cleans up DocBrokers.
     static void doHousekeeping();
 
+    static void checkDiskSpaceAndWarnClients(const bool cacheLastCheck);
+
+    static void checkSessionLimitsAndWarnClients();
+
     /// Close document with @docKey and a @message
     static void closeDocument(const std::string& docKey, const std::string& 
message);
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to