loolwsd/ChildSession.cpp | 37 +++++++++++++++---------------------- loolwsd/ChildSession.hpp | 2 +- 2 files changed, 16 insertions(+), 23 deletions(-)
New commits: commit 74304fc08ee2cb666824eee4b460b029b81a69de Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat May 21 11:47:13 2016 -0400 loolwsd: ChildSession error propegation and cleanup Change-Id: I8e5c87b6989fd090c98ca35e2584a7dd6d1c6a60 Reviewed-on: https://gerrit.libreoffice.org/25267 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp index 785f6f2..8587e25 100644 --- a/loolwsd/ChildSession.cpp +++ b/loolwsd/ChildSession.cpp @@ -401,13 +401,13 @@ bool ChildSession::_handleInput(const char *buffer, int length) if (tokens[0] == "dummymsg") { - // Just to update the activity of view-only mode + // Just to update the activity of a view-only client. return true; } else if (tokens[0] == "canceltiles") { - // this command makes sense only on the command queue level, nothing - // to do here + // This command makes sense only on the command queue level. + // Shouldn't get this here. return true; } else if (tokens[0] == "commandvalues") @@ -562,14 +562,14 @@ bool ChildSession::_handleInput(const char *buffer, int length) // than for WSD to potentially stall while notifying // each client with the edit lock state. Log::trace("Echoing back [" + firstLine + "]."); - sendTextFrame(firstLine); - return true; + return sendTextFrame(firstLine); } else { - assert(false); + assert(!"Unknown command token."); } } + return true; } @@ -627,7 +627,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT return true; } -void ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens) +bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens) { std::string font, decodedFont; @@ -635,7 +635,7 @@ void ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, Str !getTokenString(tokens[1], "font", font)) { sendTextFrame("error: cmd=renderfont kind=syntax"); - return; + return false; } std::unique_lock<std::recursive_mutex> lock(Mutex); @@ -652,21 +652,16 @@ void ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, Str Timestamp timestamp; int width, height; - unsigned char *pixmap = _loKitDocument->renderFont(decodedFont.c_str(), &width, &height); + std::unique_ptr<unsigned char[]> pixmap(_loKitDocument->renderFont(decodedFont.c_str(), &width, &height)); Log::trace("renderFont [" + font + "] rendered in " + std::to_string(timestamp.elapsed()/1000.) + "ms"); - if (pixmap != nullptr) + if (!pixmap || + !png::encodeBufferToPNG(pixmap.get(), width, height, output, LOK_TILEMODE_RGBA)) { - if (!png::encodeBufferToPNG(pixmap, width, height, output, LOK_TILEMODE_RGBA)) - { - sendTextFrame("error: cmd=renderfont kind=failure"); - delete[] pixmap; - return; - } - delete[] pixmap; + return sendTextFrame("error: cmd=renderfont kind=failure"); } - sendBinaryFrame(output.data(), output.size()); + return sendBinaryFrame(output.data(), output.size()); } bool ChildSession::getStatus(const char* /*buffer*/, int /*length*/) @@ -683,8 +678,7 @@ bool ChildSession::getStatus(const char* /*buffer*/, int /*length*/) return false; } - sendTextFrame("status: " + status); - return true; + return sendTextFrame("status: " + status); } bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, StringTokenizer& tokens) @@ -701,8 +695,7 @@ bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, Stri if (_multiView) _loKitDocument->setView(_viewId); - sendTextFrame("commandvalues: " + std::string(_loKitDocument->getCommandValues(command.c_str()))); - return true; + return sendTextFrame("commandvalues: " + std::string(_loKitDocument->getCommandValues(command.c_str()))); } bool ChildSession::getPartPageRectangles(const char* /*buffer*/, int /*length*/) diff --git a/loolwsd/ChildSession.hpp b/loolwsd/ChildSession.hpp index a0e42d9..aa17be8 100644 --- a/loolwsd/ChildSession.hpp +++ b/loolwsd/ChildSession.hpp @@ -59,7 +59,7 @@ public: protected: bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens); - void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens); + bool sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens); bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens); bool clientZoom(const char *buffer, int length, Poco::StringTokenizer& tokens); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits