[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Mar 28 05:14:40 UTC 2017


 wsd/DocumentBroker.cpp |    3 +++
 wsd/LOOLWSD.cpp        |   23 +++++++++++++----------
 wsd/LOOLWSD.hpp        |    2 ++
 3 files changed, 18 insertions(+), 10 deletions(-)

New commits:
commit 1a6f6e9a65559756ead5c61804744e520ea749d3
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Mar 27 21:46:16 2017 -0400

    wsd: trigger child and doc housekeeping upon terminating kit
    
    Change-Id: I7ffbadb40221c19b24fd172d1b9aabcaa8c581e5
    Reviewed-on: https://gerrit.libreoffice.org/35787
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 384e66cf..32f55aae 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1304,6 +1304,9 @@ void DocumentBroker::terminateChild(std::unique_lock<std::mutex>& lock, const st
     // Stop the polling thread.
     _poll->stop();
     _stop = true;
+
+    // Trigger cleanup.
+    LOOLWSD::triggerChildAndDocHousekeeping();
 }
 
 void DocumentBroker::closeDocument(const std::string& reason)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 4e2c923a..f8d6aa03 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1112,9 +1112,6 @@ bool LOOLWSD::checkAndRestoreForKit()
 
 void PrisonerPoll::wakeupHook()
 {
-    /// FIXME: we should do this less frequently
-    /// currently the prisoner poll wakes up quite
-    /// a lot.
     if (!LOOLWSD::checkAndRestoreForKit())
     {
         // No children have died.
@@ -1144,6 +1141,18 @@ void PrisonerPoll::wakeupHook()
 #endif
         }
     }
+
+    std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex, std::defer_lock);
+    if (docBrokersLock.try_lock())
+    {
+        cleanupDocBrokers();
+    }
+}
+
+void LOOLWSD::triggerChildAndDocHousekeeping()
+{
+    PrisonerPoll.wakeup();
+
 }
 
 bool LOOLWSD::createForKit()
@@ -2451,7 +2460,7 @@ int LOOLWSD::innerMain()
         UnitWSD::get().invokeTest();
 
         // This timeout affects the recovery time of prespawned children.
-        mainWait.poll(SocketPoll::DefaultPollTimeoutMs);
+        mainWait.poll(SocketPoll::DefaultPollTimeoutMs * 4);
 
         // Wake the prisoner poll to spawn some children, if necessary.
         PrisonerPoll.wakeup();
@@ -2462,12 +2471,6 @@ int LOOLWSD::innerMain()
             UnitWSD::get().getTimeoutMilliSeconds())
             UnitWSD::get().timeout();
 
-        std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex, std::defer_lock);
-        if (docBrokersLock.try_lock())
-        {
-            cleanupDocBrokers();
-        }
-
 #if ENABLE_DEBUG
         if (careerSpanSeconds > 0 && time(nullptr) > startTimeSpan + careerSpanSeconds)
         {
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 2461a0d5..d20314c1 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -99,6 +99,8 @@ public:
     /// Return true when successfull.
     static bool createForKit();
 
+    static void triggerChildAndDocHousekeeping();
+
 protected:
     void initialize(Poco::Util::Application& self) override;
     void defineOptions(Poco::Util::OptionSet& options) override;


More information about the Libreoffice-commits mailing list