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

Pranav Kant pranavk at collabora.co.uk
Tue Oct 3 08:22:54 UTC 2017


 wsd/LOOLWSD.cpp |   30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

New commits:
commit 3008342c5752183bcd447cee5af7c4e947e9abb8
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Oct 3 13:45:29 2017 +0530

    Don't kill the process when debugging
    
    Assume that when SLEEPFORDEBUGGER or SLEEPKITFORDEBUGGER is mentioned,
    loolwsd is being debugged. In that case, don't set any timeout to exit
    before first child is forked.
    
    Change-Id: I2527f02187d8452ef6bebb70e1d750b5e796c4b6

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 377e890f..3d41d0c9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2595,18 +2595,28 @@ int LOOLWSD::innerMain()
 
 #ifndef KIT_IN_PROCESS
     {
+        // Make sure we have at least one child before moving forward.
         std::unique_lock<std::mutex> lock(NewChildrenMutex);
-
-        const auto timeoutMs = CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 150 : 10);
-        const auto timeout = std::chrono::milliseconds(timeoutMs);
-        // Make sure we have at least one before moving forward.
-        LOG_TRC("Waiting for a new child for a max of " << timeoutMs << " ms.");
-        if (!NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); }))
+        // If we are debugging, it's not uncommon to wait for several minutes before first
+        // child is born. Don't use an expiry timeout in that case.
+        const bool debugging = std::getenv("SLEEPFORDEBUGGER") || std::getenv("SLEEPKITFORDEBUGGER");
+        if (debugging)
+        {
+            LOG_DBG("Waiting for new child without timeout.");
+            NewChildrenCV.wait(lock, []() { return !NewChildren.empty(); });
+        }
+        else
         {
-            const auto msg = "Failed to fork child processes.";
-            LOG_FTL(msg);
-            std::cerr << "FATAL: " << msg << std::endl;
-            throw std::runtime_error(msg);
+            const auto timeoutMs = CHILD_TIMEOUT_MS * (LOOLWSD::NoCapsForKit ? 150 : 10);
+            const auto timeout = std::chrono::milliseconds(timeoutMs);
+            LOG_TRC("Waiting for a new child for a max of " << timeoutMs << " ms.");
+            if (!NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); }))
+            {
+                const auto msg = "Failed to fork child processes.";
+                LOG_FTL(msg);
+                std::cerr << "FATAL: " << msg << std::endl;
+                throw std::runtime_error(msg);
+            }
         }
 
         // Check we have at least one.


More information about the Libreoffice-commits mailing list