summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-04-06 01:32:39 -0400
committerJan Holesovsky <kendy@collabora.com>2017-04-07 16:28:52 +0200
commit816b9933a8cf9731645b1274bba327c49109eb7a (patch)
tree3c53c3ff3f32221c6f4fedd97df4c0faffbe1d87 /net
parente96ac2ece6cfc4cc3d806ee1d8c92b1bcaca415d (diff)
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@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'net')
-rw-r--r--net/Socket.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/net/Socket.hpp b/net/Socket.hpp
index ad59bbfb0..cd1ea6cc4 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();
}