[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sun Oct 16 22:11:01 UTC 2016
loolwsd/DocumentBroker.cpp | 27 ++++++++++++++++++++++++++-
loolwsd/DocumentBroker.hpp | 2 ++
2 files changed, 28 insertions(+), 1 deletion(-)
New commits:
commit 4f4472ffa6e11bf8b77c8e64198c5e159dbd9daa
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Oct 15 17:07:40 2016 -0400
loolwsd: shutdown client sockets and cleanup when kit dies
Change-Id: I4d59553d744a8075d4d873ff520d9f3e417521b3
Reviewed-on: https://gerrit.libreoffice.org/29947
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 0d36497..dceb1c5 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -53,6 +53,16 @@ void ChildProcess::socketProcessor()
},
[]() { },
[this]() { return TerminationFlag || this->_stop; });
+
+ Log::debug() << "Child [" << getPid() << "] WS terminated. Notifying DocBroker." << Log::end;
+
+
+ // Notify the broker that we're done.
+ auto docBroker = _docBroker.lock();
+ if (docBroker)
+ {
+ docBroker->childSocketTerminated();
+ }
}
namespace
@@ -286,7 +296,7 @@ bool DocumentBroker::autoSave(const bool force, const size_t waitTimeoutMs)
{
std::unique_lock<std::mutex> lock(_mutex);
if (_sessions.empty() || _storage == nullptr || !_isLoaded ||
- (!_isModified && !force))
+ !_childProcess->isAlive() || (!_isModified && !force))
{
// Nothing to do.
Log::trace("Nothing to autosave [" + _docKey + "].");
@@ -824,4 +834,19 @@ const std::chrono::duration<double> DocumentBroker::getStorageLoadDuration() con
return std::chrono::duration<double>::zero();
}
+void DocumentBroker::childSocketTerminated()
+{
+ if (!_childProcess->isAlive())
+ {
+ Log::error("Child for doc [" + _docKey + "] terminated prematurely.");
+ }
+
+ // We could restore the kit if this was unexpected.
+ // For now, close the connections to cleanup.
+ for (auto& pair : _sessions)
+ {
+ pair.second->shutdown(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index d5e8b42..7972903 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -266,6 +266,8 @@ public:
/// Currently, only makes sense in case storage is WOPI
const std::chrono::duration<double> getStorageLoadDuration() const;
+ void childSocketTerminated();
+
private:
/// Sends the .uno:Save command to LoKit.
More information about the Libreoffice-commits
mailing list