loolwsd/LOOLSession.cpp | 14 ++++------ loolwsd/LOOLSession.hpp | 62 ++++++++++++++++++------------------------------ loolwsd/LOOLWSD.cpp | 2 - 3 files changed, 30 insertions(+), 48 deletions(-)
New commits: commit 76ad9b3451d82cf6b0079836fb5a1627677f4f83 Author: Ashod Nakashian <[email protected]> Date: Sun Aug 21 12:56:35 2016 -0400 loolwsd: cleanup of LOOLSession Change-Id: Ib65e65c44b258c7ae4d4fbe68555f664900d21c9 Reviewed-on: https://gerrit.libreoffice.org/28305 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp index d9fcfc1..091fd48 100644 --- a/loolwsd/LOOLSession.cpp +++ b/loolwsd/LOOLSession.cpp @@ -50,25 +50,23 @@ using Poco::StringTokenizer; LOOLSession::LOOLSession(const std::string& id, const Kind kind, std::shared_ptr<WebSocket> ws) : + _id(id), _kind(kind), _kindString(kind == Kind::ToClient ? "ToClient" : kind == Kind::ToMaster ? "ToMaster" : "ToPrisoner"), + _name(_kindString + '-' + id), _ws(std::move(ws)), - _docPassword(""), - _haveDocPassword(false), - _isDocLoaded(false), - _isDocPasswordProtected(false), - _isCloseFrame(false), _disconnected(false), _isActive(true), _lastActivityTime(std::chrono::steady_clock::now()), - _isHeadless(false) + _isCloseFrame(false), + _docPassword(""), + _haveDocPassword(false), + _isDocPasswordProtected(false) { // Only a post request can have a null ws. if (_kind != Kind::ToClient) assert(_ws); - - setId(id); } LOOLSession::~LOOLSession() diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp index 96bbefb..71d1e9f 100644 --- a/loolwsd/LOOLSession.hpp +++ b/loolwsd/LOOLSession.hpp @@ -80,20 +80,13 @@ public: Kind getKind() const { return _kind; } - void setHeadless(bool val) { _isHeadless = val; } - bool isHeadless() const { return _isHeadless; } + bool isHeadless() const { return _ws == nullptr; } protected: LOOLSession(const std::string& id, const Kind kind, std::shared_ptr<Poco::Net::WebSocket> ws); virtual ~LOOLSession(); - void setId(const std::string& id) - { - _id = id; - _name = _kindString + '-' + id; - } - /// Parses the options of the "load" command, shared between MasterProcessSession::loadDocument() and ChildProcessSession::loadDocument(). void parseDocOptions(const Poco::StringTokenizer& tokens, int& part, std::string& timestamp); @@ -131,16 +124,39 @@ protected: } private: + + virtual bool _handleInput(const char *buffer, int length) = 0; + +private: + + /// A session ID specific to an end-to-end connection (from user to lokit). + const std::string _id; + // Our kind signifies to what we are connected to. const Kind _kind; // The kind cached as a string. const std::string _kindString; + /// A readable name that identifies our peer and ID. + const std::string _name; + // In the master process, the websocket to the LOOL client or the jailed child process. In a // jailed process, the websocket to the parent. std::shared_ptr<Poco::Net::WebSocket> _ws; + /// True if we have been disconnected. + bool _disconnected; + /// True if the user is active, otherwise false (switched tabs). + bool _isActive; + + std::chrono::steady_clock::time_point _lastActivityTime; + + // Whether websocket received close frame. Closing Handshake + std::atomic<bool> _isCloseFrame; + + std::mutex _mutex; + protected: // The actual URL, also in the child, even if the child never accesses that. std::string _docURL; @@ -154,41 +170,11 @@ protected: // If password is provided or not bool _haveDocPassword; - // Whether document has been opened succesfuly - bool _isDocLoaded; - // Whether document is password protected bool _isDocPasswordProtected; /// Document options: a JSON string, containing options (rendering, also possibly load in the future). std::string _docOptions; - - // Whether websocket received close frame. Closing Handshake - std::atomic<bool> _isCloseFrame; -private: - - virtual bool _handleInput(const char *buffer, int length) = 0; - -private: - /// A session ID specific to an end-to-end connection (from user to lokit). - std::string _id; - /// A readable name that identifies our peer and ID. - std::string _name; - /// True if we have been disconnected. - bool _disconnected; - /// True if the user is active, otherwise false (switched tabs). - bool _isActive; - - std::chrono::steady_clock::time_point _lastActivityTime; - - // Whether it is dummy session - // For eg. In case of convert-to requests (HTTP Post), there is no actual websocket - // connection on client side - bool _isHeadless; - - std::mutex _mutex; - - static constexpr auto InactivityThresholdMS = 120 * 1000; }; template<typename charT, typename traits> diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index e6d9145..0d0c80a 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -402,8 +402,6 @@ private: // Load the document. std::shared_ptr<WebSocket> ws; auto session = std::make_shared<ClientSession>(id, ws, docBroker, nullptr); - // There is no actual client websocket connnection here - session->setHeadless(true); // Request the child to connect to us and add this session. auto sessionsCount = docBroker->addSession(session); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
