wsd: improve DocBroker state dumping logic
We dump the state of a DocBroker when we detect data-loss, or when running a unit-test that failed. This simplifies the logic and improves it by avoiding duplicate dumps and unnecessary dumps. Change-Id: I1cf2199d35073a762937ce2cf2377061e40b06b5 Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
parent
19b6633625
commit
21dd54086c
1 changed files with 16 additions and 16 deletions
|
@ -510,29 +510,29 @@ void DocumentBroker::pollThread()
|
|||
_poll->continuePolling() << ", ShutdownRequestFlag: " << SigUtil::getShutdownRequestFlag() <<
|
||||
", TerminationFlag: " << SigUtil::getTerminationFlag() << ", closeReason: " << _closeReason << ". Flushing socket.");
|
||||
|
||||
// If we are exiting because the owner discarded conflict changes, don't detect data loss.
|
||||
if (!(_docState.isCloseRequested() && _documentChangedInStorage))
|
||||
// Check for data-loss.
|
||||
std::string reason;
|
||||
if (isModified() || isStorageOutdated())
|
||||
{
|
||||
// If the document is modified, or not uploaded, at exit, dump the state and warn.
|
||||
const std::string reason = isModified() ? "flagged as modified"
|
||||
: isStorageOutdated() ? "not uploaded to storage"
|
||||
: "";
|
||||
if (!reason.empty())
|
||||
// If we are exiting because the owner discarded conflict changes, don't detect data loss.
|
||||
if (!(_docState.isCloseRequested() && _documentChangedInStorage))
|
||||
{
|
||||
std::stringstream state;
|
||||
dumpState(state);
|
||||
LOG_WRN("DocumentBroker stopping although " << reason << ". State: " << state.str());
|
||||
if (UnitWSD::isUnitTesting())
|
||||
{
|
||||
_unitWsd.onDataLoss("Data-loss detected while exiting DocBroker [" + _docKey + ']');
|
||||
}
|
||||
reason = isModified() ? "flagged as modified" : "not uploaded to storage";
|
||||
|
||||
// The test may override (if it was expected).
|
||||
if (UnitWSD::isUnitTesting() &&
|
||||
!_unitWsd.onDataLoss("Data-loss detected while exiting [" + _docKey + ']'))
|
||||
reason.clear();
|
||||
}
|
||||
}
|
||||
else if (UnitWSD::isUnitTesting() && _unitWsd.isFinished() && _unitWsd.failed())
|
||||
|
||||
if (!reason.empty() || (UnitWSD::isUnitTesting() && _unitWsd.isFinished() && _unitWsd.failed()))
|
||||
{
|
||||
std::stringstream state;
|
||||
state << "DocBroker [" << _docKey << " stopped "
|
||||
<< (reason.empty() ? "because of test failure" : ("although " + reason)) << ": ";
|
||||
dumpState(state);
|
||||
LOG_WRN("Test failed with doc [" << _docKey << "]: " << state.str());
|
||||
LOG_WRN(state.str());
|
||||
}
|
||||
|
||||
// Flush socket data first.
|
||||
|
|
Loading…
Reference in a new issue