[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon May 22 19:07:21 UTC 2017
wsd/DocumentBroker.cpp | 29 ++++++++++++++++++++++++-----
wsd/DocumentBroker.hpp | 3 +++
wsd/LOOLWSD.cpp | 3 ---
3 files changed, 27 insertions(+), 8 deletions(-)
New commits:
commit e877adc84bc6f90bcfa52f9f63666358e6614885
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon May 22 15:04:35 2017 -0400
wsd: don't stop doc on unauthorized loading
When a client connects with expired/invalid
access_token, the document should remain
active for other/existing clients, if any.
However, if no clients exists (i.e. the
first client has invalid access_token),
then the document should be unloaded and
cleaned up.
Change-Id: Iaad95a4286325cc6ee130b37e3ad635993a71c72
Reviewed-on: https://gerrit.libreoffice.org/37916
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 73178103..17ce1be2 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -785,6 +785,25 @@ std::string DocumentBroker::getJailRoot() const
size_t DocumentBroker::addSession(const std::shared_ptr<ClientSession>& session)
{
+ try
+ {
+ return addSessionInternal(session);
+ }
+ catch (const std::exception& exc)
+ {
+ LOG_ERR("Failed to add session to [" << _docKey << "] with URI [" << session->getPublicUri().toString() << "]: " << exc.what());
+ if (_sessions.empty())
+ {
+ LOG_INF("Doc [" << _docKey << "] has no more sessions. Marking to destroy.");
+ _markToDestroy = true;
+ }
+
+ throw;
+ }
+}
+
+size_t DocumentBroker::addSessionInternal(const std::shared_ptr<ClientSession>& session)
+{
assertCorrectThread();
try
@@ -815,12 +834,7 @@ size_t DocumentBroker::addSession(const std::shared_ptr<ClientSession>& session)
_markToDestroy = false;
_stop = false;
- // Add and attach the session.
- _sessions.emplace(session->getId(), session);
- session->setAttached();
-
const auto id = session->getId();
- const auto count = _sessions.size();
// Request a new session from the child kit.
const std::string aMessage = "session " + id + ' ' + _docKey + ' ' + _docId;
@@ -829,6 +843,11 @@ size_t DocumentBroker::addSession(const std::shared_ptr<ClientSession>& session)
// Tell the admin console about this new doc
Admin::instance().addDoc(_docKey, getPid(), getFilename(), id, session->getUserName());
+ // Add and attach the session.
+ _sessions.emplace(session->getId(), session);
+ session->setAttached();
+
+ const auto count = _sessions.size();
LOG_TRC("Added " << (session->isReadOnly() ? "readonly" : "non-readonly") <<
" session [" << id << "] to docKey [" <<
_docKey << "] to have " << count << " sessions.");
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 14fe17e0..23b699e4 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -350,6 +350,9 @@ private:
/// Saves the doc to the storage.
bool saveToStorageInternal(const std::string& sesionId, bool success, const std::string& result = "");
+ /// Loads a new session and adds to the sessions container.
+ size_t addSessionInternal(const std::shared_ptr<ClientSession>& session);
+
/// Removes a session by ID. Returns the new number of sessions.
size_t removeSessionInternal(const std::string& id);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3a877242..7c188f17 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2127,19 +2127,16 @@ private:
LOG_ERR("Unauthorized Request while loading session for " << docBroker->getDocKey() << ": " << exc.what());
const std::string msg = "error: cmd=internal kind=unauthorized";
clientSession->sendMessage(msg);
- docBroker->stop();
}
catch (const StorageConnectionException& exc)
{
// Alert user about failed load
const std::string msg = "error: cmd=storage kind=loadfailed";
clientSession->sendMessage(msg);
- docBroker->stop();
}
catch (const std::exception& exc)
{
LOG_ERR("Error while loading : " << exc.what());
- docBroker->stop();
}
});
});
More information about the Libreoffice-commits
mailing list