[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
Michael Meeks
michael.meeks at collabora.com
Thu Apr 6 17:54:10 UTC 2017
wsd/DocumentBroker.cpp | 12 ++++++++++++
wsd/DocumentBroker.hpp | 2 +-
wsd/LOOLWSD.cpp | 32 +++++++-------------------------
3 files changed, 20 insertions(+), 26 deletions(-)
New commits:
commit 90127ac0e3e7d4dd90e3143c7b310249c274c1a9
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Thu Apr 6 17:58:41 2017 +0100
Let the DocBroker thread clean itself up and expire.
(cherry picked from commit 2e372b70b32d4e052458547daa229c537442774f)
Change-Id: I5835c83f44ef770fa6ccd2418fc6ca73e17694e4
Reviewed-on: https://gerrit.libreoffice.org/36225
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a5a995df..0ee99738 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 d05437e9..fd8d20e8 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 e5d4cb68..439ab67e 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())
More information about the Libreoffice-commits
mailing list