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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon Jan 16 02:10:38 UTC 2017


 wsd/LOOLWSD.cpp |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

New commits:
commit 818329d66eadf38f99baa5d3dcc57d28f473483a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Jan 15 12:41:45 2017 -0500

    wsd: update outstanding forks only on successfull write
    
    Change-Id: I312b3f860d98a31e8a28742915df32eb7e737037
    Reviewed-on: https://gerrit.libreoffice.org/33131
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e7d4ee7..47a2fdc 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -324,11 +324,12 @@ static bool forkChildren(const int number)
 
         const std::string aMessage = "spawn " + std::to_string(number) + "\n";
         LOG_DBG("MasterToForKit: " << aMessage.substr(0, aMessage.length() - 1));
-
-        OutstandingForks += number;
-        IoUtil::writeToPipe(LOOLWSD::ForKitWritePipe, aMessage);
-        LastForkRequestTime = std::chrono::steady_clock::now();
-        return true;
+        if (IoUtil::writeToPipe(LOOLWSD::ForKitWritePipe, aMessage) > 0)
+        {
+            OutstandingForks += number;
+            LastForkRequestTime = std::chrono::steady_clock::now();
+            return true;
+        }
     }
 
     return false;
@@ -367,10 +368,12 @@ static bool rebalanceChildren(int balance)
 
     const auto duration = (std::chrono::steady_clock::now() - LastForkRequestTime);
     const auto durationMs = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
-    if (durationMs >= CHILD_TIMEOUT_MS)
+    if (OutstandingForks > 0 && durationMs >= CHILD_TIMEOUT_MS)
     {
         // Children taking too long to spawn.
         // Forget we had requested any, and request anew.
+        LOG_WRN("ForKit not responsive for " << durationMs << " ms forking " <<
+                OutstandingForks << " children. Resetting.");
         OutstandingForks = 0;
     }
 
@@ -381,8 +384,8 @@ static bool rebalanceChildren(int balance)
     if (balance > 0 && (rebalance || OutstandingForks == 0))
     {
         LOG_DBG("prespawnChildren: Have " << available << " spare " <<
-                (available == 1 ? "child" : "children") <<
-                ", forking " << balance << " more.");
+                (available == 1 ? "child" : "children") << ", and " <<
+                OutstandingForks << " outstanding, forking " << balance << " more.");
         return forkChildren(balance);
     }
 


More information about the Libreoffice-commits mailing list