[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/LOOLWSD.cpp loolwsd/MasterProcessSession.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Fri Apr 22 04:36:21 UTC 2016
loolwsd/DocumentBroker.cpp | 4 +++-
loolwsd/DocumentBroker.hpp | 3 +++
loolwsd/LOOLWSD.cpp | 5 ++++-
loolwsd/MasterProcessSession.cpp | 11 +++++++++++
4 files changed, 21 insertions(+), 2 deletions(-)
New commits:
commit bde67c99344751702116e3409d96b52db07b15e8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Fri Apr 22 00:11:24 2016 -0400
loolwsd: track document modified state to avoid unnecessary auto-saving
This also avoids the feedback loop that results from the kit
thinking the previously inactive client is now active and
sending commands (.uno:Save).
Change-Id: I47074b35a922da15592d550032d494ba1efab83e
Reviewed-on: https://gerrit.libreoffice.org/24287
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 10776b3..5a21bad 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -73,7 +73,8 @@ DocumentBroker::DocumentBroker(const Poco::URI& uriPublic,
_cacheRoot(getCachePath(uriPublic.toString())),
_lastSaveTime(std::chrono::steady_clock::now()),
_childProcess(childProcess),
- _markToDestroy(false)
+ _markToDestroy(false),
+ _isModified(false)
{
assert(!_docKey.empty());
assert(!_childRoot.empty());
@@ -153,6 +154,7 @@ bool DocumentBroker::save()
assert(_storage && _tileCache);
if (_storage->saveLocalFileToStorage())
{
+ _isModified = false;
_lastSaveTime = std::chrono::steady_clock::now();
_tileCache->documentSaved();
Log::debug("Saved to URI [" + uri + "] and updated tile cache.");
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 2a1e73d..b696a65 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -177,6 +177,8 @@ public:
// Called when the last view is going out.
bool canDestroy();
bool isMarkedToDestroy() const { return _markToDestroy; }
+ bool isModified() const { return _isModified; }
+ void setModified(const bool value) { _isModified = value; }
private:
const Poco::URI _uriPublic;
@@ -192,6 +194,7 @@ private:
std::unique_ptr<TileCache> _tileCache;
std::shared_ptr<ChildProcess> _childProcess;
bool _markToDestroy;
+ bool _isModified;
mutable std::mutex _mutex;
std::condition_variable _saveCV;
std::mutex _saveMutex;
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index e6886a4..6a377fc 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1594,7 +1594,10 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
std::unique_lock<std::mutex> docBrokersLock(docBrokersMutex);
for (auto& brokerIt : docBrokers)
{
- brokerIt.second->autoSave(false);
+ if (brokerIt.second->isModified())
+ {
+ brokerIt.second->autoSave(false);
+ }
}
}
catch (const std::exception& exc)
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index 1fa0a03..99f143e 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -164,6 +164,17 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length)
return true;
}
+ else if (tokens.count() == 2 && tokens[0] == "statechanged:")
+ {
+ StringTokenizer stateTokens(tokens[1], "=", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
+ if (stateTokens.count() == 2 && stateTokens[0] == ".uno:ModifiedStatus")
+ {
+ if (_docBroker)
+ {
+ _docBroker->setModified(stateTokens[1] == "true");
+ }
+ }
+ }
}
if (peer && !_isDocPasswordProtected)
More information about the Libreoffice-commits
mailing list