Skip to content

Commit

Permalink
fix: data loss when shutting down while using typer
Browse files Browse the repository at this point in the history
- Docbroker only uploads the document when the document is already saved and
  there are no further modifications.
- But when using typer once dockerbroker saves the document and tries to upload
  there are already new changes to the document. Therefore, docbroker keeps on
  saving this new changes and keeps on skiping the upload as there are new
  changes to the document; until it times out

Signed-off-by: Rashesh Padia <rashesh.padia@collabora.com>
Change-Id: I427d37a6228299006530daddebdf4365af63588b
  • Loading branch information
Rash419 committed Mar 18, 2024
1 parent 48ba853 commit d89d321
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions browser/src/core/Socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,8 @@ app.definitions.Socket = L.Class.extend({
else if (textMsg === 'shuttingdown') {
msg = _('Server is shutting down for maintenance (auto-saving)');
postMsgData['Reason'] = 'ShuttingDown';
app.idleHandler._active = false;
app.idleHandler._serverRecycling = true;
}
else if (textMsg === 'docdisconnected') {
msg = _('Oops, there is a problem connecting the document');
Expand Down Expand Up @@ -1223,6 +1225,11 @@ app.definitions.Socket = L.Class.extend({
else if (textMsg.startsWith('statusindicatorfinish:')) {
this._map.fire('statusindicator', {statusType : 'finish'});
this._map._fireInitComplete('statusindicatorfinish');
// show shutting down popup after saving is finished
// if we show the popup just after the shuttingdown messsage, it will be overwitten by save popup
if (app.idleHandler._serverRecycling) {
this._map.showBusy(_('Server is shutting down'), false);
}
return;
}
}
Expand Down
2 changes: 2 additions & 0 deletions wsd/COOLWSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6297,6 +6297,8 @@ int COOLWSD::innerMain()
#endif
}

COOLWSD::alertAllUsersInternal("close: shuttingdown");

// Stop the listening to new connections
// and wait until sockets close.
LOG_INF("Stopping server socket listening. ShutdownRequestFlag: " <<
Expand Down
8 changes: 7 additions & 1 deletion wsd/DocumentBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3654,6 +3654,13 @@ bool DocumentBroker::forwardToChild(const std::shared_ptr<ClientSession>& sessio
return true;
}

// Ignore textinput, mouse and key message when document is unloading
if (isUnloading() && (Util::startsWith(message, "textinput ") ||
Util::startsWith(message, "mouse ") || Util::startsWith(message, "key ")))
{
return true;
}

const std::string viewId = session->getId();

LOG_TRC("Forwarding payload to child [" << viewId << "]: " << getAbbreviatedMessage(message));
Expand Down Expand Up @@ -3779,7 +3786,6 @@ void DocumentBroker::terminateChild(const std::string& closeReason)

_childProcess->close();
}

stop(closeReason);
}

Expand Down

0 comments on commit d89d321

Please sign in to comment.