mirror of https://gitee.com/bigwinds/arangodb
prohibit the use of sleep() in the source (#5178)
This commit is contained in:
parent
7c723fe09f
commit
357ec8ebef
|
@ -434,21 +434,21 @@ Result DatabaseInitialSyncer::handleCollectionDump(arangodb::LogicalCollection*
|
|||
return Result(TRI_ERROR_REPLICATION_NO_RESPONSE, std::string("timed out waiting for response from master at ") + _masterInfo._endpoint);
|
||||
}
|
||||
|
||||
double sleepTime;
|
||||
std::chrono::milliseconds sleepTime;
|
||||
if (waitTime < 5.0) {
|
||||
sleepTime = 0.25;
|
||||
sleepTime = std::chrono::milliseconds(250);
|
||||
} else if (waitTime < 20.0) {
|
||||
sleepTime = 0.5;
|
||||
sleepTime = std::chrono::milliseconds(500);
|
||||
} else if (waitTime < 60.0) {
|
||||
sleepTime = 1.0;
|
||||
sleepTime = std::chrono::seconds(1);
|
||||
} else {
|
||||
sleepTime = 2.0;
|
||||
sleepTime = std::chrono::seconds(2);
|
||||
}
|
||||
|
||||
if (isAborted()) {
|
||||
return Result(TRI_ERROR_REPLICATION_APPLIER_STOPPED);
|
||||
}
|
||||
this->sleep(static_cast<uint64_t>(sleepTime * 1000.0 * 1000.0));
|
||||
std::this_thread::sleep_for(sleepTime);
|
||||
}
|
||||
// fallthrough here in case everything went well
|
||||
}
|
||||
|
@ -613,21 +613,21 @@ Result DatabaseInitialSyncer::handleCollectionSync(arangodb::LogicalCollection*
|
|||
return Result(TRI_ERROR_REPLICATION_NO_RESPONSE, std::string("timed out waiting for response from master at ") + _masterInfo._endpoint);
|
||||
}
|
||||
|
||||
double sleepTime;
|
||||
std::chrono::milliseconds sleepTime;
|
||||
if (waitTime < 5.0) {
|
||||
sleepTime = 0.25;
|
||||
sleepTime = std::chrono::milliseconds(250);
|
||||
} else if (waitTime < 20.0) {
|
||||
sleepTime = 0.5;
|
||||
sleepTime = std::chrono::milliseconds(500);
|
||||
} else if (waitTime < 60.0) {
|
||||
sleepTime = 1.0;
|
||||
sleepTime = std::chrono::seconds(1);
|
||||
} else {
|
||||
sleepTime = 2.0;
|
||||
sleepTime = std::chrono::seconds(2);
|
||||
}
|
||||
|
||||
if (isAborted()) {
|
||||
return Result(TRI_ERROR_REPLICATION_APPLIER_STOPPED);
|
||||
}
|
||||
this->sleep(static_cast<uint64_t>(sleepTime * 1000.0 * 1000.0));
|
||||
std::this_thread::sleep_for(sleepTime);
|
||||
}
|
||||
|
||||
if (hasFailed(response.get())) {
|
||||
|
|
|
@ -76,11 +76,6 @@ class Syncer {
|
|||
|
||||
virtual ~Syncer();
|
||||
|
||||
/// @brief sleeps (nanoseconds)
|
||||
void sleep(uint64_t time) {
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(time));
|
||||
}
|
||||
|
||||
/// @brief request location rewriter (injects database name)
|
||||
static std::string rewriteLocation(void*, std::string const&);
|
||||
|
||||
|
|
|
@ -285,4 +285,9 @@ struct TRI_AutoOutOfScope {
|
|||
#undef TRI_SHOW_LOCK_TIME
|
||||
#define TRI_SHOW_LOCK_THRESHOLD 0.000199
|
||||
|
||||
#ifdef sleep
|
||||
#undef sleep
|
||||
#endif
|
||||
#define sleep ERROR_USE_std_this_thread_sleep_for
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#error use <Basics/Common.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __STDC_LIMIT_MACROS
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
|
@ -741,7 +742,6 @@
|
|||
#define fsync _commit
|
||||
#define isatty _cyg_isatty
|
||||
#define putenv _putenv
|
||||
#define sleep TRI_sleep
|
||||
#define tzset _tzset
|
||||
|
||||
// available features
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#undef sleep
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
|
Loading…
Reference in New Issue