loolwsd/LOOLBroker.cpp | 8 ++++++-- loolwsd/LOOLKit.cpp | 36 +++++++++++++++++++++++++++++------- loolwsd/LOOLWSD.cpp | 17 ++++++++++++----- 3 files changed, 47 insertions(+), 14 deletions(-)
New commits: commit fe0c11333f096a69ed29feb5b6b62931b2f489ab Author: Ashod Nakashian <[email protected]> Date: Sat Dec 26 11:33:01 2015 -0500 loolwsd: thread lifecycle markers Change-Id: I704e37e797224c9dbd024fcab3d8e917584be152 Reviewed-on: https://gerrit.libreoffice.org/20975 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp index bb3e3b7..99e4e8d 100644 --- a/loolwsd/LOOLBroker.cpp +++ b/loolwsd/LOOLBroker.cpp @@ -440,10 +440,12 @@ public: pStart = aBuffer; pEnd = aBuffer; + static const std::string thread_name = "broker_pipe_reader"; #ifdef __linux - if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("pipe_reader"), 0, 0, 0) != 0) - Log::error("Cannot set 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."); while (true) { @@ -497,6 +499,8 @@ public: } } } + + Log::debug("Thread [" + thread_name + "] finished."); } private: diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index 28cb506..3745089 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -234,6 +234,13 @@ public: void run() { + static const std::string thread_name = "lokit_callback_handler"; +#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 + "."); +#endif + Log::debug("Thread [" + thread_name + "] started."); + while ( true ) { Notification::Ptr aNotification(_queue.waitDequeueNotification()); @@ -268,6 +275,8 @@ public: } else break; } + + Log::debug("Thread [" + thread_name + "] finished."); } private: @@ -290,10 +299,13 @@ public: void run() override { + static const std::string thread_name = "lokit_queue_handler"; #ifdef __linux - if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("queue_handler"), 0, 0, 0) != 0) - Log::error("Cannot set 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."); + try { while (true) @@ -315,6 +327,8 @@ public: Log::error("Unexpected Exception."); raise(SIGABRT); } + + Log::debug("Thread [" + thread_name + "] finished."); } private: @@ -351,10 +365,13 @@ public: void run() override { + static const std::string thread_name = "lokit_connection"; #ifdef __linux - if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("lokit_connection"), 0, 0, 0) != 0) - Log::error("Cannot set 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."); + try { // Open websocket connection between the child process and the @@ -414,6 +431,8 @@ public: { Log::error(std::string("Exception: ") + exc.what()); } + + Log::debug("Thread [" + thread_name + "] finished."); } ~Connection() @@ -453,10 +472,12 @@ void run_lok_main(const std::string &loSubPath, Poco::UInt64 _childId, const std assert (_childId != 0); assert (!loSubPath.empty()); + static const std::string thread_name = "libreofficekit"; #ifdef __linux - if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("libreofficekit"), 0, 0, 0) != 0) - Log::error("Cannot set 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."); static const std::string instdir_path = #ifdef __APPLE__ @@ -644,7 +665,7 @@ void run_lok_main(const std::string &loSubPath, Poco::UInt64 _childId, const std // Destroy LibreOfficeKit loKit->pClass->destroy(loKit.get()); - Log::info("Kit process " + std::to_string(Process::id()) + " finished."); + Log::debug("Thread [" + thread_name + "] finished."); } #ifndef LOOLKIT_NO_MAIN @@ -720,6 +741,7 @@ int main(int argc, char** argv) run_lok_main(loSubPath, _childId, _pipe); + Log::info("loolkit finished OK!"); return 0; } diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index a046ad2..5d80a7e 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -244,10 +244,12 @@ public: void run() override { + static const std::string thread_name = "wsd_pipe_reader"; #ifdef __linux - if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>("queue_handler"), 0, 0, 0) != 0) - Log::error("Cannot set 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."); while (true) { @@ -257,6 +259,8 @@ public: if (!_session->handleInput(input.c_str(), input.size())) break; } + + Log::debug("Thread [" + thread_name + "] finished."); } private: @@ -301,8 +305,8 @@ public: } }; +/// Handle a WebSocket connection or a simple HTTP request. class RequestHandler: public HTTPRequestHandler - /// Handle a WebSocket connection or a simple HTTP request. { public: RequestHandler() @@ -311,16 +315,17 @@ public: void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response) override { -#ifdef __linux std::string thread_name; if (request.serverAddress().port() == LOOLWSD::MASTER_PORT_NUMBER) thread_name = "prision_socket"; else thread_name = "client_socket"; +#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."); + Log::error("Cannot set thread name to " + thread_name + "."); #endif + Log::debug("Thread [" + thread_name + "] started."); if (!(request.find("Upgrade") != request.end() && Poco::icompare(request["Upgrade"], "websocket") == 0)) { @@ -542,6 +547,8 @@ public: { Log::error("IOException: " + exc.message()); } + + Log::debug("Thread [" + thread_name + "] finished."); } }; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
