[Libreoffice-commits] online.git: loolwsd/DocumentBroker.hpp loolwsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Mar 14 03:14:12 UTC 2016
loolwsd/DocumentBroker.hpp | 6 +++++-
loolwsd/LOOLWSD.cpp | 7 ++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
New commits:
commit 0b18a67da21debd051f151718f271cea27c30bc8
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Mar 13 10:04:54 2016 -0400
loolwsd: DocumentBroker cleanup
Change-Id: Iedf2e0afd3c63d24b96ce1c7923c90d86d82bc13
Reviewed-on: https://gerrit.libreoffice.org/23220
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 71c9681..f4fc674 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -148,6 +148,8 @@ public:
Poco::URI getJailedUri() const { return _uriJailed; }
const std::string& getJailId() const { return _jailId; }
const std::string& getDocKey() const { return _docKey; }
+ unsigned decSessions() { return --_sessionsCount; }
+ unsigned incSessions() { return ++_sessionsCount; }
std::string getJailRoot() const
{
@@ -161,7 +163,8 @@ private:
const std::string& childRoot) :
_uriPublic(uriPublic),
_docKey(docKey),
- _childRoot(childRoot)
+ _childRoot(childRoot),
+ _sessionsCount(0)
{
assert(!_docKey.empty());
assert(!_childRoot.empty());
@@ -176,6 +179,7 @@ private:
std::string _jailId;
std::unique_ptr<StorageBase> _storage;
std::mutex _mutex;
+ std::atomic<unsigned> _sessionsCount;
};
#endif
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 1d63532..ca08811 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -535,6 +535,7 @@ private:
auto ws = std::make_shared<WebSocket>(request, response);
auto session = std::make_shared<MasterProcessSession>(id, LOOLSession::Kind::ToClient, ws, docBroker);
+ docBroker->incSessions();
// For ToClient sessions, we store incoming messages in a queue and have a separate
// thread that handles them. This is so that we can empty the queue when we get a
@@ -569,7 +570,11 @@ private:
queue.put("eof");
queueHandlerThread.join();
- //TODO: Cleanup DocumentBroker.
+ std::unique_lock<std::mutex> lock(LOOLWSD::DocBrokersMutex);
+ if (docBroker->decSessions() == 0)
+ {
+ LOOLWSD::DocBrokers.erase(docKey);
+ }
}
public:
More information about the Libreoffice-commits
mailing list