[Libreoffice-commits] online.git: loolwsd/Admin.cpp loolwsd/DocumentBroker.cpp loolwsd/IoUtil.cpp loolwsd/IoUtil.hpp loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Nov 14 05:33:06 UTC 2016
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 <ashod.nakashian at collabora.co.uk>
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 <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
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<char>& 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<char>& 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<LOOLWebSocket>& ws,
+ const std::string& name,
const std::function<bool(const std::vector<char>&)>& handler,
const std::function<void()>& closeFrame,
const std::function<bool()>& 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<LOOLWebSocket>& 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<LOOLWebSocket>& 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<LOOLWebSocket>& 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<LOOLWebSocket>& 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("SocketProcessor [" << name << "]: Getting large message of " << size << " bytes.");
if (size > MAX_MESSAGE_SIZE)
{
- LOG_ERR("Large-message size (" << size << ") over limit or invalid.");
+ LOG_ERR("SocketProcessor [" << name << "]: Large-message size (" << size << ") over limit or invalid.");
}
else
{
@@ -148,7 +149,7 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
if (n <= 0 || (flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE)
{
closeFrame();
- LOG_WRN("Connection closed.");
+ LOG_WRN("SocketProcessor [" << name << "]: Connection closed.");
break;
}
@@ -158,25 +159,25 @@ void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
if (!success)
{
- LOG_INF("Socket handler flagged to finish.");
+ LOG_INF("SocketProcessor [" << name << "]: Handler flagged to finish.");
break;
}
}
}
catch (const std::exception& exc)
{
- LOG_ERR("SocketProcessor: exception: " << exc.what());
+ LOG_ERR("SocketProcessor [" << name << "]: Exception: " << exc.what());
}
if ((flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE && n > 0 && payload.size() > 0)
{
std::string msg;
Poco::URI::encode(std::string(payload.data(), payload.size()), "", msg);
- LOG_WRN("Last message (" << payload.size() <<
+ LOG_WRN("SocketProcessor [" << name << "]: Last message (" << payload.size() <<
" bytes) will not be processed: [" << msg << "].");
}
- LOG_INF("SocketProcessor finished. stop: " << (stop ? "true" : "false") <<
+ LOG_INF("SocketProcessor [" << name << "] finished. stop: " << (stop ? "true" : "false") <<
", n: " << n << ", payload size: " << payload.size() <<
", flags: " << std::hex << flags);
}
diff --git a/loolwsd/IoUtil.hpp b/loolwsd/IoUtil.hpp
index fca3107..6a81f19 100644
--- a/loolwsd/IoUtil.hpp
+++ b/loolwsd/IoUtil.hpp
@@ -22,6 +22,7 @@ namespace IoUtil
/// Synchronously process LOOLWebSocket requests and dispatch to handler.
/// Handler returns false to end.
void SocketProcessor(const std::shared_ptr<LOOLWebSocket>& ws,
+ const std::string& name,
const std::function<bool(const std::vector<char>&)>& handler,
const std::function<void()>& closeFrame,
const std::function<bool()>& stopPredicate);
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 17bd15c..435b8a7 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1467,8 +1467,8 @@ void lokit_main(const std::string& childRoot,
auto queue = std::make_shared<TileQueue>();
- const std::string socketName = "ChildControllerWS";
- IoUtil::SocketProcessor(ws,
+ const std::string socketName = "child_ws_" + std::to_string(getpid());
+ IoUtil::SocketProcessor(ws, socketName,
[&socketName, &ws, &loKit, &queue](const std::vector<char>& data)
{
std::string message(data.data(), data.size());
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index bb2bd85..91329d6 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -878,7 +878,7 @@ private:
LOOLWSD::dumpEventTrace(docBroker->getJailId(), id, "NewSession: " + uri);
// Let messages flow.
- IoUtil::SocketProcessor(ws,
+ IoUtil::SocketProcessor(ws, "client_ws_" + id,
[&session](const std::vector<char>& payload)
{
return session->handleInput(payload.data(), payload.size());
More information about the Libreoffice-commits
mailing list