[Libreoffice-commits] online.git: net/Socket.cpp net/Socket.hpp wsd/LOOLWSD.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Mon May 15 03:10:49 UTC 2017


 net/Socket.cpp  |    1 +
 net/Socket.hpp  |    3 +++
 wsd/LOOLWSD.cpp |    3 +++
 3 files changed, 7 insertions(+)

New commits:
commit 7cff4fb08a2dba769a992300d24c0d5c3192b0a9
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun May 14 21:42:10 2017 -0400

    wsd: fix server shutdown
    
    Thread-affinity checks must be inhibited
    not just on Socket, but on the SocketPoll as well,
    before destroying DocumentBroker instances.
    
    Also, properly initialize the inhibit statics.
    
    Change-Id: I2ced1554d477f0c3faf09bda74034cbae99e4ce1
    Reviewed-on: https://gerrit.libreoffice.org/37608
    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 97018c86..06afce83 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -25,6 +25,7 @@
 #include "WebSocketHandler.hpp"
 
 int SocketPoll::DefaultPollTimeoutMs = 5000;
+std::atomic<bool> SocketPoll::InhibitThreadChecks(false);
 std::atomic<bool> Socket::InhibitThreadChecks(false);
 
 // help with initialization order
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 0468eb9c..7c7b55ab 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -317,6 +317,7 @@ public:
 
     /// Default poll time - useful to increase for debugging.
     static int DefaultPollTimeoutMs;
+    static std::atomic<bool> InhibitThreadChecks;
 
     /// Stop the polling thread.
     void stop()
@@ -368,6 +369,8 @@ public:
     /// Asserts in the debug builds, otherwise just logs.
     void assertCorrectThread() const
     {
+        if (InhibitThreadChecks)
+            return;
         // 0 owner means detached and can be invoked by any thread.
         const bool sameThread = (!isAlive() || _owner == std::thread::id(0) || std::this_thread::get_id() == _owner);
         if (!sameThread)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8c116654..8598d763 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2221,6 +2221,7 @@ public:
     {
         // FIXME: add some stop-world magic before doing the dump(?)
         Socket::InhibitThreadChecks = true;
+        SocketPoll::InhibitThreadChecks = true;
 
         os << "LOOLWSDServer:\n"
            << "  Ports: server " << ClientPortNumber
@@ -2254,6 +2255,7 @@ public:
             i.second->dumpState(os);
 
         Socket::InhibitThreadChecks = false;
+        SocketPoll::InhibitThreadChecks = false;
     }
 
 private:
@@ -2532,6 +2534,7 @@ int LOOLWSD::innerMain()
 
     // Disable thread checking - we'll now cleanup lots of things if we can
     Socket::InhibitThreadChecks = true;
+    SocketPoll::InhibitThreadChecks = true;
 
     DocBrokers.clear();
 


More information about the Libreoffice-commits mailing list