[Libreoffice-commits] online.git: wsd/DocumentBroker.cpp wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Jan 16 01:54:17 UTC 2017
wsd/DocumentBroker.cpp | 2 +
wsd/LOOLWSD.cpp | 53 +++++++++++--------------------------------------
2 files changed, 14 insertions(+), 41 deletions(-)
New commits:
commit 087f9930402c49d2f26bfab6ce1bb10012e33faa
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Tue Jan 10 00:26:24 2017 -0500
wsd: use refactored createNewClientSession
Change-Id: I7d9128865eea6c5fd9f48b469fb35ede3c811b4b
Reviewed-on: https://gerrit.libreoffice.org/33123
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 cb20b14..4348e86 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -960,6 +960,8 @@ bool DocumentBroker::startDestroy(const std::string& id)
// Last view going away, can destroy.
_markToDestroy = (_sessions.size() <= 1);
+ LOG_DBG("startDestroy on session [" << id << "] on docKey [" << _docKey <<
+ "], markToDestroy: " << _markToDestroy << ", lastEditableSession: " << _lastEditableSession);
return _lastEditableSession;
}
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 5cc6b2c..ca03df2 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -833,8 +833,12 @@ private:
auto docBroker = findOrCreateDocBroker(docKey, ws, id, uriPublic);
if (docBroker)
{
- // Process the request in an exception-safe way.
- processGetRequest(uri, ws, id, uriPublic, docBroker, isReadOnly);
+ auto session = createNewClientSession(uri, ws, id, uriPublic, docBroker, isReadOnly);
+ if (session)
+ {
+ // Process the request in an exception-safe way.
+ processGetRequest(uri, ws, id, docBroker, session);
+ }
}
}
catch (const WebSocketErrorMessageException& exc)
@@ -1105,47 +1109,14 @@ private:
}
/// Process GET requests.
- static void processGetRequest(const std::string& uri, std::shared_ptr<LOOLWebSocket>& ws, const std::string& id,
- const Poco::URI& uriPublic, const std::shared_ptr<DocumentBroker>& docBroker, const bool isReadOnly)
+ static void processGetRequest(const std::string& uri,
+ std::shared_ptr<LOOLWebSocket>& ws,
+ const std::string& id,
+ const std::shared_ptr<DocumentBroker>& docBroker,
+ const std::shared_ptr<ClientSession>& session)
{
LOG_CHECK_RET(docBroker && "Null docBroker instance", );
const auto docKey = docBroker->getDocKey();
-
- std::shared_ptr<ClientSession> session;
- try
- {
- // In case of WOPI, if this session is not set as readonly, it might be set so
- // later after making a call to WOPI host which tells us the permission on files
- // (UserCanWrite param).
- session = std::make_shared<ClientSession>(id, ws, docBroker, uriPublic, isReadOnly);
-
- // Now we have a DocumentBroker and we're ready to process client commands.
- const std::string statusReady = "statusindicator: ready";
- LOG_TRC("Sending to Client [" << statusReady << "].");
- ws->sendFrame(statusReady.data(), statusReady.size());
-
- const std::string fs = FileUtil::checkDiskSpaceOnRegisteredFileSystems();
- if (!fs.empty())
- {
- LOG_WRN("File system of [" << fs << "] is dangerously low on disk space.");
- const std::string diskfullMsg = "error: cmd=internal kind=diskfull";
- // Alert the session currently being opened
- ws->sendFrame(diskfullMsg.data(), diskfullMsg.size());
- // Alert all other existing sessions also
- Util::alertAllUsers(diskfullMsg);
- }
-
- LOOLWSD::dumpEventTrace(docBroker->getJailId(), id, "NewSession: " + uri);
- docBroker->addSession(session);
- }
- catch (const std::exception& exc)
- {
- LOG_WRN("Exception while preparing session [" << id << "].");
- removeDocBrokerSession(docBroker, id);
-
- return;
- }
-
LOG_CHECK_RET(session && "Null ClientSession instance", );
try
{
@@ -1159,7 +1130,7 @@ private:
[]() { return TerminationFlag || SigUtil::isShuttingDown(); });
// Connection terminated. Destroy session.
- LOG_DBG("Client session [" << id << "] terminated. Cleaning up.");
+ LOG_DBG("Client session [" << id << "] on docKey [" << docKey << "] terminated. Cleaning up.");
auto docLock = docBroker->getLock();
More information about the Libreoffice-commits
mailing list