wsd/LOOLWSD.cpp |   52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

New commits:
commit 9b99f64772fe14a3cee09495fc99e0a7e03ad077
Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
Date:   Sun Jan 1 17:16:49 2017 -0500

    wsd: don't sleep after autosaving or spawning children
    
    Between waits on forkit we shouldn't spend too much time.
    This is to recover from forkit crashes.
    
    Now we first spawn children, and only when not successful
    (i.e. no more spare children needed) we check for autosave
    and DocBrokers cleanup. Only when none of the above is done
    do we sleep.
    
    This gives the best balance between forkit waits and reduces
    the unittests by a good 25 seconds (crash tests down from 34s
    to about 10s only).
    
    Change-Id: If69284746859bc78d14f1c6eda07aef4e006709e
    Reviewed-on: https://gerrit.libreoffice.org/32624
    Reviewed-by: Ashod Nakashian <ashnak...@gmail.com>
    Tested-by: Ashod Nakashian <ashnak...@gmail.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 34bc044..2c8b8d9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2163,8 +2163,13 @@ int LOOLWSD::main(const std::vector<std::string>& 
/*args*/)
         }
         else // pid == 0, no children have died
         {
-            if (!std::getenv("LOOL_NO_AUTOSAVE") &&
-                (time(nullptr) >= last30SecCheck + 30))
+            // Make sure we have sufficient reserves.
+            if (prespawnChildren(false))
+            {
+                // Nothing more to do this round.
+            }
+            else if (!std::getenv("LOOL_NO_AUTOSAVE") &&
+                     (time(nullptr) >= last30SecCheck + 30))
             {
                 try
                 {
@@ -2183,40 +2188,35 @@ int LOOLWSD::main(const std::vector<std::string>& 
/*args*/)
 
                 last30SecCheck = time(nullptr);
             }
-            else
+            else if (time(nullptr) >= lastOneHourCheck + 900) // Every 15 
minutes
             {
-                // Every 15 minutes
-                if (time(nullptr) >= lastOneHourCheck + 900)
+                // Bluntly close documents that have been idle over an hour. 
(By that time
+                // loleaflet's greying-out has already also kicked in.)
+                try
                 {
-                    // Bluntly close documents that have been idle over an 
hour. (By that time
-                    // loleaflet's greying-out has already also kicked in.)
-                    try
+                    std::unique_lock<std::mutex> 
docBrokersLock(DocBrokersMutex);
+                    for (auto& pair : DocBrokers)
                     {
-                        std::unique_lock<std::mutex> 
docBrokersLock(DocBrokersMutex);
-                        for (auto& pair : DocBrokers)
+                        auto docLock = pair.second->getLock();
+                        if (pair.second->getIdleTime() >= 3600)
                         {
-                            auto docLock = pair.second->getLock();
-                            if (pair.second->getIdleTime() >= 3600)
-                            {
-                                LOG_INF("Terminating idle document " + 
pair.second->getDocKey());
-                                pair.second->terminateChild(docLock);
-                            }
+                            LOG_INF("Terminating idle document " + 
pair.second->getDocKey());
+                            pair.second->terminateChild(docLock);
                         }
                     }
-                    catch (const std::exception& exc)
-                    {
-                        LOG_ERR("Exception: " << exc.what());
-                    }
-
-                    lastOneHourCheck = time(nullptr);
+                }
+                catch (const std::exception& exc)
+                {
+                    LOG_ERR("Exception: " << exc.what());
                 }
 
-                // Don't wait if we had been saving, which takes a while 
anyway.
+                lastOneHourCheck = time(nullptr);
+            }
+            else
+            {
+                // Wait if we had done no work.
                 
std::this_thread::sleep_for(std::chrono::milliseconds(CHILD_REBALANCE_INTERVAL_MS));
             }
-
-            // Make sure we have sufficient reserves.
-            prespawnChildren(false);
         }
 
 #if ENABLE_DEBUG
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to