diff options
author | Shubham Goyal <22shubh22@gmail.com> | 2020-12-18 13:26:47 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2021-01-13 16:55:35 +0000 |
commit | 3a3867e1c62534762fa9af602c4f2f0c618558ff (patch) | |
tree | f745bb830f44a4b53ebeaabb5fcbe4618833066e /kit | |
parent | Fontwork: layout improvements (diff) | |
download | online-3a3867e1c62534762fa9af602c4f2f0c618558ff.tar.gz online-3a3867e1c62534762fa9af602c4f2f0c618558ff.zip |
Resolve #805 : Remove Mutex lock
Signed-off-by: Shubham Goyal <22shubh22@gmail.com>
Change-Id: I80da9d085590e67c0998ce971225a8c9903c0bb7
Diffstat (limited to 'kit')
-rw-r--r-- | kit/ChildSession.hpp | 2 | ||||
-rw-r--r-- | kit/Kit.cpp | 34 |
2 files changed, 0 insertions, 36 deletions
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp index 138c7215a6..a3065107fb 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -7,7 +7,6 @@ #pragma once -#include <mutex> #include <unordered_map> #include <queue> @@ -60,7 +59,6 @@ public: /// Get a view ID <-> UserInfo map. virtual std::map<int, UserInfo> getViewInfo() = 0; - virtual std::mutex& getMutex() = 0; virtual std::string getObfuscatedFileId() = 0; diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 3c0951cc96..1e5fe62c62 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -582,8 +582,6 @@ public: bool createSession(const std::string& sessionId, int canonicalViewId) { - std::unique_lock<std::mutex> lock(_mutex); - try { if (_sessions.find(sessionId) != _sessions.end()) @@ -625,13 +623,6 @@ public: std::vector<std::shared_ptr<ChildSession>> deadSessions; std::size_t num_sessions = 0; { - std::unique_lock<std::mutex> lock(_mutex, std::defer_lock); - if (!lock.try_lock()) - { - // Not a good time, try later. - return -1; - } - // If there are no live sessions, we don't need to do anything at all and can just // bluntly exit, no need to clean up our own data structures. Also, there is a bug that // causes the deadSessions.clear() call below to crash in some situations when the last @@ -660,10 +651,6 @@ public: #endif } - // Don't destroy sessions while holding our lock. - // We may deadlock if a session is waiting on us - // during callback initiated while handling a command - // and the dtor tries to take its lock (which is taken). deadSessions.clear(); return num_sessions; @@ -944,15 +931,10 @@ private: const std::string& renderOpts, const std::string& docTemplate) override { - std::unique_lock<std::mutex> lock(_mutex); - LOG_INF("Loading url [" << uriAnonym << "] for session [" << sessionId << "] which has " << (_sessions.size() - 1) << " sessions. Another load in progress: " << _isLoading); - while (_isLoading) - _cvLoading.wait(lock); - // This shouldn't happen, but for sanity. const auto it = _sessions.find(sessionId); if (it == _sessions.end() || !it->second) @@ -963,7 +945,6 @@ private: std::shared_ptr<ChildSession> session = it->second; - // Flag and release lock. ++_isLoading; Util::ScopeGuard g([this]() { @@ -972,8 +953,6 @@ private: _cvLoading.notify_one(); }); - lock.unlock(); - try { if (!load(session, renderOpts, docTemplate)) @@ -1010,7 +989,6 @@ private: int viewCount = _loKitDocument->getViewsCount(); if (viewCount == 1) { - std::unique_lock<std::mutex> lock(_mutex); #if !MOBILEAPP if (_sessions.empty()) { @@ -1052,16 +1030,9 @@ private: std::map<int, UserInfo> getViewInfo() override { - std::unique_lock<std::mutex> lock(_mutex); - return _sessionUserInfo; } - std::mutex& getMutex() override - { - return _mutex; - } - std::shared_ptr<TileQueue>& getTileQueue() override { return _tileQueue; @@ -1389,8 +1360,6 @@ private: std::string sessionId; if (LOOLProtocol::parseNameValuePair(prefix, name, sessionId, '-') && name == "child") { - std::unique_lock<std::mutex> lock(_mutex); - const auto it = _sessions.find(sessionId); if (it != _sessions.end()) { @@ -1414,13 +1383,11 @@ private: " after removing ChildSession [" << sessionId << "]."); // No longer needed, and allow session dtor to take it. - lock.unlock(); session.reset(); return true; } // No longer needed, and allow the handler to take it. - lock.unlock(); if (session) { std::vector<char> vect(size); @@ -1727,7 +1694,6 @@ private: PasswordType _docPasswordType; std::atomic<bool> _stop; - mutable std::mutex _mutex; ThreadPool _pngPool; |