[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp
Tor Lillqvist
tml at collabora.com
Mon Sep 26 14:41:27 UTC 2016
loolwsd/LOOLKit.cpp | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
New commits:
commit e0c5f260155ce38bc9f10b0120fed4c39a52beef
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Sep 26 17:28:14 2016 +0300
bccu#2035: Work around crash by just exiting before it happens
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index cc35ad4..153bd80 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -530,6 +530,7 @@ public:
size_t purgeSessions()
{
std::vector<std::shared_ptr<ChildSession>> deadSessions;
+ size_t numRunning = 0;
size_t num_connections = 0;
{
std::unique_lock<std::mutex> lock(_mutex, std::defer_lock);
@@ -539,22 +540,41 @@ public:
return -1;
}
- for (auto it = _connections.cbegin(); it != _connections.cend(); )
+ // 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
+ // session is being removed, see bccu#2035.
+ for (auto it = _connections.cbegin(); it != _connections.cend(); ++it)
{
- if (!it->second->isRunning())
- {
- deadSessions.push_back(it->second->getSession());
- it = _connections.erase(it);
- }
- else
+ if (it->second->isRunning())
+ numRunning++;
+ }
+
+ if (numRunning > 0)
+ {
+ for (auto it = _connections.cbegin(); it != _connections.cend(); )
{
- ++it;
+ if (!it->second->isRunning())
+ {
+ deadSessions.push_back(it->second->getSession());
+ it = _connections.erase(it);
+ }
+ else
+ {
+ ++it;
+ }
}
}
num_connections = _connections.size();
}
+ if (numRunning == 0)
+ {
+ Log::info("No more sessions, exiting bluntly");
+ std::_Exit(Application::EXIT_OK);
+ }
+
// 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
More information about the Libreoffice-commits
mailing list