[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - wsd/Admin.cpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
Pranav Kant
pranavk at collabora.co.uk
Tue Jul 11 13:24:14 UTC 2017
wsd/Admin.cpp | 9 +++++++++
wsd/LOOLWSD.cpp | 13 +++++++++++++
wsd/LOOLWSD.hpp | 3 +++
3 files changed, 25 insertions(+)
New commits:
commit 7fe79d2e1f5a39711211c2d799b83aa26f996d3b
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Mon Jul 10 22:45:04 2017 +0530
Save unsaved documents when memory consumption is high
These saved documents are then removed to free some memory when next
memory cleanup is triggered in the admin loop.
Change-Id: Ia789a65dc204b546f1d3627a8006c4590bdca371
(cherry picked from commit 160c1f555a12f53c0cd6e3f7994bf2d62ed49230)
Reviewed-on: https://gerrit.libreoffice.org/39818
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 2fd79584..08d3916f 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -467,6 +467,15 @@ void Admin::triggerMemoryCleanup(size_t totalMem)
else
++docIt;
}
+
+ // Save unsaved documents
+ docIt = docList.begin();
+ while (docIt != docList.end() && memToFree > 0)
+ {
+ LOG_TRC("Saving document: DocKey[" << docIt->_docKey << "].");
+ LOOLWSD::autoSave(docIt->_docKey);
+ ++docIt;
+ }
}
LOG_TRC("OOM: Memory to free percentage : " << memToFreePercentage);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 500f786a..e8347e9a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1109,6 +1109,19 @@ void LOOLWSD::closeDocument(const std::string& docKey, const std::string& messag
}
}
+void LOOLWSD::autoSave(const std::string& docKey)
+{
+ std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
+ auto docBrokerIt = DocBrokers.find(docKey);
+ if (docBrokerIt != DocBrokers.end())
+ {
+ std::shared_ptr<DocumentBroker> docBroker = docBrokerIt->second;
+ docBroker->addCallback([docBroker]() {
+ docBroker->autoSave(true);
+ });
+ }
+}
+
/// Really do the house-keeping
void PrisonerPoll::wakeupHook()
{
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index c26d6858..7ed29e15 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -124,6 +124,9 @@ public:
/// Close document with @docKey and a @message
static void closeDocument(const std::string& docKey, const std::string& message);
+ /// Autosave a given document
+ static void autoSave(const std::string& docKey);
+
protected:
void initialize(Poco::Util::Application& self) override;
void defineOptions(Poco::Util::OptionSet& options) override;
More information about the Libreoffice-commits
mailing list