diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 5cc671740..b940f6c1b 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -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(); }