wsd: better session disconnection logic
This improves the disconnected session cleanup and fixes a corner-case with the last editor disconnecting before read-only sessions. Change-Id: Iecb553d7f5be2c63fc55111e60e22b3d8aa668f6 Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
parent
e90586a098
commit
acdd74f014
1 changed files with 18 additions and 13 deletions
|
@ -1575,21 +1575,17 @@ void DocumentBroker::checkAndUploadToStorage(const std::shared_ptr<ClientSession
|
|||
{
|
||||
uploadToStorage(session, /*force=*/false);
|
||||
}
|
||||
|
||||
if (!isAsyncUploading())
|
||||
else if (!isAsyncUploading())
|
||||
{
|
||||
// If marked to destroy, or session is disconnected, remove.
|
||||
if (_docState.isMarkedToDestroy() || session->isCloseFrame())
|
||||
disconnectSessionInternal(session);
|
||||
|
||||
// If marked to destroy, then this was the last session.
|
||||
if (_docState.isMarkedToDestroy() || _sessions.empty())
|
||||
// If session is disconnected, remove.
|
||||
LOG_TRC("Nothing to upload, disconnecting closed sessions");
|
||||
for (const auto& pair : _sessions)
|
||||
{
|
||||
// Stop so we get cleaned up and removed.
|
||||
LOG_DBG("Stopping after saving because "
|
||||
<< (_sessions.empty() ? "there are no active sessions left."
|
||||
: "the document is marked to destroy"));
|
||||
stop("unloading");
|
||||
if (pair.second->isCloseFrame() && !pair.second->inWaitDisconnected())
|
||||
{
|
||||
LOG_TRC("Disconnecting session [" << pair.second->getName() << ']');
|
||||
disconnectSessionInternal(pair.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1960,6 +1956,15 @@ void DocumentBroker::handleUploadToStorageResponse(const StorageBase::UploadResu
|
|||
stop("unloading");
|
||||
}
|
||||
|
||||
// After uploading, disconnect the sessions pending disconnection.
|
||||
for (const auto& pair : _sessions)
|
||||
{
|
||||
if (pair.second->isCloseFrame() && !pair.second->inWaitDisconnected())
|
||||
{
|
||||
disconnectSessionInternal(pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (uploadResult.getResult() == StorageBase::UploadResult::Result::TOO_LARGE)
|
||||
|
|
Loading…
Reference in a new issue