diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2017-04-06 17:58:41 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2017-04-06 17:58:41 +0100 |
commit | 2e372b70b32d4e052458547daa229c537442774f (patch) | |
tree | 54f5b2f581d7f9b8482e412d67326a4c0f153751 | |
parent | fb4fbdd575d6971c92a5222da1fe245f5791bd78 (diff) |
Let the DocBroker thread clean itself up and expire.private/mmeeks/fixing
-rw-r--r-- | wsd/DocumentBroker.cpp | 12 | ||||
-rw-r--r-- | wsd/DocumentBroker.hpp | 2 | ||||
-rw-r--r-- | wsd/LOOLWSD.cpp | 32 |
3 files changed, 20 insertions, 26 deletions
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index a5a995dfd..0ee997389 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -241,6 +241,18 @@ void DocumentBroker::pollThread() LOG_INF("No more sessions in doc [" << _docKey << "]. Terminating."); _stop = true; } + + // Remove idle documents after 1 hour. + const bool idle = getIdleTimeSecs() >= 3600; + + // Cleanup used and dead entries. + if ((isLoaded() || _markToDestroy) && + (getSessionsCount() == 0 || !isAlive() || idle)) + { + LOG_INF("Terminating " << (idle ? "idle" : "dead") << + " DocumentBroker for docKey [" << getDocKey() << "]."); + _stop = true; + } } LOG_INF("Finished polling doc [" << _docKey << "]. stop: " << _stop << ", continuePolling: " << diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index d05437e9c..fd8d20e80 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -304,7 +304,7 @@ public: void handleTileCombinedResponse(const std::vector<char>& payload); void destroyIfLastEditor(const std::string& id); - bool isMarkedToDestroy() const { return _markToDestroy; } + bool isMarkedToDestroy() const { return _markToDestroy || _stop; } bool handleInput(const std::vector<char>& payload); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index e5d4cb689..439ab67ed 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -235,33 +235,15 @@ void cleanupDocBrokers() { auto docBroker = it->second; - // If document busy at the moment, cleanup later. - auto lock = docBroker->getDeferredLock(); - if (lock.try_lock()) + // Remove only when not alive. + if (!docBroker->isAlive()) { - // Remove idle documents after 1 hour. - const bool idle = (docBroker->getIdleTimeSecs() >= 3600); - - // Cleanup used and dead entries. - if ((docBroker->isLoaded() || docBroker->isMarkedToDestroy()) && - (docBroker->getSessionsCount() == 0 || !docBroker->isAlive() || idle)) - { - LOG_INF("Terminating " << (idle ? "idle" : "dead") << - " DocumentBroker for docKey [" << it->first << "]."); - docBroker->stop(); - - // Remove only when not alive. - if (!docBroker->isAlive()) - { - LOG_INF("Removing " << (idle ? "idle" : "dead") << - " DocumentBroker for docKey [" << it->first << "]."); - it = DocBrokers.erase(it); - continue; - } - } + LOG_INF("Removing DocumentBroker for docKey [" << it->first << "]."); + it = DocBrokers.erase(it); + continue; + } else { + ++it; } - - ++it; } if (count != DocBrokers.size()) |