[Libreoffice-commits] online.git: 2 commits - common/Session.cpp common/Session.hpp net/Socket.cpp net/Socket.hpp wsd/ClientSession.cpp wsd/LOOLWSD.cpp wsd/SenderQueue.hpp

Michael Meeks michael.meeks at collabora.com
Wed Apr 5 17:00:38 UTC 2017


 common/Session.cpp    |   22 ++++++++++++++++++++++
 common/Session.hpp    |    2 ++
 net/Socket.cpp        |    1 +
 net/Socket.hpp        |    3 +++
 wsd/ClientSession.cpp |    1 +
 wsd/LOOLWSD.cpp       |    7 ++++++-
 wsd/SenderQueue.hpp   |   11 +++++++++++
 7 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 2d1764d30eb1fa5b6434291e9dde6551611de243
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Apr 5 17:59:29 2017 +0100

    Dump ClientSession and MessageQueue state too.

diff --git a/common/Session.cpp b/common/Session.cpp
index 9dcb5329..69696fb3 100644
--- a/common/Session.cpp
+++ b/common/Session.cpp
@@ -198,4 +198,26 @@ void Session::handleMessage(bool /*fin*/, WSOpCode /*code*/, std::vector<char> &
     }
 }
 
+void Session::dumpState(std::ostream& os)
+{
+    WebSocketHandler::dumpState(os);
+
+    os <<   "\t\tid: " << _id
+       << "\n\t\tname: " << _name
+       << "\n\t\tdisconnected: " << _disconnected
+       << "\n\t\tisActive: " << _isActive
+       << "\n\t\tisCloseFrame: " << _isCloseFrame
+       << "\n\t\tisReadOnly: " << _isReadOnly
+       << "\n\t\tdocURL: " << _docURL
+       << "\n\t\tjailedFilePath: " << _jailedFilePath
+       << "\n\t\tdocPwd: " << _docPassword
+       << "\n\t\thaveDocPwd: " << _haveDocPassword
+       << "\n\t\tisDocPwdProtected: " << _isDocPasswordProtected
+       << "\n\t\tDocOptions: " << _docOptions
+       << "\n\t\tuserId: " << _userId
+       << "\n\t\tuserName: " << _userName
+       << "\n\t\tlang: " << _lang
+       << "\n";
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/common/Session.hpp b/common/Session.hpp
index 2b460d43..b67466e3 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -100,6 +100,8 @@ protected:
         return std::unique_lock<std::mutex>(_mutex);
     }
 
+    void dumpState(std::ostream& os) override;
+
 private:
     virtual bool _handleInput(const char* buffer, int length) = 0;
 
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 8eca9d80..d70d18c8 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -792,6 +792,7 @@ void ClientSession::dumpState(std::ostream& os)
        << "\n\t\tisAttached: " << _isAttached
        << "\n\t\tstop: " <<_stop
        << "\n";
+    _senderQueue.dumpState(os);
 }
 
 
diff --git a/wsd/SenderQueue.hpp b/wsd/SenderQueue.hpp
index 77f09770..af8199f1 100644
--- a/wsd/SenderQueue.hpp
+++ b/wsd/SenderQueue.hpp
@@ -87,6 +87,17 @@ public:
         return _queue.size();
     }
 
+    void dumpState(std::ostream& os)
+    {
+        os << "\n\t\tqueue size " << _queue.size() << "\n";
+        std::lock_guard<std::mutex> lock(_mutex);
+        for (const Item &item : _queue)
+        {
+            os << "\t\t\ttype: " << (item->isBinary() ? "binary" : "text") << "\n";
+            os << "\t\t\t" << item->abbr() << "\n";
+        }
+    }
+
 private:
     /// Deduplicate messages based on the new one.
     /// Returns true if the new message should be
commit 185540bcde22baaaa66d530f224ffdfbc5130560
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Apr 5 17:58:52 2017 +0100

    Inhibit thread checks for SIGUSR1 handling.
    
    USR1 handling is not thread-safe; we walk the structures and hope.

diff --git a/net/Socket.cpp b/net/Socket.cpp
index 55bd4fb5..21ab00f2 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -24,6 +24,7 @@
 #include "WebSocketHandler.hpp"
 
 int SocketPoll::DefaultPollTimeoutMs = 5000;
+std::atomic<bool> Socket::InhibitThreadChecks(false);
 
 // help with initialization order
 namespace {
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 3692bd10..6bca6abf 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -44,6 +44,7 @@ class Socket
 public:
     static const int DefaultSendBufferSize = 16 * 1024;
     static const int MaximumSendBufferSize = 128 * 1024;
+    static std::atomic<bool> InhibitThreadChecks;
 
     Socket() :
         _fd(socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0)),
@@ -194,6 +195,8 @@ public:
     /// Asserts in the debug builds, otherwise just logs.
     virtual void assertCorrectThread()
     {
+        if (InhibitThreadChecks)
+            return;
         // 0 owner means detached and can be invoked by any thread.
         const bool sameThread = (_owner == std::thread::id(0) || std::this_thread::get_id() == _owner);
         if (!sameThread)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 196a1c5d..408d49d4 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2192,8 +2192,11 @@ public:
 
     void dumpState(std::ostream& os)
     {
+        // FIXME: add some stop-world magic before doing the dump(?)
+        Socket::InhibitThreadChecks = true;
+
         os << "LOOLWSDServer:\n"
-           << "   Ports: server " << ClientPortNumber
+           << "  Ports: server " << ClientPortNumber
            <<          " prisoner " << MasterPortNumber << "\n"
            << "  TerminationFlag: " << TerminationFlag << "\n"
            << "  isShuttingDown: " << ShutdownRequestFlag << "\n"
@@ -2217,6 +2220,8 @@ public:
                   << "[ " << DocBrokers.size() << " ]:\n";
         for (auto &i : DocBrokers)
             i.second->dumpState(os);
+
+        Socket::InhibitThreadChecks = false;
     }
 
 private:


More information about the Libreoffice-commits mailing list