[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/Util.cpp loolwsd/Util.hpp

2016-11-13 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp |   10 +-
 loolwsd/LOOLWSD.cpp |3 ++-
 loolwsd/Util.cpp|   13 -
 loolwsd/Util.hpp|5 +
 4 files changed, 24 insertions(+), 7 deletions(-)

New commits:
commit 47d040f34532e1b913a64d340dd891601a83072b
Author: Ashod Nakashian 
Date:   Sun Nov 13 16:13:36 2016 -0500

loolwsd: handle SIGINT in WSD only

CONTROL-C is now handled by WSD only to
have full control over server shutting down.

Also set signal handlers first thing to trap
any early failures.

Change-Id: Ifc5c93b9dd2aef288eed0ed36c600a639dbc6a44
Reviewed-on: https://gerrit.libreoffice.org/30826
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 507ad94..17bd15c 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1279,6 +1279,11 @@ void lokit_main(const std::string& childRoot,
 bool queryVersion,
 bool displayVersion)
 {
+Util::setFatalSignals();
+Util::setTerminationSignals();
+
+Util::setThreadName("loolkit");
+
 // Reinitialize logging when forked.
 const bool logToFile = std::getenv("LOOL_LOGFILE");
 const char* logFilename = std::getenv("LOOL_LOGFILENAME");
@@ -1304,13 +1309,8 @@ void lokit_main(const std::string& childRoot,
 static const std::string pid = std::to_string(Process::id());
 static const std::string jailId = pid;
 
-Util::setThreadName("loolkit");
-
 LOG_DBG("Process started.");
 
-Util::setTerminationSignals();
-Util::setFatalSignals();
-
 std::string userdir_url;
 std::string instdir_path;
 
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 177b155..4655a91 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1846,8 +1846,9 @@ Process::PID LOOLWSD::createForKit()
 
 int LOOLWSD::main(const std::vector& /*args*/)
 {
-Util::setTerminationSignals();
 Util::setFatalSignals();
+Util::setTerminationSignals();
+Util::setInterruptionSignal();
 
 // down-pay all the forkit linking cost once & early.
 Environment::set("LD_BIND_NOW", "1");
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index b5c26a7..deb2819 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -218,11 +218,22 @@ namespace Util
 action.sa_handler = handleTerminationSignal;
 
 sigaction(SIGTERM, &action, nullptr);
-sigaction(SIGINT, &action, nullptr);
 sigaction(SIGQUIT, &action, nullptr);
 sigaction(SIGHUP, &action, nullptr);
 }
 
+/// Handle SIGINT, should be set by WSD only.
+void setInterruptionSignal()
+{
+struct sigaction action;
+
+sigemptyset(&action.sa_mask);
+action.sa_flags = 0;
+action.sa_handler = handleTerminationSignal;
+
+sigaction(SIGINT, &action, nullptr);
+}
+
 static char FatalGdbString[256] = { '\0' };
 
 static
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index 93c95f7..2303a65 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -84,8 +84,13 @@ namespace Util
 
 /// Trap signals to cleanup and exit the process gracefully.
 void setTerminationSignals();
+
+/// Trap all fatal signals to assist debugging.
 void setFatalSignals();
 
+/// Trap SIGINT, should be set by WSD only.
+void setInterruptionSignal();
+
 void requestTermination(const Poco::Process::PID& pid);
 
 /// Kills a child process and returns true when
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

2016-09-22 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp |   10 +-
 loolwsd/LOOLWSD.cpp |   13 +
 2 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit b8317e7b34120417885833926852657d4e7bce07
Author: Ashod Nakashian 
Date:   Wed Sep 21 18:12:34 2016 -0400

loolwsd: lokit process logs to file if configured

Pass the log-to-file config to the kit processes
using envars.

Change-Id: Ida79c35ab02d8038685153805be780359bfbe97e
Reviewed-on: https://gerrit.libreoffice.org/29161
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 36b7817..7c9f451 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1349,7 +1349,15 @@ void lokit_main(const std::string& childRoot,
 bool queryVersion)
 {
 // Reinitialize logging when forked.
-Log::initialize("kit", getenv("LOOL_LOGLEVEL"), getenv("LOOL_LOGCOLOR"));
+const bool logToFile = getenv("LOOL_LOGFILE");
+const auto logFilename = getenv("LOOL_LOGFILENAME");
+std::map logProperties;
+if (logToFile && logFilename)
+{
+logProperties["path"] = std::string(logFilename);
+}
+
+Log::initialize("kit", getenv("LOOL_LOGLEVEL"), getenv("LOOL_LOGCOLOR"), 
logToFile, logProperties);
 Util::rng::reseed();
 
 assert(!childRoot.empty());
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 266ac7c..15e9eca 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1403,7 +1403,9 @@ void LOOLWSD::initialize(Application& self)
 setenv("LOOL_LOGLEVEL", logLevel.c_str(), true);
 const auto withColor = !std::getenv("LOOL_NO_LOGCOLOR") && 
getConfigValue(conf, "logging.color", true);
 if (withColor)
+{
 setenv("LOOL_LOGCOLOR", "1", true);
+}
 
 const auto logToFile = getConfigValue(conf, "logging.file[@enable]", 
false);
 std::map logProperties;
@@ -1422,6 +1424,17 @@ void LOOLWSD::initialize(Application& self)
 }
 }
 
+// Setup the logfile envar for the kit processes.
+if (logToFile)
+{
+setenv("LOOL_LOGFILE", "1", true);
+const auto it = logProperties.find("path");
+if (it != logProperties.end())
+{
+setenv("LOOL_LOGFILENAME", it->second.c_str(), true);
+}
+}
+
 Log::initialize("wsd", logLevel, withColor, logToFile, logProperties);
 
 #if ENABLE_SSL
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

2016-09-19 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp |5 -
 loolwsd/LOOLWSD.cpp |8 
 2 files changed, 13 deletions(-)

New commits:
commit f0c09238ce0aa9772b182b1461af0a448332dda4
Author: Ashod Nakashian 
Date:   Sat Sep 17 08:42:25 2016 -0400

loolwsd: fail fast rather than catch all

Change-Id: Ib38924bf823315d211eb467d90f364fdc225ba2e
Reviewed-on: https://gerrit.libreoffice.org/29005
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 2e3fdb9..74ef66b 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -289,7 +289,6 @@ public:
 Util::setThreadName("kit_ws_" + _sessionId);
 
 Log::debug("Thread started.");
-
 try
 {
 auto queue = std::make_shared();
@@ -333,10 +332,6 @@ public:
 {
 Log::error(std::string("Connection::run: Exception: ") + 
exc.what());
 }
-catch (...)
-{
-Log::error("Connection::run:: Unexpected exception");
-}
 
 Log::debug("Thread finished.");
 }
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 57b996b..b496a1b 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -995,10 +995,6 @@ public:
 Log::error(std::string("ClientRequestHandler::handleRequest: 
Exception: ") + exc.what());
 
response.setStatusAndReason(HTTPResponse::HTTP_SERVICE_UNAVAILABLE);
 }
-catch (...)
-{
-Log::error("ClientRequestHandler::handleRequest:: Unexpected 
exception");
-}
 
 if (!responded)
 {
@@ -1190,10 +1186,6 @@ public:
 {
 Log::error(std::string("PrisonerRequestHandler::handleRequest: 
Exception: ") + exc.what());
 }
-catch (...)
-{
-Log::error("PrisonerRequestHandler::handleRequest:: Unexpected 
exception");
-}
 
 if (!jailId.empty())
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

2016-08-30 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp |5 +
 loolwsd/LOOLWSD.cpp |7 ---
 2 files changed, 9 insertions(+), 3 deletions(-)

New commits:
commit a674fc7e8fda162b7e84c75902d36cb9b9030650
Author: Ashod Nakashian 
Date:   Tue Aug 30 18:21:50 2016 -0400

loolwsd: logs and formatting

Change-Id: Ic3ec268cdc1962814654c7be676da62375494f66
Reviewed-on: https://gerrit.libreoffice.org/28524
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 944a029..a2ff02e 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1467,6 +1467,7 @@ void lokit_main(const std::string& childRoot,
 }
 else if (document && document->canDiscard())
 {
+Log::info("Last session discarded. Terminating.");
 TerminationFlag = true;
 }
 else
@@ -1480,7 +1481,11 @@ void lokit_main(const std::string& childRoot,
 [&document]()
 {
 if (document && document->canDiscard())
+{
+Log::info("Last session discarded. Terminating.");
 TerminationFlag = true;
+}
+
 return TerminationFlag.load();
 });
 
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 5749f9c..0988b4c 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -911,18 +911,18 @@ public:
 // http://server/hosting/discovery
 responded = handleGetWOPIDiscovery(request, response);
 }
-// All post requests have url prefix, lool
 else if (!(request.find("Upgrade") != request.end() && 
Poco::icompare(request["Upgrade"], "websocket") == 0) &&
  reqPathSegs.size() > 0 && reqPathSegs[0] == "lool")
 {
+// All post requests have url prefix 'lool'.
 responded = handlePostRequest(request, response, id);
 }
 else if (reqPathSegs.size() > 2 && reqPathSegs[0] == "lool" && 
reqPathSegs[1] == "ws")
 {
 auto ws = std::make_shared(request, response);
+responded = true; // After upgrading to WS we should not set 
HTTP response.
 try
 {
-responded = true; // After upgrading to WS we should not 
set HTTP response.
 handleGetRequest(request, ws, id);
 }
 catch (const WebSocketErrorMessageException& exc)
@@ -1868,9 +1868,10 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 else if (pid < 0)
 {
 Log::syserror("waitpid failed.");
-// No child processes
 if (errno == ECHILD)
 {
+// No child processes.
+Log::error("No Forkit instance. Terminating.");
 TerminationFlag = true;
 continue;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

2016-07-27 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp |1 +
 loolwsd/LOOLWSD.cpp |4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 1300b412fbeb00e465b689ee57a5a321cc7c4740
Author: Ashod Nakashian 
Date:   Wed Jul 27 10:57:08 2016 -0400

loolwsd: comments

Change-Id: I57ba646df6ceb24d4f101a5539c979e77130cfc9
Reviewed-on: https://gerrit.libreoffice.org/27589
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index bde9f50..e3b5ec1 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -743,6 +743,7 @@ private:
 return;
 }
 
+// Broadcast to all clients.
 for (auto& it: self->_connections)
 {
 if (it.second->isRunning())
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index f7b7bce..daa8946 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -683,13 +683,13 @@ private:
 
 // Wait until the client has connected with a prison socket.
 waitBridgeCompleted(session);
-// Now the bridge beetween the client and kit process is connected
-// Let messages flow
 
+// Now the bridge beetween the client and kit process is connected
 status = "statusindicator: ready";
 Log::trace("Sending to Client [" + status + "].");
 ws->sendFrame(status.data(), (int) status.size());
 
+// Let messages flow
 QueueHandler handler(queue, session, "wsd_queue_" + 
session->getId());
 Thread queueHandlerThread;
 queueHandlerThread.start(handler);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/loolwsd-systemplate-setup

2016-04-15 Thread Michael Meeks
 loolwsd/LOOLKit.cpp   |   42 --
 loolwsd/LOOLWSD.cpp   |1 
 loolwsd/loolwsd-systemplate-setup |8 ---
 3 files changed, 32 insertions(+), 19 deletions(-)

New commits:
commit ebfa339da02337274d332763b0e1ace952550f2a
Author: Michael Meeks 
Date:   Fri Apr 15 16:16:36 2016 +0100

Cleanup symlinking and add realpath symlink if necessary.

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 18b0da2..7f55ec9 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -16,6 +16,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
 #include 
 #include 
@@ -820,6 +823,27 @@ private:
 std::atomic_size_t _clientViews;
 };
 
+namespace {
+void symlinkPathToJail(const Path jailPath, const std::string &loTemplate,
+   const std::string &loSubPath)
+{
+Path symlinkSource(jailPath, Path(loTemplate.substr(1)));
+File(symlinkSource.parent()).createDirectories();
+
+std::string symlinkTarget;
+for (auto i = 0; i < Path(loTemplate).depth(); i++)
+symlinkTarget += "../";
+symlinkTarget += loSubPath;
+
+Log::debug("symlink(\"" + symlinkTarget + "\",\"" + 
symlinkSource.toString() + "\")");
+if (symlink(symlinkTarget.c_str(), symlinkSource.toString().c_str()) 
== -1)
+{
+Log::syserror("symlink(\"" + symlinkTarget + "\",\"" + 
symlinkSource.toString() + "\") failed");
+throw Exception("symlink() failed");
+}
+}
+}
+
 void lokit_main(const std::string& childRoot,
 const std::string& sysTemplate,
 const std::string& loTemplate,
@@ -861,19 +885,15 @@ void lokit_main(const std::string& childRoot,
 
 // Create a symlink inside the jailPath so that the absolute pathname 
loTemplate, when
 // interpreted inside a chroot at jailPath, points to loSubPath 
(relative to the chroot).
-Path symlinkSource(jailPath, Path(loTemplate.substr(1)));
-File(symlinkSource.parent()).createDirectories();
-
-std::string symlinkTarget;
-for (auto i = 0; i < Path(loTemplate).depth(); i++)
-symlinkTarget += "../";
-symlinkTarget += loSubPath;
+symlinkPathToJail(jailPath, loTemplate, loSubPath);
 
-Log::debug("symlink(\"" + symlinkTarget + "\",\"" + 
symlinkSource.toString() + "\")");
-if (symlink(symlinkTarget.c_str(), symlinkSource.toString().c_str()) 
== -1)
+// Font paths can end up as realpaths so match that too.
+char *resolved = realpath(loTemplate.c_str(), NULL);
+if (resolved)
 {
-Log::syserror("symlink(\"" + symlinkTarget + "\",\"" + 
symlinkSource.toString() + "\") failed");
-throw Exception("symlink() failed");
+if (strcmp(loTemplate.c_str(), resolved))
+symlinkPathToJail(jailPath, std::string(resolved), loSubPath);
+free (resolved);
 }
 
 Path jailLOInstallation(jailPath, loSubPath);
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 31ed0d2..db27edc 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -479,6 +479,7 @@ private:
 response.setStatus(HTTPResponse::HTTP_NOT_FOUND);
 response.setContentLength(0);
 response.send();
+Log::info("file not found.");
 }
 }
 else
diff --git a/loolwsd/loolwsd-systemplate-setup 
b/loolwsd/loolwsd-systemplate-setup
index d6539e3..27c760c 100755
--- a/loolwsd/loolwsd-systemplate-setup
+++ b/loolwsd/loolwsd-systemplate-setup
@@ -87,14 +87,6 @@ if [ -h usr/share/fonts/ghostscript ]; then
 cp -r -p /usr/share/ghostscript/fonts usr/share/ghostscript
 fi
 
-# Our Libreoffice install often comes with pre-bundled fonts.
-# we need to ensure that there is a link to these with the same
-# path that fontconfig found.
-mkdir -p ./lo
-mkdir -p ./$INSTDIR
-rmdir ./$INSTDIR
-ln -s /lo $CHROOT/$INSTDIR
-
 # Debugging only hackery to avoid confusion.
 if test "z$ENABLE_DEBUG" != "z" -a "z$HOME" != "z"; then
 echo "Copying development users's fonts into systemplate"
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

2016-04-03 Thread Michael Meeks
 loolwsd/LOOLKit.cpp |   22 ++
 loolwsd/LOOLWSD.cpp |2 --
 2 files changed, 10 insertions(+), 14 deletions(-)

New commits:
commit 9266ffc09fdea870cc66d6cb71b4a12dff361c43
Author: Michael Meeks 
Date:   Fri Apr 1 23:07:32 2016 +0100

Remove apparently un-necessary thread local variable template.

Change-Id: Ia220aff972827a0e49a8dadcdb8f32dcd3eed8c9
Reviewed-on: https://gerrit.libreoffice.org/23771
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 2794609..848dbf8 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -38,7 +38,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -68,7 +67,6 @@ using Poco::Process;
 using Poco::Runnable;
 using Poco::StringTokenizer;
 using Poco::Thread;
-using Poco::ThreadLocal;
 using Poco::Util::Application;
 
 const std::string FIFO_BROKER = "loolbroker.fifo";
@@ -78,20 +76,20 @@ static int writerNotify = -1;
 
 namespace
 {
-ThreadLocal sourceForLinkOrCopy;
-ThreadLocal destinationForLinkOrCopy;
+std::string sourceForLinkOrCopy;
+Path destinationForLinkOrCopy;
 
 int linkOrCopyFunction(const char *fpath,
const struct stat* /*sb*/,
int typeflag,
struct FTW* /*ftwbuf*/)
 {
-if (strcmp(fpath, sourceForLinkOrCopy->c_str()) == 0)
+if (strcmp(fpath, sourceForLinkOrCopy.c_str()) == 0)
 return 0;
 
-assert(fpath[strlen(sourceForLinkOrCopy->c_str())] == '/');
-const char *relativeOldPath = fpath + 
strlen(sourceForLinkOrCopy->c_str()) + 1;
-Path newPath(*destinationForLinkOrCopy, Path(relativeOldPath));
+assert(fpath[strlen(sourceForLinkOrCopy.c_str())] == '/');
+const char *relativeOldPath = fpath + 
strlen(sourceForLinkOrCopy.c_str()) + 1;
+Path newPath(destinationForLinkOrCopy, Path(relativeOldPath));
 
 switch (typeflag)
 {
@@ -153,10 +151,10 @@ namespace
 
 void linkOrCopy(const std::string& source, const Path& destination)
 {
-*sourceForLinkOrCopy = source;
-if (sourceForLinkOrCopy->back() == '/')
-sourceForLinkOrCopy->pop_back();
-*destinationForLinkOrCopy = destination;
+sourceForLinkOrCopy = source;
+if (sourceForLinkOrCopy.back() == '/')
+sourceForLinkOrCopy.pop_back();
+destinationForLinkOrCopy = destination;
 if (nftw(source.c_str(), linkOrCopyFunction, 10, FTW_ACTIONRETVAL) == 
-1)
 Log::error("linkOrCopy: nftw() failed for '" + source + "'");
 }
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 1dd6eef..033c2ec 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -101,7 +101,6 @@ DEALINGS IN THE SOFTWARE.
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -157,7 +156,6 @@ using Poco::StreamCopier;
 using Poco::StringTokenizer;
 using Poco::TemporaryFile;
 using Poco::Thread;
-using Poco::ThreadLocal;
 using Poco::ThreadPool;
 using Poco::URI;
 using Poco::Util::Application;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

2016-03-13 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp |   14 +++---
 loolwsd/LOOLWSD.cpp |   12 +---
 2 files changed, 20 insertions(+), 6 deletions(-)

New commits:
commit 8ef45a975e1ef950d4e754e43b82cda78f917847
Author: Ashod Nakashian 
Date:   Sat Mar 12 18:12:40 2016 -0500

loolwsd: child URI now includes docKey

Change-Id: I62b91fee98fd853c84c3c5cbb48e65e5c9788ef0
Reviewed-on: https://gerrit.libreoffice.org/23215
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 4fb6141..33aebe1 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define LOK_USE_UNSTABLE_API
 #include 
@@ -310,10 +311,12 @@ public:
 
 Document(LibreOfficeKit *loKit,
  const std::string& jailId,
+ const std::string& docKey,
  const std::string& url)
   : _multiView(std::getenv("LOK_VIEW_CALLBACK")),
 _loKit(loKit),
 _jailId(jailId),
+_docKey(docKey),
 _url(url),
 _loKitDocument(nullptr),
 _docPassword(""),
@@ -404,7 +407,7 @@ public:
 
 HTTPClientSession cs("127.0.0.1", MASTER_PORT_NUMBER);
 cs.setTimeout(0);
-HTTPRequest request(HTTPRequest::HTTP_GET, CHILD_URI + "sessionId=" + 
sessionId + "&jailId=" + _jailId);
+HTTPRequest request(HTTPRequest::HTTP_GET, CHILD_URI + "sessionId=" + 
sessionId + "&jailId=" + _jailId + "&docKey=" + _docKey);
 HTTPResponse response;
 
 auto ws = std::make_shared(cs, request, response);
@@ -734,6 +737,7 @@ private:
 const bool _multiView;
 LibreOfficeKit *_loKit;
 const std::string _jailId;
+const std::string _docKey;
 const std::string _url;
 std::string _jailedUrl;
 
@@ -1007,12 +1011,16 @@ void lokit_main(const std::string& childRoot,
 {
 const std::string& sessionId = tokens[1];
 const unsigned intSessionId = 
Util::decodeId(sessionId);
-const std::string& url = tokens[2];
+const std::string& docKey = tokens[2];
 
+std::string url;
+Poco::URI::decode(docKey, url);
 Log::debug("Thread request for session [" + sessionId 
+ "], url: [" + url + "].");
 auto it = _documents.lower_bound(url);
 if (it == _documents.end())
-it = _documents.emplace_hint(it, url, 
std::make_shared(loKit, jailId, url));
+{
+it = _documents.emplace_hint(it, url, 
std::make_shared(loKit, jailId, docKey, url));
+}
 
 it->second->createSession(sessionId, intSessionId);
 isUsedKit = true;
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 1e833d9..b295bb6 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -506,7 +506,8 @@ private:
 // Log::info("Cookie: " + cookies.get("PHPSESSID", ""));
 
 const auto uri = DocumentStoreManager::getUri(request.getURI());
-const auto docKey = uri.getPath();
+std::string docKey;
+Poco::URI::encode(uri.getPath(), "", docKey);
 
 // Request a kit process for this doc.
 const std::string aMessage = "request " + id + " " + docKey + "\r\n";
@@ -609,6 +610,7 @@ public:
 const auto params = 
Poco::URI(request.getURI()).getQueryParameters();
 std::string sessionId;
 std::string jailId;
+std::string docKey;
 for (const auto& param : params)
 {
 if (param.first == "sessionId")
@@ -619,16 +621,20 @@ public:
 {
 jailId = param.second;
 }
+else if (param.first == "docKey")
+{
+docKey = param.second;
+}
 }
 
-Log::debug("Child socket for SessionId: " + sessionId + ", jailId: 
" + jailId + " connected.");
-
 thread_name += sessionId;
 if (prctl(PR_SET_NAME, reinterpret_cast(thread_name.c_str()), 0, 0, 0) != 0)
 Log::error("Cannot set thread name to " + thread_name + ".");
 
 Log::debug("Thread [" + thread_name + "] started.");
 
+Log::debug("Child socket for SessionId: " + sessionId + ", jailId: 
" + jailId +
+   ", docKey: " + docKey + " connected.");
 auto ws = std::make_shared(request, response);
 auto session = std::make_shared(sessionId, 
LOOLSession::Kind::ToPrisoner, ws, nullptr);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

2016-01-14 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp |   76 +---
 loolwsd/LOOLWSD.cpp |3 +-
 2 files changed, 34 insertions(+), 45 deletions(-)

New commits:
commit c2af36d0ef99b509bd5087704c7afa8e61721ce7
Author: Ashod Nakashian 
Date:   Tue Jan 12 17:47:50 2016 -0500

loolwsd: simplified Connection

Change-Id: Ia7ff0d4b636513ce1b08641bb6db85c97ee5c2f9
Reviewed-on: https://gerrit.libreoffice.org/21468
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 2fa260d..2093825 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -316,30 +316,22 @@ private:
 class Connection: public Runnable
 {
 public:
-Connection(LibreOfficeKit *loKit, LibreOfficeKitDocument *loKitDocument,
-   const std::string& jailId, const std::string& sessionId,
-   std::function onLoad,
-   std::function onUnload) :
-_loKit(loKit),
-_loKitDocument(loKitDocument),
-_jailId(jailId),
-_sessionId(sessionId),
-_stop(false),
-_onLoad(onLoad),
-_onUnload(onUnload)
+Connection(std::shared_ptr session,
+   std::shared_ptr ws) :
+_session(session),
+_ws(ws),
+_stop(false)
 {
-Log::info("Connection ctor in child: " + _jailId + ", thread: " + 
_sessionId);
+Log::info("Connection ctor in child for " + _session->getId());
 }
 
 ~Connection()
 {
-Log::info("~Connection dtor in child: " + _jailId + ", thread: " + 
_sessionId);
+Log::info("~Connection dtor in child for " + _session->getId());
 stop();
 }
 
-const std::string& getSessionId() const { return _sessionId; }
 std::shared_ptr getWebSocket() const { return _ws; }
-
 std::shared_ptr getSession() { return _session; }
 
 void start()
@@ -364,7 +356,7 @@ public:
 
 void run() override
 {
-static const std::string thread_name = "kit_ws_" + _sessionId;
+static const std::string thread_name = "kit_ws_" + _session->getId();
 #ifdef __linux
 if (prctl(PR_SET_NAME, reinterpret_cast(thread_name.c_str()), 0, 0, 0) != 0)
 Log::error("Cannot set thread name to " + thread_name + ".");
@@ -373,23 +365,6 @@ public:
 
 try
 {
-// Open websocket connection between the child process and the
-// parent. The parent forwards us requests that it can't handle.
-
-HTTPClientSession cs("127.0.0.1", MASTER_PORT_NUMBER);
-cs.setTimeout(0);
-HTTPRequest request(HTTPRequest::HTTP_GET, CHILD_URI + _sessionId);
-HTTPResponse response;
-_ws = std::make_shared(cs, request, response);
-
-_session.reset(new ChildProcessSession(_sessionId, _ws, _loKit, 
_loKitDocument, _jailId, _onLoad, _onUnload));
-_ws->setReceiveTimeout(0);
-
-// child Jail TID PID
-std::string hello("child " + _jailId + " " +
-  _sessionId + " " + 
std::to_string(Process::id()));
-_session->sendTextFrame(hello);
-
 TileQueue queue;
 QueueHandler handler(queue, _session, "kit_queue_" + 
_session->getId());
 
@@ -405,9 +380,12 @@ public:
 
 if (n > 0 && (flags & WebSocket::FRAME_OP_BITMASK) != 
WebSocket::FRAME_OP_CLOSE)
 {
-std::string firstLine = getFirstLine(buffer, n);
+const std::string firstLine = getFirstLine(buffer, n);
 if (firstLine == "eof")
+{
+Log::info("Recieved EOF. Finishing.");
 break;
+}
 
 StringTokenizer tokens(firstLine, " ", 
StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 
@@ -446,16 +424,10 @@ public:
 }
 
 private:
-LibreOfficeKit *_loKit;
-LibreOfficeKitDocument *_loKitDocument;
-const std::string _jailId;
-const std::string _sessionId;
 Thread _thread;
 std::shared_ptr _session;
-volatile bool _stop;
-std::function _onLoad;
-std::function _onUnload;
 std::shared_ptr _ws;
+volatile bool _stop;
 };
 
 // A document container.
@@ -554,10 +526,26 @@ public:
 << " view for url: " << _url << "for thread: " << sessionId
 << " on child: " << _jailId << Log::end;
 
-auto thread = std::make_shared(_loKit, _loKitDocument, 
_jailId, sessionId,
-   [this](const std::string& 
id, const std::string& uri) { return onLoad(id, uri); },
-   [this](const std::string& 
id) { onUnload(id); });
+// Open websocket connection between the child process and the
+// parent. The parent forwards us requests that it can't handle.
+
+HTTPClientSession cs("127.0.0.1", M

[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp

2016-01-10 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp |4 ++--
 loolwsd/LOOLWSD.cpp |   26 +-
 2 files changed, 15 insertions(+), 15 deletions(-)

New commits:
commit f577e48f18c01616269159c839b25beda9a4355f
Author: Ashod Nakashian 
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 
Tested-by: Ashod Nakashian 

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(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(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(thread_name.c_str()), 0, 0, 0) != 0)
@@ -333,7 +334,6 @@ public:
 // Load the document.
 std::shared_ptr ws;
 const LOOLSession::Kind kind = LOOLSession::Kind::ToClient;
-const auto id = LOOLWSD::GenSessionId();
 auto session = std::make_shared(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(request, response);
-
-const std::string id = LOOLWSD::GenSessionId();
 auto session = std::make_shared(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(thread_name.c_str()), 0, 0, 0) != 0)
-Log::error("Cannot set thread name to " + thread_name + ".");
+if (prctl(PR_SET_NAME, reinterpret_cast(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(request, response);
-
-const std::string id;
 auto session = std::make_shared(id, 
LOOLSession::Kind::ToPrisoner, ws);
 
 SocketProcessor(ws, response, [&session](const char* data, const 
int size, bool)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/QueueHandler.hpp

2016-01-06 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp  |6 +-
 loolwsd/LOOLWSD.cpp  |   31 ++-
 loolwsd/QueueHandler.hpp |2 --
 3 files changed, 31 insertions(+), 8 deletions(-)

New commits:
commit 7bf3fe843a62061deff2f6c2f269c6713e4861f6
Author: Ashod Nakashian 
Date:   Wed Jan 6 09:13:21 2016 -0500

loolwsd: more exception handling

Change-Id: I7ac694395e2c231565bd84a7cd7813498dba387f
Reviewed-on: https://gerrit.libreoffice.org/21163
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index d468739..6c765ab 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -432,7 +432,7 @@ public:
 }
 catch (const Exception& exc)
 {
-Log::error() << exc.displayText()
+Log::error() << "Error: " << exc.displayText()
  << (exc.nested() ? " (" + exc.nested()->displayText() 
+ ")" : "")
  << Log::end;
 }
@@ -440,6 +440,10 @@ public:
 {
 Log::error(std::string("Exception: ") + exc.what());
 }
+catch (...)
+{
+Log::error("Unexpected Exception.");
+}
 
 Log::debug("Thread [" + thread_name + "] finished.");
 }
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 979bbb4..2669011 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -445,7 +445,8 @@ public:
 // FIXME: There is a race here when a request A gets in 
the queue and
 // is processed _after_ a later request B, because B gets 
processed
 // synchronously and A is waiting in the queue thread.
-// Fix is to push everything into the queue.
+// The fix is to push everything into the queue
+// (i.e. change MessageQueue to vector).
 if (singleLine)
 {
 const std::string firstLine = getFirstLine(data, size);
@@ -462,9 +463,19 @@ public:
 queue.put("eof");
 queueHandlerThread.join();
 }
-catch (const IOException& exc)
+catch (const Exception& exc)
 {
-Log::error("IOException: " + exc.message());
+Log::error() << "Error: " << exc.displayText()
+ << (exc.nested() ? " (" + exc.nested()->displayText() 
+ ")" : "")
+ << Log::end;
+}
+catch (const std::exception& exc)
+{
+Log::error(std::string("Exception: ") + exc.what());
+}
+catch (...)
+{
+Log::error("Unexpected Exception.");
 }
 
 Log::debug("Thread [" + thread_name + "] finished.");
@@ -501,9 +512,19 @@ public:
 return session->handleInput(data, size);
 });
 }
-catch (const IOException& exc)
+catch (const Exception& exc)
+{
+Log::error() << "Error: " << exc.displayText()
+ << (exc.nested() ? " (" + exc.nested()->displayText() 
+ ")" : "")
+ << Log::end;
+}
+catch (const std::exception& exc)
+{
+Log::error(std::string("Exception: ") + exc.what());
+}
+catch (...)
 {
-Log::error("IOException: " + exc.message());
+Log::error("Unexpected Exception.");
 }
 
 Log::debug("Thread [" + thread_name + "] finished.");
diff --git a/loolwsd/QueueHandler.hpp b/loolwsd/QueueHandler.hpp
index 5111382..759c175 100644
--- a/loolwsd/QueueHandler.hpp
+++ b/loolwsd/QueueHandler.hpp
@@ -48,12 +48,10 @@ public:
 catch (const std::exception& exc)
 {
 Log::error(std::string("Exception: ") + exc.what());
-raise(SIGABRT);
 }
 catch (...)
 {
 Log::error("Unexpected Exception.");
-raise(SIGABRT);
 }
 
 Log::debug("Thread [" + _name + "] finished.");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/QueueHandler.hpp

2016-01-06 Thread Ashod Nakashian
 loolwsd/LOOLKit.cpp  |2 -
 loolwsd/LOOLWSD.cpp  |   66 +++
 loolwsd/QueueHandler.hpp |   16 ++-
 3 files changed, 15 insertions(+), 69 deletions(-)

New commits:
commit f9cfdd902152bde395ce2289b072e19cf1073073
Author: Ashod Nakashian 
Date:   Wed Jan 6 08:38:21 2016 -0500

loolwsd: reuse QueueHandler

Change-Id: I90dd0cc1457604d85ec82c98af9a457f44968b0d
Reviewed-on: https://gerrit.libreoffice.org/21161
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index c352422..d468739 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -396,7 +396,7 @@ public:
 _session->sendTextFrame(hello);
 
 TileQueue queue;
-QueueHandler handler(queue, _session);
+QueueHandler handler(queue, _session, "kit_queue_" + 
_session->getId());
 
 Thread queueHandlerThread;
 queueHandlerThread.start(handler);
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 259b97e..03dc308 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -108,7 +108,7 @@ DEALINGS IN THE SOFTWARE.
 #include "MasterProcessSession.hpp"
 #include "ChildProcessSession.hpp"
 #include "LOOLWSD.hpp"
-#include "MessageQueue.hpp"
+#include "QueueHandler.hpp"
 #include "Util.hpp"
 
 using namespace LOOLProtocol;
@@ -151,58 +151,6 @@ using Poco::NamedMutex;
 using Poco::ProcessHandle;
 using Poco::URI;
 
-class QueueHandler: public Runnable
-{
-public:
-QueueHandler(MessageQueue& queue):
-_queue(queue)
-{
-}
-
-void setSession(std::shared_ptr session)
-{
-_session = session;
-}
-
-void run() override
-{
-static const std::string thread_name = "wsd_queue";
-#ifdef __linux
-if (prctl(PR_SET_NAME, reinterpret_cast(thread_name.c_str()), 0, 0, 0) != 0)
-Log::error("Cannot set thread name to " + thread_name + ".");
-#endif
-Log::debug("Thread [" + thread_name + "] started.");
-
-try
-{
-while (true)
-{
-const std::string input = _queue.get();
-if (input == "eof")
-break;
-if (!_session->handleInput(input.c_str(), input.size()))
-break;
-}
-}
-catch (const std::exception& exc)
-{
-Log::error(std::string("Exception: ") + exc.what());
-raise(SIGABRT);
-}
-catch (...)
-{
-Log::error("Unexpected Exception.");
-raise(SIGABRT);
-}
-
-Log::debug("Thread [" + thread_name + "] finished.");
-}
-
-private:
-std::shared_ptr _session;
-MessageQueue& _queue;
-};
-
 /// Handles the filename part of the convert-to POST request payload.
 class ConvertToPartHandler : public Poco::Net::PartHandler
 {
@@ -473,11 +421,6 @@ public:
 return;
 }
 
-BasicTileQueue queue;
-Thread queueHandlerThread;
-QueueHandler handler(queue);
-Poco::Timespan waitTime(POLL_TIMEOUT);
-
 try
 {
 auto ws = std::make_shared(request, response);
@@ -488,7 +431,10 @@ public:
 // For ToClient sessions, we store incoming messages in a queue 
and have a separate
 // thread that handles them. This is so that we can empty the 
queue when we get a
 // "canceltiles" message.
-handler.setSession(session);
+BasicTileQueue queue;
+QueueHandler handler(queue, session, "wsd_queue_" + 
session->getId());
+
+Thread queueHandlerThread;
 queueHandlerThread.start(handler);
 
 SocketProcessor(ws, response, [&session, &queue](const char* data, 
const int size, const bool singleLine)
@@ -540,8 +486,6 @@ public:
 #endif
 Log::debug("Thread [" + thread_name + "] started.");
 
-Poco::Timespan waitTime(POLL_TIMEOUT);
-
 try
 {
 auto ws = std::make_shared(request, response);
diff --git a/loolwsd/QueueHandler.hpp b/loolwsd/QueueHandler.hpp
index 5d07b9a..5111382 100644
--- a/loolwsd/QueueHandler.hpp
+++ b/loolwsd/QueueHandler.hpp
@@ -18,20 +18,21 @@
 class QueueHandler: public Poco::Runnable
 {
 public:
-QueueHandler(MessageQueue& queue, const std::shared_ptr& 
session):
+QueueHandler(MessageQueue& queue, const std::shared_ptr& 
session,
+ const std::string& name):
 _queue(queue),
-_session(session)
+_session(session),
+_name(name)
 {
 }
 
 void run() override
 {
-static const std::string thread_name = "kit_queue_" + 
_session->getId();
 #ifdef __linux
-if (prctl(PR_SET_NAME, reinterpret_cast(thread_name.c_str()), 0, 0, 0) != 0)
-Log::error("Cannot set thread name to " + thread_name + ".");
+if (prctl(PR_SET_NAME, reinterpret_cast