From 2d1764d30eb1fa5b6434291e9dde6551611de243 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Wed, 5 Apr 2017 17:59:29 +0100 Subject: [PATCH] Dump ClientSession and MessageQueue state too. --- common/Session.cpp | 22 ++++++++++++++++++++++ common/Session.hpp | 2 ++ wsd/ClientSession.cpp | 1 + wsd/SenderQueue.hpp | 11 +++++++++++ 4 files changed, 36 insertions(+) diff --git a/common/Session.cpp b/common/Session.cpp index 9dcb5329fc..69696fb3b9 100644 --- a/common/Session.cpp +++ b/common/Session.cpp @@ -198,4 +198,26 @@ void Session::handleMessage(bool /*fin*/, WSOpCode /*code*/, std::vector & } } +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 2b460d4325..b67466e397 100644 --- a/common/Session.hpp +++ b/common/Session.hpp @@ -100,6 +100,8 @@ protected: return std::unique_lock(_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 8eca9d8023..d70d18c8b9 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 77f09770cb..af8199f132 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 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