[Libreoffice-commits] online.git: net/Socket.cpp net/Socket.hpp wsd/DocumentBroker.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Mar 13 04:23:37 UTC 2017
net/Socket.cpp | 3 ++-
net/Socket.hpp | 5 +++++
wsd/DocumentBroker.cpp | 12 +++++-------
3 files changed, 12 insertions(+), 8 deletions(-)
New commits:
commit 9248107702745f37d321b5b31a22e9dc7a1963ec
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Mar 12 22:11:25 2017 -0400
wsd: SocketPoll reports thread isAlive and use in DocBroker
Now that DocumentBroker has SocketPoll thread,
it's isAlive() must be defined by the lifetime of
both the SocketPoll thread and the ChildProcess,
which it previously did.
Change-Id: I093f8774cf4374d01729a383f6c535de4143fec6
Reviewed-on: https://gerrit.libreoffice.org/35122
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/net/Socket.cpp b/net/Socket.cpp
index 48bc696..de41e34 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -35,7 +35,8 @@ namespace {
SocketPoll::SocketPoll(const std::string& threadName)
: _name(threadName),
_stop(false),
- _threadStarted(false)
+ _threadStarted(false),
+ _threadFinished(false)
{
// Create the wakeup fd.
if (::pipe2(_wakeup, O_CLOEXEC | O_NONBLOCK) == -1)
diff --git a/net/Socket.hpp b/net/Socket.hpp
index c4badea..4fe334b 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -262,6 +262,8 @@ public:
wakeup();
}
+ bool isAlive() const { return _threadStarted && !_threadFinished; }
+
/// Check if we should continue polling
virtual bool continuePolling()
{
@@ -280,6 +282,8 @@ public:
{
poll(DefaultPollTimeoutMs);
}
+
+ _threadFinished = true;
}
/// Are we running in either shutdown, or the polling thread.
@@ -478,6 +482,7 @@ protected:
/// The polling thread.
std::thread _thread;
std::atomic<bool> _threadStarted;
+ std::atomic<bool> _threadFinished;
std::thread::id _owner;
};
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 9e2087f..25686bf 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -152,6 +152,7 @@ DocumentBroker::DocumentBroker(const std::string& uri,
_cursorWidth(0),
_cursorHeight(0),
_poll(new DocumentBrokerPoll("docbrk_poll", *this)),
+ _stop(false),
_tileVersion(0),
_debugRenderedTileCount(0)
{
@@ -159,8 +160,6 @@ DocumentBroker::DocumentBroker(const std::string& uri,
assert(!_childRoot.empty());
LOG_INF("DocumentBroker [" << _uriPublic.toString() << "] created. DocKey: [" << _docKey << "]");
-
- _stop = false;
}
// The inner heart of the DocumentBroker - our poll loop.
@@ -248,12 +247,11 @@ void DocumentBroker::pollThread()
bool DocumentBroker::isAlive() const
{
- if (!_childProcess)
- return true; // waiting to get a child.
- if (_stop) // we're dead.
- return false;
+ if (_poll->isAlive())
+ return true; // Polling thread still running.
- return _childProcess->isAlive();
+ // Shouldn't have live child process outside of the polling thread.
+ return _childProcess && _childProcess->isAlive();
}
DocumentBroker::~DocumentBroker()
More information about the Libreoffice-commits
mailing list