wsd/DocumentBroker.cpp | 8 +++++++- wsd/DocumentBroker.hpp | 3 +-- wsd/LOOLWSD.cpp | 15 ++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-)
New commits: commit 01519eff70f1157dbbb4cb329acc7754f34a2765 Author: Michael Meeks <michael.me...@collabora.com> Date: Wed Apr 5 21:31:15 2017 +0100 Always cleanup DocBrokers in the PrisonerPoll thread. This simplifies things, and keeps process management in one thread. Also - wakeup the DocumentBroker when we want to stop it. Change-Id: I597ba4b34719fc072a4b4ad3697442b5eebe5784 Reviewed-on: https://gerrit.libreoffice.org/36182 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 5a4de9e2..396bf52b 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -264,7 +264,7 @@ void DocumentBroker::pollThread() _poll->poll(std::min(flushTimeoutMs - elapsedMs, POLL_TIMEOUT_MS / 5)); } - // Cleanup. + // Async cleanup. LOOLWSD::doHousekeeping(); LOG_INF("Finished docBroker polling thread for docKey [" << _docKey << "]."); @@ -306,6 +306,12 @@ void DocumentBroker::joinThread() _poll->joinThread(); } +void DocumentBroker::stop() +{ + _stop = true; + _poll->wakeup(); +} + bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const std::string& jailId) { assertCorrectThread(); diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index 0af441ff..d05437e9 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -222,8 +222,7 @@ public: void startThread(); /// Flag for termination. - //TODO: Take reason to broadcast to clients. - void stop() { _stop = true; } + void stop(); /// Thread safe termination of this broker if it has a lingering thread void joinThread(); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 08a20ce7..e5d4cb68 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -226,7 +226,7 @@ void alertAllUsersInternal(const std::string& msg) /// Remove dead and idle DocBrokers. /// The client of idle document should've greyed-out long ago. /// Returns true if at least one is removed. -bool cleanupDocBrokers() +void cleanupDocBrokers() { Util::assertIsLocked(DocBrokersMutex); @@ -277,11 +277,7 @@ bool cleanupDocBrokers() LOG_END(logger); } - - return true; } - - return false; } /// Forks as many children as requested. @@ -582,7 +578,7 @@ class PrisonerPoll : public TerminatingPoll { public: PrisonerPoll() : TerminatingPoll("prisoner_poll") {} - /// Check prisoners are still alive and balaned. + /// Check prisoners are still alive and balanced. void wakeupHook() override; }; @@ -1099,12 +1095,13 @@ bool LOOLWSD::checkAndRestoreForKit() #endif } -void PrisonerPoll::wakeupHook() +void LOOLWSD::doHousekeeping() { - LOOLWSD::doHousekeeping(); + PrisonerPoll.wakeup(); } -void LOOLWSD::doHousekeeping() +/// Really do the house-keeping +void PrisonerPoll::wakeupHook() { if (!LOOLWSD::checkAndRestoreForKit()) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits