[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sun Jan 10 20:09:25 PST 2016
loolwsd/LOOLKit.cpp | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
New commits:
commit c83f3937d4faeac4eda2a03a9eac3244429ef46b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Jan 10 10:34:47 2016 -0500
loolwsd: Document locks and view counters
Change-Id: I2bae3fd7136e5bb85276f5cad246497e51fbfdd0
Reviewed-on: https://gerrit.libreoffice.org/21328
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 35fc483..7e2f8ad 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -485,6 +485,8 @@ public:
~Document()
{
+ std::unique_lock<std::mutex> lock(_mutex);
+
Log::info("~Document dtor for url [" + _url + "] on child [" + _jailId +
"]. There are " + std::to_string(_clientViews) + " views.");
@@ -597,6 +599,8 @@ private:
Document* self = reinterpret_cast<Document*>(pData);
if (self)
{
+ std::unique_lock<std::mutex> lock(self->_mutex);
+
for (auto& it: self->_connections)
{
if (it.second->isRunning())
@@ -615,6 +619,10 @@ private:
/// Load a document (or view) and register callbacks.
LibreOfficeKitDocument* onLoad(const std::string& sessionId, const std::string& uri)
{
+ std::unique_lock<std::mutex> lock(_mutex);
+
+ Log::info("Session " + sessionId + " is unloading. " + std::to_string(_clientViews) + " views loaded.");
+
const unsigned intSessionId = Util::decodeId(sessionId);
const auto it = _connections.find(intSessionId);
if (it == _connections.end() || !it->second)
@@ -644,16 +652,16 @@ private:
_loKitDocument->pClass->registerCallback(_loKitDocument, ViewCallback, reinterpret_cast<void*>(intSessionId));
- ++_clientViews;
Log::info() << "Document [" << _url << "] view ["
<< viewId << "] loaded, leaving "
- << _clientViews << " views." << Log::end;
+ << (_clientViews + 1) << " views." << Log::end;
}
else
{
_loKitDocument->pClass->registerCallback(_loKitDocument, DocumentCallback, this);
}
+ ++_clientViews;
return _loKitDocument;
}
@@ -675,8 +683,7 @@ private:
if (_multiView && _loKitDocument)
{
- --_clientViews;
- Log::info() << "Document [" << _url << "] view ["
+ Log::info() << "Document [" << _url << "] session ["
<< sessionId << "] unloaded, leaving "
<< _clientViews << " views." << Log::end;
More information about the Libreoffice-commits
mailing list