net/Socket.cpp | 1 + net/Socket.hpp | 9 ++++++--- wsd/DocumentBroker.cpp | 1 + wsd/LOOLWSD.cpp | 6 +++--- 4 files changed, 11 insertions(+), 6 deletions(-)
New commits: commit 3d03a0fb5d9a4dcb69202816f142943578c58f8a Author: Ashod Nakashian <[email protected]> Date: Thu Apr 6 02:56:21 2017 -0400 wsd: accomodate accept_poll shutdown When shutting down accept_poll from main, we can't remove sockets or cleanup. That work needs to be done fro within accept_poll's thread. This is different from when DocBroker's poll needs to cleanup its own sockets before it exists. So we split the stop and removeSockets so they can each be called in the proper way. For accept_poll and others that joinThread we queue a callback to cleanup before stopping. Change-Id: If780d6a97ac0fc6da6897f895d5b4dda443f9e73 Reviewed-on: https://gerrit.libreoffice.org/36186 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/net/Socket.cpp b/net/Socket.cpp index 21ab00f2..5850e9c4 100644 --- a/net/Socket.cpp +++ b/net/Socket.cpp @@ -96,6 +96,7 @@ void SocketPoll::startThread() void SocketPoll::joinThread() { + addCallback([this](){ removeSockets(); }); stop(); if (_threadStarted && _thread.joinable()) { diff --git a/net/Socket.hpp b/net/Socket.hpp index cd1ea6cc..bb08dca1 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -264,9 +264,14 @@ public: /// Stop the polling thread. void stop() { - LOG_DBG("Stopping " << _name << " and removing all sockets."); + LOG_DBG("Stopping " << _name << "."); _stop = true; + wakeup(); + } + void removeSockets() + { + LOG_DBG("Removing all sockets from " << _name << "."); assert(socket); assertCorrectThread(); @@ -280,8 +285,6 @@ public: _pollSockets.pop_back(); } - - wakeup(); } bool isAlive() const { return _threadStarted && !_threadFinished; } diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 8dd3fa42..1b6f5d45 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -266,6 +266,7 @@ void DocumentBroker::pollThread() // Stop to mark it done and cleanup. _poll->stop(); + _poll->removeSockets(); // Async cleanup. LOOLWSD::doHousekeeping(); diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index ac721294..e5d4cb68 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -2474,9 +2474,6 @@ int LOOLWSD::innerMain() LOG_INF("Stopping server socket listening. ShutdownFlag: " << ShutdownRequestFlag << ", TerminationFlag: " << TerminationFlag); - // Disable thread checking - we'll now cleanup lots of things if we can - Socket::InhibitThreadChecks = true; - // Wait until documents are saved and sessions closed. srv.stop(); @@ -2485,6 +2482,9 @@ int LOOLWSD::innerMain() for (auto& docBrokerIt : DocBrokers) docBrokerIt.second->joinThread(); + // Disable thread checking - we'll now cleanup lots of things if we can + Socket::InhibitThreadChecks = true; + DocBrokers.clear(); #ifndef KIT_IN_PROCESS _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
