[Libreoffice-commits] online.git: loolwsd/LOOLSession.cpp loolwsd/LOOLWSD.cpp loolwsd/QueueHandler.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Tue Mar 29 02:48:46 UTC 2016
loolwsd/LOOLSession.cpp | 10 +++-------
loolwsd/LOOLWSD.cpp | 6 +++---
loolwsd/QueueHandler.hpp | 7 +------
3 files changed, 7 insertions(+), 16 deletions(-)
New commits:
commit 7d2d2aab1c7f91e07e3d735daeb9680dc3ad1455
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Mar 27 14:51:54 2016 -0400
loolwsd: message handling cleanups
Change-Id: I346511819907757bd84895c3751f0cbce4f37084
Reviewed-on: https://gerrit.libreoffice.org/23585
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index e69cbf0..da39bba 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -186,9 +186,9 @@ bool LOOLSession::handleInput(const char *buffer, int length)
{
assert(buffer != nullptr);
+ const auto summary = getAbbreviatedMessage(buffer, length);
try
{
- const auto summary = getAbbreviatedMessage(buffer, length);
Log::trace(getName() + " Recv: " + summary);
if (TerminationFlag)
{
@@ -199,7 +199,7 @@ bool LOOLSession::handleInput(const char *buffer, int length)
}
catch (const Exception& exc)
{
- Log::error() << "LOOLSession::handleInput: Exception while handling [" + getFirstLine(buffer, length) + "] in "
+ Log::error() << "LOOLSession::handleInput: Exception while handling [" + summary + "] in "
<< getName() << ": "
<< exc.displayText()
<< (exc.nested() ? " (" + exc.nested()->displayText() + ")" : "")
@@ -207,11 +207,7 @@ bool LOOLSession::handleInput(const char *buffer, int length)
}
catch (const std::exception& exc)
{
- Log::error("LOOLSession::handleInput: Exception while handling [" + getFirstLine(buffer, length) + "]: " + exc.what());
- }
- catch (...)
- {
- Log::error("LOOLSession::handleInput: Unexpected exception");
+ Log::error("LOOLSession::handleInput: Exception while handling [" + summary + "]: " + exc.what());
}
return false;
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index b4cc910..b84f0db 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -274,7 +274,7 @@ void SocketProcessor(std::shared_ptr<WebSocket> ws,
assert(n > 0);
- const std::string firstLine = getFirstLine(payload.data(), payload.size());
+ const std::string firstLine = LOOLProtocol::getFirstLine(payload);
if ((flags & WebSocket::FrameFlags::FRAME_FLAG_FIN) != WebSocket::FrameFlags::FRAME_FLAG_FIN)
{
// One WS message split into multiple frames.
@@ -616,9 +616,9 @@ private:
SocketProcessor(ws, response, [&session, &queue, &normalShutdown](const std::vector<char>& payload)
{
- const auto firstLine = getFirstLine(payload.data(), payload.size());
time(&session->_lastMessageTime);
- if (firstLine.compare(0, 10, "disconnect") == 0) // starts with "disconnect"
+ const auto token = LOOLProtocol::getFirstToken(payload);
+ if (token == "disconnect")
{
normalShutdown = true;
}
diff --git a/loolwsd/QueueHandler.hpp b/loolwsd/QueueHandler.hpp
index 833c331..4d2fd18 100644
--- a/loolwsd/QueueHandler.hpp
+++ b/loolwsd/QueueHandler.hpp
@@ -38,8 +38,7 @@ public:
while (true)
{
const auto input = _queue.get();
- const auto firstLine = LOOLProtocol::getFirstLine(input.data(), input.size());
- if (firstLine == "eof")
+ if (LOOLProtocol::getFirstToken(input) == "eof")
{
Log::info("Received EOF. Finishing.");
break;
@@ -56,10 +55,6 @@ public:
{
Log::error(std::string("QueueHandler::run: Exception: ") + exc.what());
}
- catch (...)
- {
- Log::error("QueueHandler::run: Unexpected exception");
- }
Log::debug("Thread [" + _name + "] finished.");
}
More information about the Libreoffice-commits
mailing list