[Libreoffice-commits] online.git: loolwsd/Admin.cpp loolwsd/DocumentBroker.cpp loolwsd/IoUtil.cpp loolwsd/IoUtil.hpp loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp
loolwsd/Admin.cpp |2 +- loolwsd/DocumentBroker.cpp |5 +++-- loolwsd/IoUtil.cpp | 27 ++- loolwsd/IoUtil.hpp |1 + loolwsd/LOOLKit.cpp|4 ++-- loolwsd/LOOLWSD.cpp|2 +- 6 files changed, 22 insertions(+), 19 deletions(-) New commits: commit 853135decd123e1bbd521e7369378056caaabd56 Author: Ashod Nakashian Date: Sun Nov 13 22:23:04 2016 -0500 loolwsd: SocketProcessor can be named and name used in logs Change-Id: I599b6f7308690b49a0e9ed3c23b88dbcb2ed8848 Reviewed-on: https://gerrit.libreoffice.org/30830 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Admin.cpp b/loolwsd/Admin.cpp index 9fc3535..560acbe 100644 --- a/loolwsd/Admin.cpp +++ b/loolwsd/Admin.cpp @@ -213,7 +213,7 @@ void AdminRequestHandler::handleWSRequests(HTTPServerRequest& request, HTTPServe model.subscribe(_sessionId, _adminWs); } -IoUtil::SocketProcessor(_adminWs, +IoUtil::SocketProcessor(_adminWs, "admin", [this](const std::vector& payload) { return adminCommandHandler(payload); diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index 51badf4..a71d405 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -37,9 +37,10 @@ using Poco::StringTokenizer; void ChildProcess::socketProcessor() { -Util::setThreadName("child_ws_" + std::to_string(_pid)); +const auto name = "docbrk_ws_" + std::to_string(_pid); +Util::setThreadName(name); -IoUtil::SocketProcessor(_ws, +IoUtil::SocketProcessor(_ws, name, [this](const std::vector& payload) { const auto message = LOOLProtocol::getAbbreviatedMessage(payload); diff --git a/loolwsd/IoUtil.cpp b/loolwsd/IoUtil.cpp index ff88892..4368af1 100644 --- a/loolwsd/IoUtil.cpp +++ b/loolwsd/IoUtil.cpp @@ -41,11 +41,12 @@ namespace IoUtil // Synchronously process LOOLWebSocket requests and dispatch to handler. // Handler returns false to end. void SocketProcessor(const std::shared_ptr& ws, + const std::string& name, const std::function&)>& handler, const std::function& closeFrame, const std::function& stopPredicate) { -LOG_INF("SocketProcessor starting."); +LOG_INF("SocketProcessor [" << name << "] starting."); // Timeout given is in microseconds. static const Poco::Timespan waitTime(POLL_TIMEOUT_MS * 1000); @@ -65,7 +66,7 @@ void SocketProcessor(const std::shared_ptr& ws, stop = stopPredicate(); if (stop) { -LOG_INF("Termination flagged. Finishing."); +LOG_INF("SocketProcessor [" << name << "]: Stop flagged."); break; } @@ -85,13 +86,13 @@ void SocketProcessor(const std::shared_ptr& ws, } catch (const Poco::TimeoutException&) { -LOG_DBG("SocketProcessor: Spurious TimeoutException, ignored"); +LOG_DBG("SocketProcessor [" << name << "]: Spurious TimeoutException, ignored"); continue; } if (n <= 0 || ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)) { -LOG_WRN("Connection closed."); +LOG_WRN("SocketProcessor [" << name << "]: Connection closed."); closeFrame(); break; } @@ -103,14 +104,14 @@ void SocketProcessor(const std::shared_ptr& ws, { // One WS message split into multiple frames. // TODO: Is this even possible with Poco if we never construct such messages outselves? -LOG_WRN("Receiving multi-parm frame."); +LOG_WRN("SocketProcessor [" << name << "]: Receiving multi-parm frame."); while (true) { char buffer[READ_BUFFER_SIZE * 10]; n = ws->receiveFrame(buffer, sizeof(buffer), flags); if (n <= 0 || (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE) { -LOG_WRN("Connection closed while reading multiframe message."); +LOG_WRN("SocketProcessor [" << name << "]: Connection closed while reading multiframe message."); closeFrame(); break; } @@ -132,10 +133,10 @@ void SocketProcessor(const std::shared_ptr& ws, if (tokens.count() == 2 && tokens[0] == "nextmessage:" && LOOLProtocol::getTokenInteger(tokens[1], "size", size) && size > 0) { -LOG_TRC("Getting large message of " << size << " bytes."); +LOG_TRC("Soc
[Libreoffice-commits] online.git: loolwsd/Admin.cpp loolwsd/DocumentBroker.cpp
loolwsd/Admin.cpp |2 +- loolwsd/DocumentBroker.cpp |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) New commits: commit 39f4e92b022893a609ad527e082d2124a67cfceb Author: Tor Lillqvist Date: Thu Sep 22 08:59:23 2016 +0300 Log::end was missing in two places that used Log::debug() It's too easy to forget the Log::end when using the Log::debug() etc API. Not sure what could be done to that. Change the logging API to be like LibreOffice's SAL_INFO? diff --git a/loolwsd/Admin.cpp b/loolwsd/Admin.cpp index 00dfc49..bf0423f 100644 --- a/loolwsd/Admin.cpp +++ b/loolwsd/Admin.cpp @@ -225,7 +225,7 @@ void AdminRequestHandler::handleWSRequests(HTTPServerRequest& request, HTTPServe []() { }, []() { return TerminationFlag.load(); }); -Log::debug() << "Finishing Admin Session " << Util::encodeId(sessionId); +Log::debug() << "Finishing Admin Session " << Util::encodeId(sessionId) << Log::end; } AdminRequestHandler::AdminRequestHandler(Admin* adminManager) diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index 9f630bf..989e056 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -229,7 +229,7 @@ bool DocumentBroker::save(bool success, const std::string& result) // notify the waiting thread, if any. if (!success && result == "unmodified") { -Log::debug() << "Save skipped as document was not modified"; +Log::debug("Save skipped as document was not modified"); _saveCV.notify_all(); return true; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: loolwsd/Admin.cpp loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/LOOLWSD.cpp loolwsd/MasterProcessSession.cpp loolwsd/MasterProcessSession.hpp loolwsd/
loolwsd/Admin.cpp|2 + loolwsd/DocumentBroker.cpp |5 loolwsd/DocumentBroker.hpp | 15 - loolwsd/LOOLWSD.cpp |1 loolwsd/MasterProcessSession.cpp | 42 +++ loolwsd/MasterProcessSession.hpp |2 - loolwsd/TileCache.cpp|1 loolwsd/TileCache.hpp|2 + 8 files changed, 45 insertions(+), 25 deletions(-) New commits: commit 48dfce13de1df2f9159a7cb72cf72902b32a37c1 Author: Ashod Nakashian Date: Fri Mar 25 22:56:18 2016 -0400 loolwsd: moved TileCache into DocumentBroker Change-Id: If44a2d3158801e0910cf0f991c75b5ef845a5a30 Reviewed-on: https://gerrit.libreoffice.org/23532 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian diff --git a/loolwsd/Admin.cpp b/loolwsd/Admin.cpp index 92a0dac..562bb58 100644 --- a/loolwsd/Admin.cpp +++ b/loolwsd/Admin.cpp @@ -30,6 +30,8 @@ #include "Admin.hpp" #include "AdminModel.hpp" #include "Common.hpp" +#include "TileCache.hpp" +#include "Storage.hpp" #include "LOOLProtocol.hpp" #include "LOOLWSD.hpp" #include "Util.hpp" diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index d3f3134..d5af7f6 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -10,6 +10,8 @@ #include #include "DocumentBroker.hpp" +#include "Storage.hpp" +#include "TileCache.hpp" Poco::URI DocumentBroker::sanitizeURI(std::string uri) { @@ -83,6 +85,9 @@ bool DocumentBroker::load(const std::string& jailId) Log::info("jailPath: " + jailPath.toString() + ", jailRoot: " + jailRoot); +const std::string timestamp = ""; //FIXME: Should come from load options. +_tileCache.reset(new TileCache(_uriPublic.toString(), timestamp)); + _storage = createStorage(jailRoot, jailPath.toString(), _uriPublic); const auto localPath = _storage->loadStorageFileToLocal(); diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp index efbd955..8871e39 100644 --- a/loolwsd/DocumentBroker.hpp +++ b/loolwsd/DocumentBroker.hpp @@ -11,10 +11,17 @@ #define INCLUDED_DOCUMENTBROKER_HPP #include +#include #include #include -#include "Storage.hpp" +#include + +#include + +// Forwards. +class StorageBase; +class TileCache; /// DocumentBroker is responsible for setting up a document /// in jail and brokering loading it from Storage @@ -38,7 +45,9 @@ public: ~DocumentBroker() { -Log::info("~DocumentBroker [" + _uriPublic.toString() + "] destroyed."); +Log::info() << "~DocumentBroker [" << _uriPublic.toString() +<< "] destroyed with " << _sessionsCount +<< " sessions." << Log::end; } void validate(const Poco::URI& uri); @@ -55,6 +64,7 @@ public: unsigned decSessions() { return --_sessionsCount; } unsigned incSessions() { return ++_sessionsCount; } unsigned getSessionsCount() { return _sessionsCount; } +TileCache& tileCache() { return *_tileCache; } std::string getJailRoot() const; @@ -66,6 +76,7 @@ private: std::string _jailId; std::string _filename; std::unique_ptr _storage; +std::unique_ptr _tileCache; std::mutex _mutex; std::atomic _sessionsCount; }; diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 7412124..b0dcde6 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -119,6 +119,7 @@ DEALINGS IN THE SOFTWARE. #include "LOOLWSD.hpp" #include "MasterProcessSession.hpp" #include "QueueHandler.hpp" +#include "Storage.hpp" #include "Util.hpp" using namespace LOOLProtocol; diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp index 52e96c9..324504c 100644 --- a/loolwsd/MasterProcessSession.cpp +++ b/loolwsd/MasterProcessSession.cpp @@ -19,6 +19,8 @@ #include "LOOLWSD.hpp" #include "MasterProcessSession.hpp" #include "Rectangle.hpp" +#include "Storage.hpp" +#include "TileCache.hpp" #include "Util.hpp" using namespace LOOLProtocol; @@ -207,7 +209,7 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length) } } -if (peer && peer->_tileCache && !_isDocPasswordProtected) +if (peer && !_isDocPasswordProtected) { if (tokens[0] == "tile:") { @@ -223,11 +225,11 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length) assert(false); assert(firstLine.size() < static_cast(length)); -peer->_tileCache->saveTile(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight, buffer + firstLine.size() + 1, length - firstLine.size() - 1); +_docBroker->tileCache().saveTile(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight, buffer + firstLine.size() + 1, length - firstLine.size() - 1); } else if (tokens[0] == "status:") { -peer->_tileC