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

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


 loolwsd/LOOLWSD.cpp |   35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

New commits:
commit cecb87dfe31669fc0c3802f160030856f21a3db0
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Oct 23 16:11:01 2016 -0400

    loolwsd: don't wait after autosaving to rebalance children
    
    Change-Id: Ifb44d0395e8f416e418711b09deed3eb7f57effa
    Reviewed-on: https://gerrit.libreoffice.org/30214
    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 e1c07cb..10b4e2f 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -2025,29 +2025,30 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
         }
         else // pid == 0, no children have died
         {
-            if (!std::getenv("LOOL_NO_AUTOSAVE"))
+            if (!std::getenv("LOOL_NO_AUTOSAVE") &&
+                (time(nullptr) >= last30SecCheck + 30))
             {
-                if (time(nullptr) >= last30SecCheck + 30)
+                try
                 {
-                    try
-                    {
-                        std::unique_lock<std::mutex> DocBrokersLock(DocBrokersMutex);
-                        cleanupDocBrokers();
-                        for (auto& brokerIt : DocBrokers)
-                        {
-                            brokerIt.second->autoSave(false, 0);
-                        }
-                    }
-                    catch (const std::exception& exc)
+                    std::unique_lock<std::mutex> DocBrokersLock(DocBrokersMutex);
+                    cleanupDocBrokers();
+                    for (auto& brokerIt : DocBrokers)
                     {
-                        Log::error("Exception: " + std::string(exc.what()));
+                        brokerIt.second->autoSave(false, 0);
                     }
-
-                    last30SecCheck = time(nullptr);
                 }
-            }
+                catch (const std::exception& exc)
+                {
+                    Log::error("Exception: " + std::string(exc.what()));
+                }
 
-            std::this_thread::sleep_for(std::chrono::milliseconds(CHILD_REBALANCE_INTERVAL_MS));
+                last30SecCheck = time(nullptr);
+            }
+            else
+            {
+                // Don't wait if we had been saving, which takes a while anyway.
+                std::this_thread::sleep_for(std::chrono::milliseconds(CHILD_REBALANCE_INTERVAL_MS));
+            }
 
             // Make sure we have sufficient reserves.
             prespawnChildren();


More information about the Libreoffice-commits mailing list