[Libreoffice-commits] online.git: net/Socket.hpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp
Michael Meeks
michael.meeks at collabora.com
Mon Mar 13 12:13:45 UTC 2017
net/Socket.hpp | 1 -
wsd/DocumentBroker.cpp | 5 +++++
wsd/DocumentBroker.hpp | 8 ++++----
wsd/LOOLWSD.cpp | 6 +++++-
4 files changed, 14 insertions(+), 6 deletions(-)
New commits:
commit 97e9463f173c833ce9d4b0503ea865ebd70a7a33
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Mon Mar 13 12:00:31 2017 +0000
Revert "wsd: TerminatingPoll always starts its own thread"
This reverts commit 388d7b1dbf1a5c2d155c0149247b3a319114f8b0.
It is vital to have clean control of thread start. By starting
a thread during init. of a member (or base-clase) we loose lots of
control, some examples:
Any members initialized after a member that auto-starts a
thread, is effectively un-defined, and cannot be accessed
reliably.
This is particularly problematic for sub-classes.
I've seen threads started before the base-class has
finished constructing in the original creating thread -
such that the vtable was not yet updated to the sub-class
causing the transient parent vtable used during construction
to be used in-error.
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 5cced5f..16c0cdc 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -435,7 +435,6 @@ public:
const std::string& name() const { return _name; }
-protected:
/// Start the polling thread (if desired)
void startThread();
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a53a7c1..04fe5ac 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -162,6 +162,11 @@ DocumentBroker::DocumentBroker(const std::string& uri,
LOG_INF("DocumentBroker [" << _uriPublic.toString() << "] created. DocKey: [" << _docKey << "]");
}
+void DocumentBroker::startThread()
+{
+ _poll->startThread();
+}
+
// The inner heart of the DocumentBroker - our poll loop.
void DocumentBroker::pollThread()
{
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 8d7eb2a..8d36cb2 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -44,10 +44,7 @@ class TerminatingPoll : public SocketPoll
{
public:
TerminatingPoll(const std::string &threadName) :
- SocketPoll(threadName)
- {
- startThread();
- }
+ SocketPoll(threadName) {}
bool continuePolling() override
{
@@ -221,6 +218,9 @@ public:
~DocumentBroker();
+ /// Start processing events
+ void startThread();
+
/// Loads a document from the public URI into the jail.
bool load(std::shared_ptr<ClientSession>& session, const std::string& jailId);
bool isLoaded() const { return _isLoaded; }
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 97cf845..b4d42ab 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2177,6 +2177,7 @@ private:
void handleClientWsUpgrade(const Poco::Net::HTTPRequest& request, const std::string& url)
{
+ // requestHandler = new ClientRequestHandler();
LOG_INF("Client WS request" << request.getURI() << ", url: " << url);
// First Upgrade.
@@ -2230,9 +2231,9 @@ private:
_clientSession->onConnect(socket);
docBroker->addSocketToPoll(socket);
}
+ docBroker->startThread();
}
}
-
if (!docBroker || !_clientSession)
LOG_WRN("Failed to connect DocBroker and Client Session.");
}
@@ -2358,11 +2359,14 @@ public:
void startPrisoners(const int port)
{
PrisonerPoll.insertNewSocket(findPrisonerServerPort(port));
+ PrisonerPoll.startThread();
}
void start(const int port)
{
_acceptPoll.insertNewSocket(findServerPort(port));
+ _acceptPoll.startThread();
+ WebServerPoll.startThread();
}
void stop()
More information about the Libreoffice-commits
mailing list