[Libreoffice-commits] online.git: common/Session.hpp kit/ChildSession.cpp kit/ChildSession.hpp

2020-02-14 Thread Michael Meeks (via logerrit)
 common/Session.hpp   |6 --
 kit/ChildSession.cpp |   14 --
 kit/ChildSession.hpp |6 --
 3 files changed, 26 deletions(-)

New commits:
commit 701cb6a230f3796964442560e057aa05dbe01a67
Author: Michael Meeks 
AuthorDate: Fri Feb 14 18:49:56 2020 +
Commit: Michael Meeks 
CommitDate: Fri Feb 14 23:33:49 2020 +0100

tdf#130673 - kill obsolete locking.

This dates back to 2016 and our pre non-blocking and pre-unipoll state.

It is no longer necessary - a single thread reads all data from the
socket and feeds events into the Kit process; much cleaner.

Change-Id: I46ad6806a1e0cdbb0e5cf4ea5d3e5e5078d3391a
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88741
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/common/Session.hpp b/common/Session.hpp
index 6a3f7cfea..aa585a559 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -175,12 +175,6 @@ protected:
 _lastActivityTime = std::chrono::steady_clock::now();
 }
 
-/// Internal lock shared with derived classes.
-std::unique_lock getLock()
-{
-return std::unique_lock(_mutex);
-}
-
 void dumpState(std::ostream& os) override;
 
 private:
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index d45891b58..83acd082f 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -50,8 +50,6 @@ using Poco::URI;
 
 using namespace LOOLProtocol;
 
