[Libreoffice-commits] online.git: kit/ForKit.cpp Makefile.am wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp

Henry Castro (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 6 12:38:11 UTC 2020


 Makefile.am     |   19 +++++++++++++++++++
 kit/ForKit.cpp  |   11 +++++++++++
 wsd/LOOLWSD.cpp |   25 +++++++++++++++++++++++++
 wsd/LOOLWSD.hpp |    3 +++
 4 files changed, 58 insertions(+)

New commits:
commit 7ba4e9dd2324534c729b053afcf7062f58ebed9a
Author:     Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Mar 4 15:38:17 2020 -0400
Commit:     Henry Castro <hcastro at collabora.com>
CommitDate: Fri Mar 6 13:37:53 2020 +0100

    wsd: debug: run the server with a single "lokit" process
    
    Sometimes it is very useful to have one "lokit" process,
    to focus on a 100% reproducible bug, and not worry
    that server pre-spawn several processes.
    
    Change-Id: I414a8145b53a0601a282cba9c245833f5d07f404
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89999
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Henry Castro <hcastro at collabora.com>

diff --git a/Makefile.am b/Makefile.am
index f183ad6ff..9d04569b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -331,6 +331,25 @@ run: all @JAILS_PATH@
 			  --o:admin_console.username=admin --o:admin_console.password=admin \
 			  --o:logging.file[@enable]=true --o:logging.level=trace
 
+if ENABLE_DEBUG
+run-one: all @JAILS_PATH@
+	@echo "Launching loolwsd"
+	@fc-cache "@LO_PATH@"/share/fonts/truetype
+	@cp $(abs_top_srcdir)/test/data/hello.odt $(abs_top_srcdir)/test/data/hello-world.odt
+	@cp $(abs_top_srcdir)/test/data/hello.ods $(abs_top_srcdir)/test/data/hello-world.ods
+	@cp $(abs_top_srcdir)/test/data/hello.odp $(abs_top_srcdir)/test/data/hello-world.odp
+	@echo
+	./loolwsd --o:sys_template_path="@SYSTEMPLATE_PATH@" \
+			  --o:security.capabilities="$(CAPABILITIES)" \
+			  --o:child_root_path="@JAILS_PATH@" --o:storage.filesystem[@allow]=true \
+			  --o:ssl.cert_file_path="$(abs_top_srcdir)/etc/cert.pem" \
+			  --o:ssl.key_file_path="$(abs_top_srcdir)/etc/key.pem" \
+			  --o:ssl.ca_file_path="$(abs_top_srcdir)/etc/ca-chain.cert.pem" \
+			  --o:admin_console.username=admin --o:admin_console.password=admin \
+			  --o:logging.file[@enable]=true --o:logging.level=trace \
+			  --singlekit
+endif
+
 sync-writer:
 	browser-sync start --config browsersync-config.js --startPath "loleaflet/96c23f663/loleaflet.html?file_path=file://$(abs_top_srcdir)/test/data/hello-world.odt"
 
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index 3af723a99..b1fe997a0 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -47,7 +47,11 @@ using Poco::Thread;
 #ifndef KIT_IN_PROCESS
 static bool NoCapsForKit = false;
 static bool NoSeccomp = false;
+#if ENABLE_DEBUG
+static bool SingleKit = false;
+#endif
 #endif
+
 static bool DisplayVersion = false;
 static std::string UnitTestLibrary;
 static std::string LogLevel;
@@ -462,6 +466,10 @@ int main(int argc, char** argv)
             eq = std::strchr(cmd, '=');
             UnitTestLibrary = std::string(eq+1);
         }
+        else if (std::strstr(cmd, "--singlekit") == cmd)
+        {
+            SingleKit = true;
+        }
 #endif
         // we are running in a lower-privilege mode - with no chroot
         else if (std::strstr(cmd, "--nocaps") == cmd)
@@ -550,6 +558,9 @@ int main(int argc, char** argv)
             break;
         }
 
+#if ENABLE_DEBUG
+        if (!SingleKit)
+#endif
         forkLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath);
     }
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8ff0564e3..6eaa05020 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -356,6 +356,13 @@ void cleanupDocBrokers()
 
             LOG_END(logger, true);
         }
+
+#if ENABLE_DEBUG
+        if (LOOLWSD::SingleKit && DocBrokers.size() == 0)
+        {
+            SigUtil::requestShutdown();
+        }
+#endif
     }
 }
 
@@ -702,6 +709,9 @@ std::atomic<int> LOOLWSD::ForKitProcId(-1);
 bool LOOLWSD::NoCapsForKit = false;
 bool LOOLWSD::NoSeccomp = false;
 bool LOOLWSD::AdminEnabled = true;
+#if ENABLE_DEBUG
+bool LOOLWSD::SingleKit = false;
+#endif
 #endif
 #ifdef FUZZER
 bool LOOLWSD::DummyLOK = false;
@@ -1361,6 +1371,10 @@ void LOOLWSD::defineOptions(OptionSet& optionSet)
                         .required(false)
                         .repeatable(false)
                         .argument("seconds"));
+
+    optionSet.addOption(Option("singlekit", "", "Spawn one libreoffice kit.")
+                        .required(false)
+                        .repeatable(false));
 #endif
 
 #ifdef FUZZER
@@ -1408,6 +1422,11 @@ void LOOLWSD::handleOption(const std::string& optionName,
         UnitTestLibrary = value;
     else if (optionName == "careerspan")
         careerSpanMs = std::stoi(value) * 1000; // Convert second to ms
+    else if (optionName == "singlekit")
+    {
+        SingleKit = true;
+        NumPreSpawnedChildren = 1;
+    }
 
     static const char* latencyMs = std::getenv("LOOL_DELAY_SOCKET_MS");
     if (latencyMs)
@@ -1560,6 +1579,7 @@ void PrisonerPoll::wakeupHook()
     LOG_TRC("PrisonerPoll - wakes up with " << NewChildren.size() <<
             " new children and " << DocBrokers.size() << " brokers and " <<
             OutstandingForks << " kits forking");
+
     if (!LOOLWSD::checkAndRestoreForKit())
     {
         // No children have died.
@@ -1644,6 +1664,11 @@ bool LOOLWSD::createForKit()
     if (NoSeccomp)
         args.push_back("--noseccomp");
 
+#if ENABLE_DEBUG
+    if (SingleKit)
+        args.push_back("--singlekit");
+#endif
+
 #ifdef STRACE_LOOLFORKIT
     std::string forKitPath = "strace";
 #else
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index b4e2b4306..166de2817 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -53,6 +53,9 @@ public:
     static bool NoCapsForKit;
     static bool NoSeccomp;
     static bool AdminEnabled;
+#if ENABLE_DEBUG
+    static bool SingleKit;
+#endif
 #endif
     static std::atomic<int> ForKitWritePipe;
     static std::atomic<int> ForKitProcId;


More information about the Libreoffice-commits mailing list