Forgot to push this fix in last night -- fixes query timeout issues due

to potential int overflow with kWaitIndefinite.
This commit is contained in:
casey langen 2020-10-28 11:21:49 -07:00
parent aba46739b6
commit c536a4bc9d
2 changed files with 16 additions and 5 deletions

View File

@ -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();
} }

View File

@ -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();
} }