[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sun Jan 10 20:09:52 PST 2016
loolwsd/LOOLKit.cpp | 4 ++--
loolwsd/LOOLWSD.cpp | 26 +++++++++++++-------------
2 files changed, 15 insertions(+), 15 deletions(-)
New commits:
commit f577e48f18c01616269159c839b25beda9a4355f
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Jan 10 10:35:28 2016 -0500
loolwsd: child Session ID in URI
Change-Id: Ide04425fe29d17dd2db1aea532de421b8f0e3669
Reviewed-on: https://gerrit.libreoffice.org/21329
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 7e2f8ad..4750d08 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -362,7 +362,7 @@ public:
void run() override
{
- static const std::string thread_name = "kit_socket_" + _sessionId;
+ static const std::string thread_name = "kit_ws_" + _sessionId;
#ifdef __linux
if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(thread_name.c_str()), 0, 0, 0) != 0)
Log::error("Cannot set thread name to " + thread_name + ".");
@@ -376,7 +376,7 @@ public:
HTTPClientSession cs("127.0.0.1", MASTER_PORT_NUMBER);
cs.setTimeout(0);
- HTTPRequest request(HTTPRequest::HTTP_GET, CHILD_URI);
+ HTTPRequest request(HTTPRequest::HTTP_GET, CHILD_URI + _sessionId);
HTTPResponse response;
_ws = std::make_shared<WebSocket>(cs, request, response);
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 71e9915..51bd75c 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -308,7 +308,8 @@ public:
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) override
{
- const std::string thread_name = "client_socket";
+ const auto id = LOOLWSD::GenSessionId();
+ const std::string thread_name = "client_ws_" + id;
#ifdef __linux
if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(thread_name.c_str()), 0, 0, 0) != 0)
@@ -333,7 +334,6 @@ public:
// Load the document.
std::shared_ptr<WebSocket> ws;
const LOOLSession::Kind kind = LOOLSession::Kind::ToClient;
- const auto id = LOOLWSD::GenSessionId();
auto session = std::make_shared<MasterProcessSession>(id, kind, ws);
const std::string filePrefix("file://");
const std::string load = "load url=" + filePrefix + fromPath;
@@ -430,8 +430,6 @@ public:
try
{
auto ws = std::make_shared<WebSocket>(request, response);
-
- const std::string id = LOOLWSD::GenSessionId();
auto session = std::make_shared<MasterProcessSession>(id, LOOLSession::Kind::ToClient, ws);
// For ToClient sessions, we store incoming messages in a queue and have a separate
@@ -493,21 +491,23 @@ public:
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) override
{
assert(request.serverAddress().port() == MASTER_PORT_NUMBER);
- assert(request.getURI() == LOOLWSD::CHILD_URI);
+ assert(request.getURI().find(LOOLWSD::CHILD_URI) == 0);
- const std::string thread_name = "prison_socket";
+ std::string thread_name = "prison_ws_";
+ try
+ {
+ const auto index = request.getURI().find_last_of('/');
+ const auto id = request.getURI().substr(index + 1);
+
+ thread_name += id;
#ifdef __linux
- if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(thread_name.c_str()), 0, 0, 0) != 0)
- Log::error("Cannot set thread name to " + thread_name + ".");
+ if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(thread_name.c_str()), 0, 0, 0) != 0)
+ Log::error("Cannot set thread name to " + thread_name + ".");
#endif
- Log::debug("Thread [" + thread_name + "] started.");
+ Log::debug("Thread [" + thread_name + "] started.");
- try
- {
auto ws = std::make_shared<WebSocket>(request, response);
-
- const std::string id;
auto session = std::make_shared<MasterProcessSession>(id, LOOLSession::Kind::ToPrisoner, ws);
SocketProcessor(ws, response, [&session](const char* data, const int size, bool)
More information about the Libreoffice-commits
mailing list