[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp
Pranav Kant
pranavk at collabora.co.uk
Fri Feb 19 21:57:28 UTC 2016
loolwsd/LOOLKit.cpp | 67 +++++++++++++++++++++++-----------------------------
1 file changed, 30 insertions(+), 37 deletions(-)
New commits:
commit 631ae0f11fb863a2ba9bbcc279c83905af8bba96
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Sun Feb 7 22:08:48 2016 +0530
loolwsd: Get the first *live* connection
Sometimes there are situations when `connection` map is filled
with dead sessions. We don't want to deal with those dead ones.
Change-Id: I00dda77c39b5adbba69421eace0be0159e02505c
Reviewed-on: https://gerrit.libreoffice.org/22207
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 3694d42..703e30b 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -496,48 +496,41 @@ private:
static void KitCallback(int nType, const char* pPayload, void* pData)
{
Document* self = reinterpret_cast<Document*>(pData);
+ Log::trace() << "Callback "
+ << KitCallbackTypeToString(nType)
+ << " [" << pPayload << "]." << Log::end;
+
if (self)
{
std::unique_lock<std::recursive_mutex> lock(self->_mutex);
-
- // Ideally, there would be only one connection at this point of time
- const auto& it = self->_connections.begin();
-
- if (!it->second->isRunning())
- Log::error() << "Error: Connection died unexpectedly" << Log::end;
-
- auto session = it->second->getSession();
- auto sessionLock = session->getLock();
-
- Log::trace() << "Callback [" << session->getViewId() << "] "
- << KitCallbackTypeToString(nType)
- << " [" << pPayload << "]." << Log::end;
-
- if (session->isDisconnected())
- {
- Log::trace("Skipping callback on disconnected session " + session->getName());
- return;
- }
- else if (session->isInactive())
+ for (auto& it: self->_connections)
{
- Log::trace("Skipping callback on inactive session " + session->getName());
- return;
- }
+ if (it.second->isRunning())
+ {
+ auto session = it.second->getSession();
+ auto sessionLock = session->getLock();
- switch (nType)
- {
- case LOK_CALLBACK_STATUS_INDICATOR_START:
- session->sendTextFrame("statusindicatorstart:");
- break;
- case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
- session->sendTextFrame("statusindicatorsetvalue: " + std::string(pPayload));
- break;
- case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
- session->sendTextFrame("statusindicatorfinish:");
- break;
- case LOK_CALLBACK_DOCUMENT_PASSWORD:
- case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
- session->setDocumentPassword(nType);
+ switch (nType)
+ {
+ case LOK_CALLBACK_STATUS_INDICATOR_START:
+ session->sendTextFrame("statusindicatorstart:");
+ break;
+ case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
+ session->sendTextFrame("statusindicatorsetvalue: " + std::string(pPayload));
+ break;
+ case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
+ session->sendTextFrame("statusindicatorfinish:");
+ break;
+ case LOK_CALLBACK_DOCUMENT_PASSWORD:
+ case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
+ session->setDocumentPassword(nType);
+ break;
+ }
+ }
+
+ // Ideally, there would be only one *live* connection at this point of time
+ // So, just get the first running one and break out.
+ // TODO: Find a better way to find the correct connection.
break;
}
}
More information about the Libreoffice-commits
mailing list