loolwsd/LOOLBroker.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
New commits: commit 94c30334081265ca1dd308784998b07cf5843e61 Author: Ashod Nakashian <[email protected]> Date: Mon Apr 4 20:46:11 2016 -0400 loolwsd: wait for the Connection thread to exit before destroying Also, the thread is joinable only once. Change-Id: Ia0d8e4c350a6bedcf15873c751fffa837460e4bf Reviewed-on: https://gerrit.libreoffice.org/23821 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp index 072e8ff..14b6299 100644 --- a/loolwsd/LOOLBroker.cpp +++ b/loolwsd/LOOLBroker.cpp @@ -28,7 +28,6 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <Poco/Exception.h> -#include <Poco/Mutex.h> #include <Poco/Net/HTTPClientSession.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> @@ -242,6 +241,7 @@ public: { Log::info("~Connection dtor in child for " + _session->getId()); stop(); + join(); } std::shared_ptr<WebSocket> getWebSocket() const { return _ws; } @@ -264,7 +264,13 @@ public: void join() { - _thread.join(); + // The thread is joinable only once. + std::unique_lock<std::mutex> lock(_threadMutex); + if (!_joined) + { + _thread.join(); + _joined = true; + } } void handle(std::shared_ptr<TileQueue> queue, const std::string& firstLine, char* buffer, int n) @@ -369,7 +375,9 @@ private: Thread _thread; std::shared_ptr<ChildProcessSession> _session; std::shared_ptr<WebSocket> _ws; - volatile bool _stop; + std::atomic<unsigned> _stop; + std::mutex _threadMutex; + std::atomic<unsigned> _joined; }; /// A document container. _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
