From d612a59999126e8e2d26fef53102633e1cf23a64 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sat, 31 Oct 2020 13:40:12 -0700 Subject: [PATCH] Revert some unnecessary and buggy restructuring of RemoteLibrary::EnqueueAndWait(). While required for LocalLibrary, this causes issues with RemoteLibrary. --- src/musikcore/library/RemoteLibrary.cpp | 35 +++++++++++-------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/musikcore/library/RemoteLibrary.cpp b/src/musikcore/library/RemoteLibrary.cpp index 318951468..66a8b23df 100644 --- a/src/musikcore/library/RemoteLibrary.cpp +++ b/src/musikcore/library/RemoteLibrary.cpp @@ -199,29 +199,24 @@ int RemoteLibrary::EnqueueAndWait(QueryPtr query, size_t timeoutMs, Callback cal context->query = serializableQuery; context->callback = callback; - if (timeoutMs == kWaitIndefinite) { - this->RunQuery(context); - } - else { - queryQueue.push_back(context); - queueCondition.notify_all(); + queryQueue.push_back(context); + queueCondition.notify_all(); - if (timeoutMs > 0) { - while ( - !this->exit && - this->IsQueryInFlight(context->query) && - !isQueryDone(context->query)) - { - if (timeoutMs == kWaitIndefinite) { - this->syncQueryCondition.wait(lock); + if (timeoutMs > 0) { + while ( + !this->exit && + this->IsQueryInFlight(context->query) && + !isQueryDone(context->query)) + { + if (timeoutMs == kWaitIndefinite) { + this->syncQueryCondition.wait(lock); + break; + } + else { + auto result = this->syncQueryCondition.wait_for(lock, timeoutMs * milliseconds(1)); + if (result == std::cv_status::timeout) { break; } - else { - auto result = this->syncQueryCondition.wait_for(lock, timeoutMs * milliseconds(1)); - if (result == std::cv_status::timeout) { - break; - } - } } } }