From 02f9eb06f84df2dfed5a02650c91eb755a5025ad Mon Sep 17 00:00:00 2001 From: jsteemann Date: Tue, 24 Sep 2019 15:18:21 +0200 Subject: [PATCH] make sleeping more accurate --- arangod/Aql/Functions.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arangod/Aql/Functions.cpp b/arangod/Aql/Functions.cpp index ccc2ff85ce..ee40793ccc 100644 --- a/arangod/Aql/Functions.cpp +++ b/arangod/Aql/Functions.cpp @@ -4185,16 +4185,18 @@ AqlValue Functions::Sleep(ExpressionContext* expressionContext, return AqlValue(AqlValueHintNull()); } - double const until = TRI_microtime() + value.toDouble(); + double now = TRI_microtime(); + double const until = now + value.toDouble(); - while (TRI_microtime() < until) { - std::this_thread::sleep_for(std::chrono::milliseconds(300)); + while (now < until) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); if (expressionContext->killed()) { THROW_ARANGO_EXCEPTION(TRI_ERROR_QUERY_KILLED); } else if (application_features::ApplicationServer::isStopping()) { THROW_ARANGO_EXCEPTION(TRI_ERROR_SHUTTING_DOWN); } + now = TRI_microtime(); } return AqlValue(AqlValueHintNull()); }