common/SigUtil.cpp | 7 ++++--- common/SigUtil.hpp | 8 ++++++++ kit/ForKit.cpp | 2 +- kit/Kit.cpp | 9 ++++++--- wsd/LOOLWSD.cpp | 6 +++--- 5 files changed, 22 insertions(+), 10 deletions(-)
New commits: commit f40e05de42513a0abf8f459cf9ece9288225d11d Author: Tor Lillqvist <[email protected]> AuthorDate: Mon Oct 15 16:23:25 2018 +0300 Commit: Tor Lillqvist <[email protected]> CommitDate: Mon Oct 15 16:33:54 2018 +0300 It's enough to document a variable in one place Let's not have slightly different documentation for the same variables in the SigUtil.hpp and SigUtil.cpp files. That is just silly. diff --git a/common/SigUtil.cpp b/common/SigUtil.cpp index 58baaafdf..77ed8e296 100644 --- a/common/SigUtil.cpp +++ b/common/SigUtil.cpp @@ -36,13 +36,10 @@ #include "Common.hpp" #include "Log.hpp" -/// Flag to request hard termination. std::atomic<bool> TerminationFlag(false); -/// Flag to request dumping of all internal state std::atomic<bool> DumpGlobalState(false); #ifndef MOBILEAPP -/// Flag to request WSD to notify clients and shutdown. std::atomic<bool> ShutdownRequestFlag(false); std::mutex SigHandlerTrap; commit e9acbe175df926d23c25d9b335a37cf0f43e5cf0 Author: Tor Lillqvist <[email protected]> AuthorDate: Mon Oct 15 16:01:15 2018 +0300 Commit: Tor Lillqvist <[email protected]> CommitDate: Mon Oct 15 16:33:54 2018 +0300 ShutdownRequestFlag can be a constant false in the mobile app We don't have any user-generated signals to handle by shutting down in an app. One less thing to worry about. Now it's just the global TerminationFlag that is problematic when the code runs in just one process. diff --git a/common/SigUtil.cpp b/common/SigUtil.cpp index 8274d1967..58baaafdf 100644 --- a/common/SigUtil.cpp +++ b/common/SigUtil.cpp @@ -40,6 +40,8 @@ std::atomic<bool> TerminationFlag(false); /// Flag to request dumping of all internal state std::atomic<bool> DumpGlobalState(false); + +#ifndef MOBILEAPP /// Flag to request WSD to notify clients and shutdown. std::atomic<bool> ShutdownRequestFlag(false); @@ -311,4 +313,6 @@ namespace SigUtil } } +#endif // !MOBILEAPP + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/common/SigUtil.hpp b/common/SigUtil.hpp index 7cc8f6d71..1bffbde47 100644 --- a/common/SigUtil.hpp +++ b/common/SigUtil.hpp @@ -13,8 +13,12 @@ #include <atomic> #include <mutex> +#ifndef MOBILEAPP /// Flag to commence clean shutdown extern std::atomic<bool> ShutdownRequestFlag; +#else +static constexpr bool ShutdownRequestFlag(false); +#endif /// Flag to stop pump loops. extern std::atomic<bool> TerminationFlag; @@ -22,6 +26,8 @@ extern std::atomic<bool> TerminationFlag; /// Flag to dump internal state extern std::atomic<bool> DumpGlobalState; +#ifndef MOBILEAPP + /// Mutex to trap signal handler, if any, /// and prevent _Exit while collecting backtrace. extern std::mutex SigHandlerTrap; @@ -61,6 +67,8 @@ namespace SigUtil } // end namespace SigUtil +#endif // !MOBILEAPP + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 22c36171d..fa7d16eac 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -2863,7 +2863,7 @@ bool LOOLWSD::handleShutdownRequest() int LOOLWSD::innerMain() { -#ifndef FUZZER +#if !defined FUZZER && !defined MOBILEAPP SigUtil::setUserSignals(); SigUtil::setFatalSignals(); SigUtil::setTerminationSignals(); commit 8ead4af199ed7b4fbc176166e2a188919cd88d10 Author: Tor Lillqvist <[email protected]> AuthorDate: Mon Oct 15 15:32:17 2018 +0300 Commit: Tor Lillqvist <[email protected]> CommitDate: Mon Oct 15 15:36:51 2018 +0300 Say "TerminationFlag" in logging when that is what we mean We already did in other places. diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp index 8d373ee6a..183f1e196 100644 --- a/kit/ForKit.cpp +++ b/kit/ForKit.cpp @@ -85,7 +85,7 @@ public: { if (TerminationFlag) { - LOG_INF("Poll interrupted in " << getName() << " and Termination flag set."); + LOG_INF("Poll interrupted in " << getName() << " and TerminationFlag is set."); } // Break. diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 2384b61e7..e726055dc 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -2126,7 +2126,7 @@ protected: void onDisconnect() override { - LOG_WRN("Kit connection lost without exit arriving from wsd"); + LOG_WRN("Kit connection lost without exit arriving from wsd. Setting TerminationFlag"); TerminationFlag = true; } }; @@ -2433,7 +2433,7 @@ void lokit_main( if (document && document->purgeSessions() == 0) { - LOG_INF("Last session discarded. Terminating."); + LOG_INF("Last session discarded. Setting TerminationFlag"); TerminationFlag = true; } } diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 1a92a99e2..22c36171d 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1570,7 +1570,7 @@ static std::shared_ptr<DocumentBroker> findOrCreateDocBroker(WebSocketHandler& w if (TerminationFlag) { - LOG_ERR("Termination flag set. No loading new session [" << id << "]"); + LOG_ERR("TerminationFlag set. Not loading new session [" << id << "]"); return nullptr; } @@ -1600,7 +1600,7 @@ static std::shared_ptr<DocumentBroker> findOrCreateDocBroker(WebSocketHandler& w if (TerminationFlag) { - LOG_ERR("Termination flag set. No loading new session [" << id << "]"); + LOG_ERR("TerminationFlag is set. Not loading new session [" << id << "]"); return nullptr; } commit 7073d4feca1807f7d2b413e1f2d87cc89af95750 Author: Tor Lillqvist <[email protected]> AuthorDate: Mon Oct 15 15:29:50 2018 +0300 Commit: Tor Lillqvist <[email protected]> CommitDate: Mon Oct 15 15:36:51 2018 +0300 Don't call std::_Exit() in the mobile app Instead we should just exit the thread(s) that serve the document that was being edited, and the app should return to showing the document browser. (Or whatever we eventually will have as its state when the user is not editing or viewing a document.) Work in progress. diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 63d9f6b24..2384b61e7 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -897,11 +897,13 @@ public: } num_sessions = _sessions.size(); +#ifndef MOBILEAPP if (num_sessions == 0) { LOG_INF("Document [" << _url << "] has no more views, exiting bluntly."); std::_Exit(Application::EXIT_OK); } +#endif } // Don't destroy sessions while holding our lock. @@ -1375,12 +1377,13 @@ private: if (viewCount == 1) { std::unique_lock<std::mutex> lock(_mutex); +#ifndef MOBILEAPP if (_sessions.empty()) { LOG_INF("Document [" << _url << "] has no more views, exiting bluntly."); std::_Exit(Application::EXIT_OK); } - +#endif LOG_INF("Document [" << _url << "] has no more views, but has " << _sessions.size() << " sessions still. Destroying the document."); _loKitDocument.reset(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
