[Libreoffice-commits] online.git: net/Socket.hpp wsd/DocumentBroker.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Thu Apr 6 06:19:29 UTC 2017
net/Socket.hpp | 18 +++++++++++++++++-
wsd/DocumentBroker.cpp | 3 +++
2 files changed, 20 insertions(+), 1 deletion(-)
New commits:
commit 4a7a0fb477a376e5c281208525777c2a926f8c6a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu Apr 6 01:32:39 2017 -0400
wsd: remove sockets when stopping poll thread
And assume correct thread if poll thread is
not running (i.e. no race).
Change-Id: I17958e682aba434ebb47fe0de199b9f530b54dee
Reviewed-on: https://gerrit.libreoffice.org/36183
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/net/Socket.hpp b/net/Socket.hpp
index d1a59b22..cd1ea6cc 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -264,7 +264,23 @@ public:
/// Stop the polling thread.
void stop()
{
+ LOG_DBG("Stopping " << _name << " and removing all sockets.");
_stop = true;
+
+ assert(socket);
+ assertCorrectThread();
+
+ while (!_pollSockets.empty())
+ {
+ const std::shared_ptr<Socket>& socket = _pollSockets.back();
+
+ LOG_DBG("Removing socket #" << socket->getFD() << " from " << _name);
+ socket->assertCorrectThread();
+ socket->setThreadOwner(std::thread::id(0));
+
+ _pollSockets.pop_back();
+ }
+
wakeup();
}
@@ -293,7 +309,7 @@ public:
void assertCorrectThread() const
{
// 0 owner means detached and can be invoked by any thread.
- const bool sameThread = (_owner == std::thread::id(0) || std::this_thread::get_id() == _owner);
+ const bool sameThread = (!isAlive() || _owner == std::thread::id(0) || std::this_thread::get_id() == _owner);
if (!sameThread)
LOG_ERR("Incorrect thread affinity for " << _name << ". Expected: 0x" << std::hex <<
_owner << " (" << std::dec << Util::getThreadId() << ") but called from 0x" <<
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 396bf52b..3ab3d121 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -264,6 +264,9 @@ void DocumentBroker::pollThread()
_poll->poll(std::min(flushTimeoutMs - elapsedMs, POLL_TIMEOUT_MS / 5));
}
+ // Stop to mark it done and cleanup.
+ _poll->stop();
+
// Async cleanup.
LOOLWSD::doHousekeeping();
More information about the Libreoffice-commits
mailing list