net/Socket.hpp         |    3 +++
 wsd/DocumentBroker.cpp |    5 +++++
 wsd/DocumentBroker.hpp |    3 +++
 wsd/LOOLWSD.cpp        |    4 ++--
 4 files changed, 13 insertions(+), 2 deletions(-)

New commits:
commit df8dc43be4980302d4287c0692d02cf4fe6ca253
Author: Michael Meeks <michael.me...@collabora.com>
Date:   Wed Apr 5 21:48:51 2017 +0100

    Don't cleanup DocumentBrokers that still have their thread running.
    
    Plenty of time to do that next time around the cleanup.
    We should still, really be doing the majority of the timeout work
    inside the DocumentBroker poll itself.

diff --git a/net/Socket.hpp b/net/Socket.hpp
index c726f337..42238751 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -500,6 +500,9 @@ public:
     /// Stop and join the polling thread before returning (if active)
     void joinThread();
 
+    /// Did our thread complete its execution
+    bool isThreadFinished() { return _threadFinished; }
+
 private:
     /// Initialize the poll fds array with the right events
     void setupPollFds(std::chrono::steady_clock::time_point now,
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a5a995df..9515fbb4 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -305,6 +305,11 @@ DocumentBroker::~DocumentBroker()
     _childProcess.reset();
 }
 
+bool DocumentBroker::isThreadFinished()
+{
+    return _poll->isThreadFinished();
+}
+
 void DocumentBroker::joinThread()
 {
     _poll->joinThread();
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index d05437e9..11d50174 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -227,6 +227,9 @@ public:
     /// Thread safe termination of this broker if it has a lingering thread
     void joinThread();
 
+    /// Is our polling thread safely out of the way
+    bool isThreadFinished();
+
     /// Loads a document from the public URI into the jail.
     bool load(const 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 e5d4cb68..1c446462 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -250,8 +250,8 @@ void cleanupDocBrokers()
                         " DocumentBroker for docKey [" << it->first << "].");
                 docBroker->stop();
 
-                // Remove only when not alive.
-                if (!docBroker->isAlive())
+                // Remove only on next pass when the thread is finished.
+                if (docBroker->isThreadFinished() && !docBroker->isAlive())
                 {
                     LOG_INF("Removing " << (idle ? "idle" : "dead") <<
                             " DocumentBroker for docKey [" << it->first << 
"].");
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to