loolwsd: ensure to remove the connection of unloaded document
This commit is contained in:
parent
4c3896c32e
commit
2c7b4490ec
1 changed files with 30 additions and 0 deletions
|
@ -560,6 +560,24 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void purgeSessions()
|
||||||
|
{
|
||||||
|
for (auto it =_connections.cbegin(); it != _connections.cend(); )
|
||||||
|
{
|
||||||
|
if (!it->second->isRunning())
|
||||||
|
{
|
||||||
|
_connections.erase(it++);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasConnections()
|
||||||
|
{
|
||||||
|
return _connections.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void onLoad(LibreOfficeKitDocument *loKitDocument, const int viewId)
|
void onLoad(LibreOfficeKitDocument *loKitDocument, const int viewId)
|
||||||
|
@ -703,6 +721,18 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s
|
||||||
|
|
||||||
if (tokens[0] == "search")
|
if (tokens[0] == "search")
|
||||||
{
|
{
|
||||||
|
// remove document that is unloaded
|
||||||
|
for (auto it =_documents.cbegin(); it != _documents.cend(); )
|
||||||
|
{
|
||||||
|
it->second->purgeSessions();
|
||||||
|
if (!it->second->hasConnections())
|
||||||
|
{
|
||||||
|
_documents.erase(it++);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
|
||||||
if (_documents.empty())
|
if (_documents.empty())
|
||||||
{
|
{
|
||||||
aResponse += "empty \r\n";
|
aResponse += "empty \r\n";
|
||||||
|
|
Loading…
Reference in a new issue