[Libreoffice-commits] online.git: loolwsd/ClientSession.cpp loolwsd/ClientSession.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sat May 21 03:21:17 UTC 2016
loolwsd/ClientSession.cpp | 58 +++++++++++++++-------------------------------
loolwsd/ClientSession.hpp | 1
2 files changed, 19 insertions(+), 40 deletions(-)
New commits:
commit 46c5ce3041dd621f9d54ae2e99be8cce648e0ab4
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Fri May 20 15:25:42 2016 -0400
loolwsd: remove unnecessary dispatchChild and simplify
Change-Id: I6edb5a51bc2d58b58f53f6689e9d37613fc508de
Reviewed-on: https://gerrit.libreoffice.org/25236
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp
index 5aecf8e..32c7f67 100644
--- a/loolwsd/ClientSession.cpp
+++ b/loolwsd/ClientSession.cpp
@@ -166,8 +166,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
if (_peer.expired())
{
- Log::trace("Dispatching child to handle [" + tokens[0] + "].");
- dispatchChild();
+ Log::warn("No peer to handle [" + tokens[0] + "].");
}
// Allow 'downloadas' for all kinds of views irrespective of editlock
@@ -193,16 +192,28 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/, StringT
return false;
}
+ Log::info("Requesting document load from child.");
try
{
std::string timestamp;
parseDocOptions(tokens, _loadPart, timestamp);
- // Finally, wait for the Child to connect to Master,
- // link the document in jail and dispatch load to child.
- Log::trace("Dispatching child to handle [load].");
- dispatchChild();
+ std::ostringstream oss;
+ oss << "load";
+ oss << " url=" << _docBroker->getPublicUri().toString();
+ oss << " jail=" << _docBroker->getJailedUri().toString();
+ if (_loadPart >= 0)
+ oss << " part=" + std::to_string(_loadPart);
+
+ if (_haveDocPassword)
+ oss << " password=" << _docPassword;
+
+ if (!_docOptions.empty())
+ oss << " options=" << _docOptions;
+
+ const auto loadRequest = oss.str();
+ forwardToPeer(loadRequest.c_str(), loadRequest.size());
return true;
}
catch (const Poco::SyntaxException&)
@@ -228,12 +239,6 @@ bool ClientSession::getStatus(const char *buffer, int length)
return true;
}
- if (_peer.expired())
- {
- Log::trace("Dispatching child to handle [getStatus].");
- dispatchChild();
- }
-
forwardToPeer(buffer, length);
return true;
}
@@ -264,8 +269,6 @@ bool ClientSession::getCommandValues(const char *buffer, int length, StringToken
return true;
}
- if (_peer.expired())
- dispatchChild();
forwardToPeer(buffer, length);
return true;
}
@@ -279,8 +282,6 @@ bool ClientSession::getPartPageRectangles(const char *buffer, int length)
return true;
}
- if (_peer.expired())
- dispatchChild();
forwardToPeer(buffer, length);
return true;
}
@@ -316,8 +317,6 @@ void ClientSession::sendFontRendering(const char *buffer, int length, StringToke
return;
}
- if (_peer.expired())
- dispatchChild();
forwardToPeer(buffer, length);
}
@@ -408,26 +407,6 @@ void ClientSession::sendCombinedTiles(const char* /*buffer*/, int /*length*/, St
}
}
-void ClientSession::dispatchChild()
-{
- std::ostringstream oss;
- oss << "load";
- oss << " url=" << _docBroker->getPublicUri().toString();
- oss << " jail=" << _docBroker->getJailedUri().toString();
-
- if (_loadPart >= 0)
- oss << " part=" + std::to_string(_loadPart);
-
- if (_haveDocPassword)
- oss << " password=" << _docPassword;
-
- if (!_docOptions.empty())
- oss << " options=" << _docOptions;
-
- const auto loadRequest = oss.str();
- forwardToPeer(loadRequest.c_str(), loadRequest.size());
-}
-
void ClientSession::forwardToPeer(const char *buffer, int length)
{
const auto message = getAbbreviatedMessage(buffer, length);
@@ -437,7 +416,8 @@ void ClientSession::forwardToPeer(const char *buffer, int length)
{
throw Poco::ProtocolException(getName() + ": no peer to forward to: [" + message + "].");
}
- else if (peer->isCloseFrame())
+
+ if (peer->isCloseFrame())
{
Log::trace(getName() + ": peer began the closing handshake. Dropping forward message [" + message + "].");
return;
diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index 2b5d0f0..6bdac2b 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -76,7 +76,6 @@ private:
void sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens);
void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens);
- void dispatchChild();
void forwardToPeer(const char *buffer, int length);
private:
More information about the Libreoffice-commits
mailing list