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; - } - } } } }