bccu#2005 follow-up: If the document appearead in the meantime, finish early.
This commit is contained in:
parent
912281bd20
commit
d1e0b978d6
1 changed files with 14 additions and 2 deletions
|
@ -583,18 +583,30 @@ private:
|
||||||
{
|
{
|
||||||
Log::debug("Document [" + docKey + "] is marked to destroy, waiting to reload.");
|
Log::debug("Document [" + docKey + "] is marked to destroy, waiting to reload.");
|
||||||
const auto timeout = POLL_TIMEOUT_MS / 2;
|
const auto timeout = POLL_TIMEOUT_MS / 2;
|
||||||
|
bool timedOut = true;
|
||||||
for (size_t i = 0; i < COMMAND_TIMEOUT_MS / timeout; ++i)
|
for (size_t i = 0; i < COMMAND_TIMEOUT_MS / timeout; ++i)
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
|
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(docBrokersMutex);
|
std::unique_lock<std::mutex> lock(docBrokersMutex);
|
||||||
if (docBrokers.find(docKey) == docBrokers.end())
|
auto it = docBrokers.find(docKey);
|
||||||
|
if (it == docBrokers.end())
|
||||||
{
|
{
|
||||||
|
// went away successfully
|
||||||
docBroker.reset();
|
docBroker.reset();
|
||||||
|
timedOut = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (it->second && !it->second->isMarkedToDestroy())
|
||||||
|
{
|
||||||
|
// was actually replaced by a real document
|
||||||
|
docBroker = it->second;
|
||||||
|
timedOut = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (docBroker)
|
if (timedOut)
|
||||||
{
|
{
|
||||||
// Still here, but marked to destroy. Proceed and hope to recover.
|
// Still here, but marked to destroy. Proceed and hope to recover.
|
||||||
Log::error("Timed out while waiting for document to unload before loading.");
|
Log::error("Timed out while waiting for document to unload before loading.");
|
||||||
|
|
Loading…
Reference in a new issue