-std::recursive_mutex ChildSession::Mutex;
-
 namespace {
 
 std::vector decodeBase64(const std::string & inputBase64)
@@ -88,8 +86,6 @@ void ChildSession::disconnect()
 {
 if (!isDisconnected())
 {
-std::unique_lock lock(Mutex);
-
 if (_viewId >= 0)
 {
 if (_docManager)
@@ -125,8 +121,6 @@ bool ChildSession::_handleInput(const char *buffer, int 
length)
 
 // Client is getting active again.
 // Send invalidation and other sync-up messages.
-std::unique_lock lock(Mutex); //TODO: Move to 
top of function?
-
 getLOKitDocument()->setView(_viewId);
 
 int curPart = 0;
@@ -610,8 +604,6 @@ bool ChildSession::loadDocument(const char * /*buffer*/, 
int /*length*/, const s
 assert(!getDocURL().empty());
 assert(!getJailedFilePath().empty());
 
-std::unique_lock lock(Mutex);
-
 #if defined(ENABLE_DEBUG) && !MOBILEAPP
 if (std::getenv("PAUSEFORDEBUGGER"))
 {
@@ -2219,7 +2211,6 @@ bool ChildSession::removeTextContext(const char* 
/*buffer*/, int /*length*/,
 return false;
 }
 
-std::unique_lock lock(getLock());
 getLOKitDocument()->setView(_viewId);
 getLOKitDocument()->removeTextContext(id, before, after);
 
@@ -2233,7 +2224,6 @@ void ChildSession::rememberEventsForInactiveUser(const 
int type, const std::stri
 {
 if (type == LOK_CALLBACK_INVALIDATE_TILES)
 {
-std::unique_lock lock(getLock());
 _stateRecorder.recordInvalidate(); // TODO remember the area, not just 
a bool ('true' invalidates everything)
 }
 else if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR ||
@@ -2249,7 +2239,6 @@ void ChildSession::rememberEventsForInactiveUser(const 
int type, const std::stri
  type == LOK_CALLBACK_CELL_ADDRESS ||
  type == LOK_CALLBACK_REFERENCE_MARKS)
 {
-std::unique_lock lock(getLock());
 _stateRecorder.recordEvent(type, payload);
 }
 else if (type == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR ||
@@ -2259,7 +2248,6 @@ void ChildSession::rememberEventsForInactiveUser(const 
int type, const std::stri
  type == LOK_CALLBACK_VIEW_CURSOR_VISIBLE ||
  type == LOK_CALLBACK_VIEW_LOCK)
 {
-std::unique_lock lock(getLock());
 Poco::JSON::Parser parser;
 
 Poco::JSON::Object::Ptr root = 
parser.parse(payload).extract();
@@ -2272,7 +2260,6 @@ void ChildSession::rememberEventsForInactiveUser(const 
int type, const std::stri
 std::string value;
 if (LOOLProtocol::parseNameValuePair(payload, name, value, '='))
 {
-std::unique_lock lock(getLock());
 _stateRecorder.recordState(name, payload);
 }
 }
@@ -2280,7 +2267,6 @@ void ChildSession::rememberEventsForInactiveUser(const 
int type, const std::stri
  type == LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED ||
  type == LOK_CALLBACK_COMMENT)
 {
-std::unique_lock lock(getLock());
 _stateRecorder.recordEventSequence(type, payload);
 }
 }
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 4a64be709..8aaa46b54 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -220,14 +220,12 @@ public:
 bool sendTextFrame(const char* buffer, int length) override
 {
 const auto msg = "client-" + getId() + ' ' + std::string(buffer, 
length);
-const std::unique_lock lock = getLock();
 return _docManager->sendFrame(msg.data(), msg.size(), WSOpCode::Text);
 }

[Libreoffice-commits] online.git: common/Session.hpp kit/ChildSession.cpp kit/ChildSession.hpp wsd/ClientSession.cpp wsd/ClientSession.hpp

2018-11-13 Thread Libreoffice Gerrit user
 common/Session.hpp|   36 ++--
 kit/ChildSession.cpp  |   20 ++--
 kit/ChildSession.hpp  |7 +++
 wsd/ClientSession.cpp |   36 ++--
 wsd/ClientSession.hpp |6 --
 5 files changed, 65 insertions(+), 40 deletions(-)

New commits:
commit cd08cbf3850e2eb92ac7b31a448ce3fa46fc53ca
Author: Miklos Vajna 
AuthorDate: Tue Nov 13 09:04:19 2018 +0100
Commit: Miklos Vajna 
CommitDate: Tue Nov 13 09:04:19 2018 +0100

Session: make members private

diff --git a/common/Session.hpp b/common/Session.hpp
index 9fa9833a0..f09af7574 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -84,6 +84,40 @@ public:
 
 void getIOStats(uint64_t &sent, uint64_t &recv);
 
+void setUserId(const std::string& userId) { _userId = userId; }
+
+const std::string& getUserId() const { return _userId; }
+
+void setWatermarkText(const std::string& watermarkText) { _watermarkText = 
watermarkText; }
+
+void setUserExtraInfo(const std::string& userExtraInfo) { _userExtraInfo = 
userExtraInfo; }
+
+void setUserName(const std::string& userName) { _userName = userName; }
+
+const std::string& getUserName() const {return _userName; }
+
+const std::string& getUserNameAnonym() const { return _userNameAnonym; }
+
+bool isDocPasswordProtected() const { return _isDocPasswordProtected; }
+
+const std::string& getDocOptions() const { return _docOptions; }
+
+const std::string& getWatermarkText() const { return _watermarkText; }
+
+const std::string& getLang() const { return _lang; }
+
+bool getHaveDocPassword() const { return _haveDocPassword; }
+
+const std::string& getDocPassword() const { return _docPassword; }
+
+const std::string& getUserExtraInfo() const { return _userExtraInfo; }
+
+const std::string& getDocURL() const { return  _docURL; }
+
+const std::string& getJailedFilePath() const { return _jailedFilePath; }
+
+const std::string& getJailedFilePathAnonym() const { return 
_jailedFilePathAnonym; }
+
 protected:
 Session(const std::string& name, const std::string& id, bool readonly);
 virtual ~Session();
@@ -108,7 +142,6 @@ 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;
 
@@ -131,7 +164,6 @@ private:
 /// Whether the session is opened as readonly
 bool _isReadOnly;
 
-protected:
 /// The actual URL, also in the child, even if the child never accesses 
that.
 std::string _docURL;
 
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index da9e7ae36..9462e2adc 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -366,33 +366,33 @@ bool ChildSession::loadDocument(const char * /*buffer*/, 
int /*length*/, const s
 parseDocOptions(tokens, part, timestamp);
 
 std::string renderOpts;
-if (!_docOptions.empty())
+if (!getDocOptions().empty())
 {
 Parser parser;
-Poco::Dynamic::Var var = parser.parse(_docOptions);
+Poco::Dynamic::Var var = parser.parse(getDocOptions());
 Object::Ptr object = var.extract();
 Poco::Dynamic::Var rendering = object->get("rendering");
 if (!rendering.isEmpty())
 renderOpts = rendering.toString();
 }
 
-assert(!_docURL.empty());
-assert(!_jailedFilePath.empty());
+assert(!getDocURL().empty());
+assert(!getJailedFilePath().empty());
 
 std::unique_lock lock(Mutex);
 
-const bool loaded = _docManager.onLoad(getId(), _jailedFilePath, 
_jailedFilePathAnonym,
-   _userName, _userNameAnonym,
-   _docPassword, renderOpts, 
_haveDocPassword,
-   _lang, _watermarkText);
+const bool loaded = _docManager.onLoad(getId(), getJailedFilePath(), 
getJailedFilePathAnonym(),
+   getUserName(), getUserNameAnonym(),
+   getDocPassword(), renderOpts, 
getHaveDocPassword(),
+   getLang(), getWatermarkText());
 if (!loaded || _viewId < 0)
 {
-LOG_ERR("Failed to get LoKitDocument instance for [" << 
_jailedFilePathAnonym << "].");
+LOG_ERR("Failed to get LoKitDocument instance for [" << 
getJailedFilePathAnonym() << "].");
 return false;
 }
 
 LOG_INF("Created new view with viewid: [" << _viewId << "] for username: 
[" <<
-_userNameAnonym << "] in session: [" << getId() << "].");
+getUserNameAnonym() << "] in session: [" << getId() << "].");
 
 std::unique_lock lockLokDoc(_docManager.getDocumentMutex());
 
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 898d09e22..7b38ec904 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -209,10