loolwsd/IoUtil.hpp | 2 +- loolwsd/LOOLSession.cpp | 12 ++++++------ loolwsd/LOOLWSD.cpp | 16 ++++++++++++---- 3 files changed, 19 insertions(+), 11 deletions(-)
New commits: commit e797ae9861c82144c43787ff9fe9f1ece52a9609 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Thu May 19 20:28:02 2016 -0400 loolwsd: logging improvements Change-Id: Ic28e8f523f67e3339cae20adcf6cab966b610f24 Reviewed-on: https://gerrit.libreoffice.org/25233 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/IoUtil.hpp b/loolwsd/IoUtil.hpp index 780754c..2584374 100644 --- a/loolwsd/IoUtil.hpp +++ b/loolwsd/IoUtil.hpp @@ -28,7 +28,7 @@ namespace IoUtil int receiveFrame(Poco::Net::WebSocket& socket, void* buffer, int length, int& flags); /// Synchronously process WebSocket requests and dispatch to handler. - //. Handler returns false to end. + /// Handler returns false to end. void SocketProcessor(const std::shared_ptr<Poco::Net::WebSocket>& ws, const std::function<bool(const std::vector<char>&)>& handler, const std::function<void()>& closeFrame, diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp index 3eda87d..55f84b2 100644 --- a/loolwsd/LOOLSession.cpp +++ b/loolwsd/LOOLSession.cpp @@ -75,11 +75,11 @@ void LOOLSession::sendTextFrame(const std::string& text) { if (!_ws || _ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_ERROR)) { - Log::error("Socket error to send " + getAbbreviatedMessage(text.c_str(), text.size()) + " to."); + Log::error(getName() + ": Bad socket while sending [" + getAbbreviatedMessage(text.c_str(), text.size()) + "]."); return; } - else - Log::trace(getName() + " Send: " + getAbbreviatedMessage(text.c_str(), text.size())); + + Log::trace(getName() + " Send: " + getAbbreviatedMessage(text.c_str(), text.size())); std::unique_lock<std::mutex> lock(_mutex); @@ -106,11 +106,11 @@ void LOOLSession::sendBinaryFrame(const char *buffer, int length) { if (!_ws || _ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_ERROR)) { - Log::error("Socket error to send binary frame of " + std::to_string(length) + " bytes to."); + Log::error(getName() + ": Bad socket while sending binary frame of " + std::to_string(length) + " bytes."); return; } - else - Log::trace(getName() + " Send: " + std::to_string(length) + " bytes"); + + Log::trace(getName() + " Send: " + std::to_string(length) + " bytes"); std::unique_lock<std::mutex> lock(_mutex); diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index e9f44ab..bea8637 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -390,7 +390,6 @@ private: Log::trace(docKey + ", ws_sessions++: " + std::to_string(sessionsCount)); lock.unlock(); - Log::trace(docKey + ", ws_sessions++: " + std::to_string(sessionsCount)); // Wait until the client has connected with a prison socket. waitBridgeCompleted(session); @@ -402,13 +401,15 @@ private: const std::string load = "load url=" + encodedFrom; session->handleInput(load.data(), load.size()); - // Convert it to the requested format. + //FIXME: Check for security violations. Path toPath(docBroker->getPublicUri().getPath()); toPath.setExtension(format); const std::string toJailURL = "file://" + std::string(JAILED_DOCUMENT_ROOT) + toPath.getFileName(); std::string encodedTo; URI::encode(toJailURL, "", encodedTo); - std::string saveas = "saveas url=" + encodedTo + " format=" + format + " options="; + + // Convert it to the requested format. + const auto saveas = "saveas url=" + encodedTo + " format=" + format + " options="; session->handleInput(saveas.data(), saveas.size()); // Send it back to the client. @@ -428,6 +429,10 @@ private: Log::debug("Removing DocumentBroker for docKey [" + docKey + "]."); docBrokers.erase(docKey); } + else + { + Log::error("Multiple sessions during conversion. " + std::to_string(sessionsCount) + " sessions remain."); + } } // Clean up the temporary directory the HTMLForm ctor created. @@ -988,7 +993,10 @@ public: auto session = std::make_shared<PrisonerSession>(sessionId, ws, docBroker); // Connect the prison session to the client. - docBroker->connectPeers(session); + if (!docBroker->connectPeers(session)) + { + Log::warn("Failed to connect " + session->getName() + " to its peer."); + } std::unique_lock<std::mutex> lock(AvailableChildSessionMutex); AvailableChildSessions.emplace(sessionId, session); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits