mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-01 17:58:29 +00:00
Forgot to push this fix in last night -- fixes query timeout issues due
to potential int overflow with kWaitIndefinite.
This commit is contained in:
parent
aba46739b6
commit
c536a4bc9d
@ -213,12 +213,17 @@ int LocalLibrary::EnqueueAndWait(QueryPtr query, size_t timeoutMs, Callback call
|
|||||||
context->query->GetStatus() == db::IQuery::Running)
|
context->query->GetStatus() == db::IQuery::Running)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if (timeoutMs == kWaitIndefinite) {
|
||||||
|
this->queueCondition.wait(lock);
|
||||||
|
}
|
||||||
|
else {
|
||||||
auto result = this->queueCondition.wait_for(lock, timeoutMs * milliseconds(1));
|
auto result = this->queueCondition.wait_for(lock, timeoutMs * milliseconds(1));
|
||||||
if (result == std::cv_status::timeout) {
|
if (result == std::cv_status::timeout) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return localQuery->GetId();
|
return localQuery->GetId();
|
||||||
}
|
}
|
||||||
|
@ -208,12 +208,18 @@ int RemoteLibrary::EnqueueAndWait(QueryPtr query, size_t timeoutMs, Callback cal
|
|||||||
this->IsQueryInFlight(context->query) &&
|
this->IsQueryInFlight(context->query) &&
|
||||||
!isQueryDone(context->query))
|
!isQueryDone(context->query))
|
||||||
{
|
{
|
||||||
|
if (timeoutMs == kWaitIndefinite) {
|
||||||
|
this->syncQueryCondition.wait(lock);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
auto result = this->syncQueryCondition.wait_for(lock, timeoutMs * milliseconds(1));
|
auto result = this->syncQueryCondition.wait_for(lock, timeoutMs * milliseconds(1));
|
||||||
if (result == std::cv_status::timeout) {
|
if (result == std::cv_status::timeout) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return query->GetId();
|
return query->GetId();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user