[Libreoffice-commits] online.git: common/SigUtil.cpp common/SigUtil.hpp kit/ForKit.cpp wsd/LOOLWSD.cpp
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jul 14 15:28:51 UTC 2020
common/SigUtil.cpp | 17 +++++++++--------
common/SigUtil.hpp | 9 ++++-----
kit/ForKit.cpp | 31 +++++++++++++++++++++++++++++++
wsd/LOOLWSD.cpp | 8 +-------
4 files changed, 45 insertions(+), 20 deletions(-)
New commits:
commit 6ca6a7649eff18e3e48bfe97c3cafcf41fb16363
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Jul 14 15:20:05 2020 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Jul 14 17:28:32 2020 +0200
Forkit: add dump_forkit_state and re-factor state checks to simplify.
Change-Id: Ic65bbd0894f26f69e1b55c769ac47013f9aaf163
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98746
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/common/SigUtil.cpp b/common/SigUtil.cpp
index 2bc3d5aa7..f768005c6 100644
--- a/common/SigUtil.cpp
+++ b/common/SigUtil.cpp
@@ -66,17 +66,18 @@ namespace SigUtil
}
#endif
-#if !MOBILEAPP
- bool getDumpGlobalState()
+ void checkDumpGlobalState(GlobalDumpStateFn dumpState)
{
- return DumpGlobalState;
- }
-
- void resetDumpGlobalState()
- {
- DumpGlobalState = false;
+#if !MOBILEAPP
+ if (DumpGlobalState)
+ {
+ dumpState();
+ DumpGlobalState = false;
+ }
+#endif
}
+#if !MOBILEAPP
/// This traps the signal-handler so we don't _Exit
/// while dumping stack trace. It's re-entrant.
/// Used to safely increment and decrement the signal-handler trap.
diff --git a/common/SigUtil.hpp b/common/SigUtil.hpp
index 9cc5b69d4..9f8296426 100644
--- a/common/SigUtil.hpp
+++ b/common/SigUtil.hpp
@@ -46,12 +46,11 @@ namespace SigUtil
}
#endif
-#if !MOBILEAPP
- /// Get the flag to dump internal state.
- bool getDumpGlobalState();
- /// Reset the flag to dump internal state.
- void resetDumpGlobalState();
+ extern "C" { typedef void (*GlobalDumpStateFn)(void); }
+
+ void checkDumpGlobalState(GlobalDumpStateFn dumpState);
+#if !MOBILEAPP
/// Wait for the signal handler, if any,
/// and prevent _Exit while collecting backtrace.
void waitSigHandlerTrap();
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index 721670bd1..9daa93576 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -67,6 +67,33 @@ int ClientPortNumber = DEFAULT_CLIENT_PORT_NUMBER;
std::string MasterLocation;
#endif
+extern "C" { void dump_forkit_state(void); /* easy for gdb */ }
+
+#if !MOBILEAPP
+void dump_forkit_state()
+{
+ std::ostringstream oss;
+
+ oss << "Forkit: " << ForkCounter << " forks\n"
+ << " loglevel: " << LogLevel << "\n"
+ << " unit test: " << UnitTestLibrary << "\n"
+#ifndef KIT_IN_PROCESS
+ << " NoCapsForKit: " << NoCapsForKit << "\n"
+ << " NoSeccomp: " << NoSeccomp << "\n"
+# if ENABLE_DEBUG
+ << " SingleKit: " << SingleKit << "\n"
+# endif
+#endif
+ << " ClientPortNumber: " << ClientPortNumber << "\n"
+ << " MasterLocation: " << MasterLocation
+ << "\n";
+
+ const std::string msg = oss.str();
+ fprintf(stderr, "%s", msg.c_str());
+ LOG_TRC(msg);
+}
+#endif
+
class ServerWSHandler;
// We have a single thread and a single connection so we won't bother with
@@ -627,6 +654,8 @@ int main(int argc, char** argv)
mainPoll.insertNewUnixSocket(MasterLocation, FORKIT_URI, WSHandler);
#endif
+ SigUtil::setUserSignals();
+
LOG_INF("ForKit process is ready.");
while (!SigUtil::getTerminationFlag())
@@ -635,6 +664,8 @@ int main(int argc, char** argv)
mainPoll.poll(POLL_TIMEOUT_MICRO_S);
+ SigUtil::checkDumpGlobalState(dump_forkit_state);
+
#if ENABLE_DEBUG
if (!SingleKit)
#endif
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 9815e4158..cef10cc11 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3599,13 +3599,7 @@ private:
void wakeupHook() override
{
-#if !MOBILEAPP
- if (SigUtil::getDumpGlobalState())
- {
- dump_state();
- SigUtil::resetDumpGlobalState();
- }
-#endif
+ SigUtil::checkDumpGlobalState(dump_state);
}
};
/// This thread & poll accepts incoming connections.
More information about the Libreoffice-commits
mailing list