wsd/DocumentBroker.hpp | 1 + wsd/LOOLWSD.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
New commits: commit 7f19d809b16d17f669f6e15b3bf52db1c764a975 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri Feb 10 01:43:32 2017 -0500 wsd: skip busy docBrokers when cleaning up When cleaning up DocumentBrokers we hold the global DocBrokersMutex. So we need to keep this lock as short as possible to serve new requests. However when a given DocBroker is locked and busy, or worse deadlocked, we'd end up blocking any new client connection. So here we skip busy DocBrokers while cleaning up. Change-Id: I188c9abc34fd90c4ba388894b47c1ab08d185129 Reviewed-on: https://gerrit.libreoffice.org/34119 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp index a401b5a..2c0122d 100644 --- a/wsd/DocumentBroker.hpp +++ b/wsd/DocumentBroker.hpp @@ -312,6 +312,7 @@ public: Poco::Process::PID getPid() const { return _childProcess->getPid(); } std::unique_lock<std::mutex> getLock() { return std::unique_lock<std::mutex>(_mutex); } + std::unique_lock<std::mutex> getDeferredLock() { return std::unique_lock<std::mutex>(_mutex, std::defer_lock); } void updateLastActivityTime(); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 399a175..05cd665 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -281,7 +281,13 @@ bool cleanupDocBrokers() for (auto it = DocBrokers.begin(); it != DocBrokers.end(); ) { auto docBroker = it->second; - auto lock = docBroker->getLock(); + auto lock = docBroker->getDeferredLock(); + if (!lock.try_lock()) + { + // Document busy at the moment, cleanup later. + ++it; + continue; + } // Remove idle documents after 1 hour. const bool idle = (docBroker->getIdleTimeSecs() >= 3600); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits