wsd: do not clobber closeReason

The closeReason member isn't just for logging,
it's is also broadcast back to clients. This
means that it has to preserve the original
reason for initiating the document closing,
lest the client misbehaves.

Change-Id: Iddee5dba3943d873e8658ce5c1748f4ecd47c486
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
Ashod Nakashian 2022-02-11 17:07:03 -05:00 committed by Ashod Nakashian
parent 3c953faded
commit 489c942aae

View file

@ -570,8 +570,18 @@ void DocumentBroker::joinThread()
void DocumentBroker::stop(const std::string& reason)
{
LOG_DBG("Stopping DocumentBroker for docKey [" << _docKey << "] with reason: " << reason);
_closeReason = reason; // used later in the polling loop
if (_closeReason.empty())
{
LOG_DBG("Stopping DocumentBroker for docKey [" << _docKey << "] with reason: " << reason);
_closeReason = reason; // used later in the polling loop
}
else
{
LOG_DBG("Stopping DocumentBroker for docKey ["
<< _docKey << "] with existing close reason: " << _closeReason
<< " (ignoring requested reason: " << reason << ')');
}
_stop = true;
_poll->wakeup();
}