diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-07-14 15:20:05 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2020-07-14 17:28:32 +0200 |
commit | 6ca6a7649eff18e3e48bfe97c3cafcf41fb16363 (patch) | |
tree | 834693c9497c6bb023e59ef2b0da0cc522c0011e | |
parent | Pass rendered tiles as uncompressed BMP files in the iOS app (diff) | |
download | online-6ca6a7649eff18e3e48bfe97c3cafcf41fb16363.tar.gz online-6ca6a7649eff18e3e48bfe97c3cafcf41fb16363.zip |
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@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r-- | common/SigUtil.cpp | 17 | ||||
-rw-r--r-- | common/SigUtil.hpp | 9 | ||||
-rw-r--r-- | kit/ForKit.cpp | 31 | ||||
-rw-r--r-- | wsd/LOOLWSD.cpp | 8 |
4 files changed, 45 insertions, 20 deletions
diff --git a/common/SigUtil.cpp b/common/SigUtil.cpp index 2bc3d5aa77..f768005c6b 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 9cc5b69d49..9f8296426f 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 721670bd19..9daa935763 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 9815e41584..cef10cc113 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. |