mirror of https://gitee.com/bigwinds/arangodb
Bug fix/meierloch (#5895)
This commit is contained in:
parent
006995a6a5
commit
f4b99bb5ed
|
@ -1,6 +1,8 @@
|
|||
devel
|
||||
-----
|
||||
|
||||
* added collection.indexes() as an alias for collection.getIndexes()
|
||||
|
||||
* disable V8 engine and JavaScript APIs for agency nodes
|
||||
|
||||
* renamed MMFiles engine compactor thread from "Compactor" to "MMFilesCompactor".
|
||||
|
|
|
@ -43,6 +43,7 @@ returns information about the indexes
|
|||
`getIndexes()`
|
||||
|
||||
Returns an array of all indexes defined for the collection.
|
||||
Since ArangoDB 3.4, `indexes()` is an alias for `getIndexes()`.
|
||||
|
||||
Note that `_key` implicitly has an index assigned to it.
|
||||
|
||||
|
|
|
@ -103,10 +103,8 @@ class GeneralCommTask : public SocketTask {
|
|||
uint64_t messageId, velocypack::Buffer<uint8_t>&&) = 0;
|
||||
|
||||
/// @brief send the response to the client.
|
||||
virtual void addResponse(GeneralResponse &, RequestStatistics *) = 0;
|
||||
virtual void addResponse(GeneralResponse&, RequestStatistics*) = 0;
|
||||
|
||||
virtual bool allowDirectHandling() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
enum class RequestFlow : bool {
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
#include "GeneralServer.h"
|
||||
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Basics/exitcodes.h"
|
||||
#include "Endpoint/EndpointList.h"
|
||||
#include "GeneralServer/GeneralDefinitions.h"
|
||||
|
@ -33,18 +31,11 @@
|
|||
#include "Logger/Logger.h"
|
||||
#include "Scheduler/Scheduler.h"
|
||||
#include "Scheduler/SchedulerFeature.h"
|
||||
#include "Scheduler/Task.h"
|
||||
|
||||
using namespace arangodb;
|
||||
using namespace arangodb::basics;
|
||||
using namespace arangodb::rest;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
GeneralServer::~GeneralServer() { _listenTasks.clear(); }
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -42,7 +42,6 @@ class GeneralServer {
|
|||
|
||||
public:
|
||||
GeneralServer() = default;
|
||||
virtual ~GeneralServer();
|
||||
|
||||
public:
|
||||
void setEndpointList(EndpointList const* list);
|
||||
|
|
|
@ -128,9 +128,12 @@ void HttpCommTask::addResponse(GeneralResponse& baseResponse,
|
|||
StaticStrings::ExposedCorsHeaders);
|
||||
}
|
||||
|
||||
// use "IfNotSet"
|
||||
response.setHeaderNCIfNotSet(StaticStrings::XContentTypeOptions,
|
||||
StaticStrings::NoSniff);
|
||||
if (!ServerState::instance()->isDBServer()) {
|
||||
// DB server is not user-facing, and does not need to set this header
|
||||
// use "IfNotSet" to not overwrite an existing response header
|
||||
response.setHeaderNCIfNotSet(StaticStrings::XContentTypeOptions,
|
||||
StaticStrings::NoSniff);
|
||||
}
|
||||
|
||||
// set "connection" header, keep-alive is the default
|
||||
response.setConnectionType(_closeRequested
|
||||
|
@ -258,10 +261,6 @@ bool HttpCommTask::processRead(double startTime) {
|
|||
size_t headerLength = ptr - (_readBuffer.c_str() + _startPosition);
|
||||
|
||||
if (headerLength > MaximalHeaderSize) {
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME)
|
||||
<< "maximal header size is " << MaximalHeaderSize
|
||||
<< ", request header size is " << headerLength;
|
||||
|
||||
// header is too large
|
||||
addSimpleResponse(rest::ResponseCode::REQUEST_HEADER_FIELDS_TOO_LARGE,
|
||||
rest::ContentType::UNSET, 1, VPackBuffer<uint8_t>());
|
||||
|
@ -324,7 +323,6 @@ bool HttpCommTask::processRead(double startTime) {
|
|||
_protocolVersion != rest::ProtocolVersion::HTTP_1_1) {
|
||||
addSimpleResponse(rest::ResponseCode::HTTP_VERSION_NOT_SUPPORTED, rest::ContentType::UNSET,
|
||||
1, VPackBuffer<uint8_t>());
|
||||
LOG_TOPIC(WARN, Logger::FIXME) << "HTTP version not supported";
|
||||
_closeRequested = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -335,7 +333,6 @@ bool HttpCommTask::processRead(double startTime) {
|
|||
if (_fullUrl.size() > 16384) {
|
||||
addSimpleResponse(rest::ResponseCode::REQUEST_URI_TOO_LONG, rest::ContentType::UNSET,
|
||||
1, VPackBuffer<uint8_t>());
|
||||
LOG_TOPIC(WARN, Logger::REQUESTS) << "requst uri too long";
|
||||
_closeRequested = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -429,9 +426,6 @@ bool HttpCommTask::processRead(double startTime) {
|
|||
l = 6;
|
||||
}
|
||||
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "got corrupted HTTP request '" << std::string(sptr, l)
|
||||
<< "'";
|
||||
|
||||
// bad request, method not allowed
|
||||
addSimpleResponse(rest::ResponseCode::METHOD_NOT_ALLOWED, rest::ContentType::UNSET,
|
||||
1, VPackBuffer<uint8_t>());
|
||||
|
@ -640,16 +634,12 @@ bool HttpCommTask::checkContentLength(HttpRequest* request,
|
|||
|
||||
if (!expectContentLength && bodyLength > 0) {
|
||||
// content-length header was sent but the request method does not support
|
||||
// that
|
||||
// we'll warn but read the body anyway
|
||||
// that we'll warn but read the body anyway
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "received HTTP GET/HEAD request with content-length, this "
|
||||
"should not happen";
|
||||
}
|
||||
|
||||
if ((size_t)bodyLength > MaximalBodySize) {
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "maximal body size is " << MaximalBodySize
|
||||
<< ", request body size is " << bodyLength;
|
||||
|
||||
// request entity too large
|
||||
addSimpleResponse(rest::ResponseCode::REQUEST_ENTITY_TOO_LARGE, rest::ContentType::UNSET,
|
||||
1, VPackBuffer<uint8_t>());
|
||||
|
|
|
@ -38,8 +38,6 @@ class HttpCommTask final : public GeneralCommTask {
|
|||
void addSimpleResponse(rest::ResponseCode, rest::ContentType,
|
||||
uint64_t messageId, velocypack::Buffer<uint8_t>&&) override;
|
||||
|
||||
bool allowDirectHandling() const override final { return true; }
|
||||
|
||||
private:
|
||||
void processRequest(std::unique_ptr<HttpRequest>);
|
||||
void processCorsOptions(std::unique_ptr<HttpRequest>);
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
#include "Statistics/RequestStatistics.h"
|
||||
#include "Utils/ExecContext.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace arangodb;
|
||||
using namespace arangodb::basics;
|
||||
using namespace arangodb::rest;
|
||||
|
|
|
@ -23,11 +23,8 @@
|
|||
|
||||
#include "RestHandlerFactory.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Replication/ReplicationFeature.h"
|
||||
#include "Replication/GlobalReplicationApplier.h"
|
||||
#include "Rest/GeneralRequest.h"
|
||||
#include "RestHandler/RestBaseHandler.h"
|
||||
#include "RestHandler/RestDocumentHandler.h"
|
||||
|
||||
using namespace arangodb;
|
||||
using namespace arangodb::basics;
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include "Utils/Events.h"
|
||||
#include "VocBase/ticks.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
|
||||
|
|
|
@ -63,8 +63,6 @@ class VstCommTask final : public GeneralCommTask {
|
|||
// internal addResponse
|
||||
void addResponse(GeneralResponse&, RequestStatistics*) override;
|
||||
|
||||
bool allowDirectHandling() const override final { return false; }
|
||||
|
||||
private:
|
||||
// process the VST 1000 request type
|
||||
void handleAuthHeader(VPackSlice const& header, uint64_t messageId);
|
||||
|
|
|
@ -48,8 +48,6 @@
|
|||
#include "search/boolean_filter.hpp"
|
||||
#include "search/score.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
NS_LOCAL
|
||||
|
||||
inline arangodb::aql::RegisterId getRegister(
|
||||
|
|
|
@ -483,7 +483,6 @@ MMFilesCollection::MMFilesCollection(
|
|||
: PhysicalCollection(collection, info),
|
||||
_ditches(&collection),
|
||||
_initialCount(0),
|
||||
_revisionError(false),
|
||||
_lastRevision(0),
|
||||
_uncollectedLogfileEntries(0),
|
||||
_nextCompactionStartIndex(0),
|
||||
|
@ -537,7 +536,6 @@ MMFilesCollection::MMFilesCollection(
|
|||
_persistentIndexes = mmfiles._persistentIndexes;
|
||||
_useSecondaryIndexes = mmfiles._useSecondaryIndexes;
|
||||
_initialCount = mmfiles._initialCount;
|
||||
_revisionError = mmfiles._revisionError;
|
||||
_lastRevision = mmfiles._lastRevision;
|
||||
_nextCompactionStartIndex = mmfiles._nextCompactionStartIndex;
|
||||
_lastCompactionStatus = mmfiles._lastCompactionStatus;
|
||||
|
@ -1832,11 +1830,7 @@ void MMFilesCollection::open(bool ignoreErrors) {
|
|||
}
|
||||
|
||||
// successfully opened collection. now adjust version number
|
||||
if (LogicalCollection::VERSION_31 != _logicalCollection.version() &&
|
||||
!_revisionError &&
|
||||
application_features::ApplicationServer::server
|
||||
->getFeature<DatabaseFeature>("Database")
|
||||
->check30Revisions()) {
|
||||
if (LogicalCollection::VERSION_31 != _logicalCollection.version()) {
|
||||
_logicalCollection.setVersion(LogicalCollection::VERSION_31);
|
||||
|
||||
bool const doSync =
|
||||
|
@ -1878,36 +1872,6 @@ int MMFilesCollection::iterateMarkersOnLoad(transaction::Methods* trx) {
|
|||
<< openState._deletions << " deletion markers for collection '"
|
||||
<< _logicalCollection.name() << "'";
|
||||
|
||||
if (LogicalCollection::VERSION_30 >= _logicalCollection.version() &&
|
||||
_lastRevision >= static_cast<TRI_voc_rid_t>(2016ULL - 1970ULL) * 1000ULL *
|
||||
60ULL * 60ULL * 24ULL * 365ULL &&
|
||||
application_features::ApplicationServer::server
|
||||
->getFeature<DatabaseFeature>("Database")
|
||||
->check30Revisions()) {
|
||||
// a collection from 3.0 or earlier with a _rev value that is higher than we
|
||||
// can handle safely
|
||||
setRevisionError();
|
||||
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME)
|
||||
<< "collection '" << _logicalCollection.name()
|
||||
<< "' contains _rev values that are higher than expected for an "
|
||||
"ArangoDB 3.1 database. If this collection was created or used with "
|
||||
"a pre-release or development version of ArangoDB 3.1, please "
|
||||
"restart the server with option '--database.check-30-revisions "
|
||||
"false' to suppress this warning. If this collection was created "
|
||||
"with an ArangoDB 3.0, please dump the 3.0 database with arangodump "
|
||||
"and restore it in 3.1 with arangorestore.";
|
||||
if (application_features::ApplicationServer::server
|
||||
->getFeature<DatabaseFeature>("Database")
|
||||
->fail30Revisions()) {
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||
TRI_ERROR_ARANGO_CORRUPTED_DATAFILE,
|
||||
std::string("collection '") + _logicalCollection.name() +
|
||||
"' contains _rev values from 3.0 and needs to be migrated using "
|
||||
"dump/restore");
|
||||
}
|
||||
}
|
||||
|
||||
// update the real statistics for the collection
|
||||
try {
|
||||
for (auto& it : openState._stats) {
|
||||
|
|
|
@ -155,8 +155,6 @@ class MMFilesCollection final : public PhysicalCollection {
|
|||
|
||||
void setRevision(TRI_voc_rid_t revision, bool force);
|
||||
|
||||
void setRevisionError() { _revisionError = true; }
|
||||
|
||||
size_t journalSize() const;
|
||||
bool isVolatile() const;
|
||||
|
||||
|
@ -556,8 +554,6 @@ class MMFilesCollection final : public PhysicalCollection {
|
|||
|
||||
int64_t _initialCount;
|
||||
|
||||
bool _revisionError;
|
||||
|
||||
MMFilesDatafileStatistics _datafileStatistics;
|
||||
|
||||
TRI_voc_rid_t _lastRevision;
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
#include "Basics/Common.h"
|
||||
|
||||
namespace arangodb {
|
||||
class HttpRequest;
|
||||
|
||||
namespace rest {
|
||||
class RestHandler;
|
||||
}
|
||||
|
@ -36,11 +34,6 @@ class RestHandler;
|
|||
template <typename H>
|
||||
class RestHandlerCreator : public H {
|
||||
public:
|
||||
static rest::RestHandler* create(GeneralRequest* request,
|
||||
GeneralResponse* response, void* data) {
|
||||
return new H(request, response, data);
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
static rest::RestHandler* createData(GeneralRequest* request,
|
||||
GeneralResponse* response, void* data) {
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#include "Rest/Version.h"
|
||||
#include "RestServer/ServerFeature.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#if defined(TRI_HAVE_POSIX_THREADS)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
|
|
@ -226,7 +226,6 @@ DatabaseFeature::DatabaseFeature(ApplicationServer* server)
|
|||
_defaultWaitForSync(false),
|
||||
_forceSyncProperties(true),
|
||||
_ignoreDatafileErrors(false),
|
||||
_check30Revisions("true"),
|
||||
_throwCollectionNotLoadedError(false),
|
||||
_vocbase(nullptr),
|
||||
_databasesLists(new DatabasesLists()),
|
||||
|
@ -282,18 +281,16 @@ void DatabaseFeature::collectOptions(std::shared_ptr<ProgramOptions> options) {
|
|||
"throw an error when accessing a collection that is still loading",
|
||||
new AtomicBooleanParameter(&_throwCollectionNotLoadedError));
|
||||
|
||||
options->addHiddenOption(
|
||||
"--database.check-30-revisions",
|
||||
"check _rev values in collections created before 3.1",
|
||||
new DiscreteValuesParameter<StringParameter>(
|
||||
&_check30Revisions,
|
||||
std::unordered_set<std::string>{"true", "false", "fail"}));
|
||||
|
||||
// the following option was removed in 3.2
|
||||
// index-creation is now automatically parallelized via the Boost ASIO thread pool
|
||||
options->addObsoleteOption(
|
||||
"--database.index-threads",
|
||||
"threads to start for parallel background index creation", true);
|
||||
|
||||
// the following hidden option was removed in 3.4
|
||||
options->addObsoleteOption(
|
||||
"--database.check-30-revisions",
|
||||
"check for revision values from ArangoDB 3.0 databases", true);
|
||||
|
||||
// the following options were removed in 3.2
|
||||
options->addObsoleteOption("--database.revision-cache-chunk-size",
|
||||
|
|
|
@ -134,8 +134,6 @@ class DatabaseFeature : public application_features::ApplicationFeature {
|
|||
void enableUpgrade() { _upgrade = true; }
|
||||
bool throwCollectionNotLoadedError() const { return _throwCollectionNotLoadedError.load(std::memory_order_relaxed); }
|
||||
void throwCollectionNotLoadedError(bool value) { _throwCollectionNotLoadedError.store(value); }
|
||||
bool check30Revisions() const { return _check30Revisions == "true" || _check30Revisions == "fail"; }
|
||||
bool fail30Revisions() const { return _check30Revisions == "fail"; }
|
||||
void isInitiallyEmpty(bool value) { _isInitiallyEmpty = value; }
|
||||
|
||||
private:
|
||||
|
@ -167,10 +165,8 @@ class DatabaseFeature : public application_features::ApplicationFeature {
|
|||
bool _defaultWaitForSync;
|
||||
bool _forceSyncProperties;
|
||||
bool _ignoreDatafileErrors;
|
||||
std::string _check30Revisions;
|
||||
std::atomic<bool> _throwCollectionNotLoadedError;
|
||||
|
||||
|
||||
TRI_vocbase_t* _vocbase; // _system database
|
||||
std::unique_ptr<DatabaseManagerThread> _databaseManager;
|
||||
|
||||
|
|
|
@ -334,4 +334,6 @@ void TRI_InitV8IndexCollection(v8::Isolate* isolate,
|
|||
JS_LookupIndexVocbaseCol);
|
||||
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING(isolate, "getIndexes"),
|
||||
JS_GetIndexesVocbaseCol);
|
||||
TRI_AddMethodVocbase(isolate, rt, TRI_V8_ASCII_STRING(isolate, "indexes"),
|
||||
JS_GetIndexesVocbaseCol); // indexes() is an alias for getIndexes() now!
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include <velocypack/Collection.h>
|
||||
#include <velocypack/Parser.h>
|
||||
#include <velocypack/velocypack-aliases.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "ApplicationFeatures/ApplicationServer.h"
|
||||
#include "Aql/PlanCache.h"
|
||||
|
@ -45,7 +44,6 @@
|
|||
#include "Basics/WriteLocker.h"
|
||||
#include "Basics/conversions.h"
|
||||
#include "Basics/files.h"
|
||||
#include "Basics/locks.h"
|
||||
#include "Basics/memory-map.h"
|
||||
#include "Basics/threads.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
|
|
|
@ -258,7 +258,7 @@ var helpArangoCollection = arangosh.createHelpHeadline('ArangoCollection help')
|
|||
' name() collection name ' + '\n' +
|
||||
' status() status of the collection ' + '\n' +
|
||||
' type() type of the collection ' + '\n' +
|
||||
' truncate() delete all documents ' + '\n' +
|
||||
' truncate() remove all documents ' + '\n' +
|
||||
' properties() show collection properties ' + '\n' +
|
||||
' properties(<data>) change collection properties ' + '\n' +
|
||||
' drop() delete a collection ' + '\n' +
|
||||
|
@ -266,7 +266,7 @@ var helpArangoCollection = arangosh.createHelpHeadline('ArangoCollection help')
|
|||
' unload() unload a collection ' + '\n' +
|
||||
' rename(<new-name>) renames a collection ' + '\n' +
|
||||
' getIndexes() return defined indexes ' + '\n' +
|
||||
' refresh() refreshes the status and name ' + '\n' +
|
||||
' refresh() refresh the status and name ' + '\n' +
|
||||
' _help() this help ' + '\n' +
|
||||
' ' + '\n' +
|
||||
'Document Functions: ' + '\n' +
|
||||
|
@ -276,8 +276,8 @@ var helpArangoCollection = arangosh.createHelpHeadline('ArangoCollection help')
|
|||
' replace(<id>, <data>, <overwrite>) overwrite document ' + '\n' +
|
||||
' update(<id>, <data>, <overwrite>, partially update document ' + '\n' +
|
||||
' <keepNull>) ' + '\n' +
|
||||
' remove(<id>) delete document ' + '\n' +
|
||||
' exists(<id>) checks whether a document exists ' + '\n' +
|
||||
' remove(<id>) remove document ' + '\n' +
|
||||
' exists(<id>) check whether a document exists ' + '\n' +
|
||||
' ' + '\n' +
|
||||
'Attributes: ' + '\n' +
|
||||
' _database database object ' + '\n' +
|
||||
|
@ -598,7 +598,7 @@ ArangoCollection.prototype.refresh = function () {
|
|||
// / @brief gets all indexes
|
||||
// //////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ArangoCollection.prototype.getIndexes = function (withStats) {
|
||||
ArangoCollection.prototype.getIndexes = ArangoCollection.prototype.indexes = function (withStats) {
|
||||
var requestResult = this._database._connection.GET(this._indexurl() +
|
||||
'&withStats=' + (withStats || false));
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ function indexSuite() {
|
|||
|
||||
setUp : function () {
|
||||
internal.db._drop(cn);
|
||||
collection = internal.db._create(cn, { waitForSync : false });
|
||||
collection = internal.db._create(cn);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -66,7 +66,23 @@ function indexSuite() {
|
|||
catch (err) {
|
||||
}
|
||||
collection = null;
|
||||
internal.wait(0.0);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test: indexes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testIndexes : function () {
|
||||
var res = collection.indexes();
|
||||
|
||||
assertEqual(1, res.length);
|
||||
|
||||
collection.ensureGeoIndex("a");
|
||||
collection.ensureGeoIndex("a", "b");
|
||||
|
||||
res = collection.indexes();
|
||||
|
||||
assertEqual(3, res.length);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -249,7 +265,6 @@ function getIndexesSuite() {
|
|||
tearDown : function () {
|
||||
collection.drop();
|
||||
collection = null;
|
||||
internal.wait(0.0);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -721,7 +736,6 @@ function getIndexesEdgesSuite() {
|
|||
tearDown : function () {
|
||||
collection.drop();
|
||||
collection = null;
|
||||
internal.wait(0.0);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -26,43 +26,25 @@
|
|||
|
||||
using namespace arangodb::basics;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ConditionVariable::ConditionVariable() : _condition() {
|
||||
TRI_InitCondition(&_condition);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief deletes the condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ConditionVariable::~ConditionVariable() { TRI_DestroyCondition(&_condition); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief locks the condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ConditionVariable::lock() { TRI_LockCondition(&_condition); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief releases the lock on the condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ConditionVariable::unlock() { TRI_UnlockCondition(&_condition); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for an event
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ConditionVariable::wait() { TRI_WaitCondition(&_condition); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for an event with timeout in micro seconds
|
||||
/// returns true when the condition was signaled, false on timeout
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool ConditionVariable::wait(uint64_t delay) {
|
||||
return TRI_TimedWaitCondition(&_condition, delay);
|
||||
}
|
||||
|
@ -70,14 +52,8 @@ bool ConditionVariable::wait(std::chrono::microseconds delay_us) {
|
|||
return TRI_TimedWaitCondition(&_condition, delay_us.count());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief signals all waiting threads
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ConditionVariable::broadcast() { TRI_BroadcastCondition(&_condition); }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief signals a waiting thread
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ConditionVariable::signal() { TRI_SignalCondition(&_condition); }
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
namespace arangodb {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief condition variable
|
||||
///
|
||||
/// A condition variable consists of a condition and a monitor.
|
||||
|
@ -61,69 +60,40 @@ namespace basics {
|
|||
/// resumes its execution when another thread causes the event to
|
||||
/// occur. However, there are major differences as will be discussed on a later
|
||||
/// page.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ConditionVariable {
|
||||
ConditionVariable(ConditionVariable const&) = delete;
|
||||
ConditionVariable& operator=(ConditionVariable const&) = delete;
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a condition variable
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ConditionVariable();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief deletes the condition variable
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~ConditionVariable();
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief locks the condition variable
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void lock();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief releases the lock on the condition variable
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void unlock();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for an event
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void wait();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for an event with timeout in micro seconds
|
||||
/// returns true when the condition was signaled, false on timeout
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool wait(uint64_t);
|
||||
bool wait(std::chrono::microseconds);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief signals all waiting threads
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void broadcast();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief signals a waiting thread
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void signal();
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief condition variable
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_condition_t _condition;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#error use <Basics/Common.h>
|
||||
#endif
|
||||
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
|
||||
#define SCOPE_GUARD_TOKEN_PASTE_WRAPPED(x, y) x##y
|
||||
|
@ -82,9 +81,6 @@ class ScopeGuard {
|
|||
}
|
||||
}
|
||||
|
||||
// don't allow creation of any ScopeGuards on the heap
|
||||
void* operator new(std::size_t) = delete;
|
||||
|
||||
// make the guard not trigger the function at scope exit
|
||||
void cancel() noexcept { _active = false; }
|
||||
|
||||
|
|
|
@ -576,28 +576,6 @@ size_t TRI_StringUInt64InPlace(uint64_t attr, char* buffer) {
|
|||
return (p - buffer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief convert to string from uint32
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_StringUInt32(uint32_t attr) {
|
||||
char buffer[11];
|
||||
size_t len = TRI_StringUInt32InPlace(attr, (char*)&buffer);
|
||||
|
||||
return TRI_DuplicateString(buffer, len);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief convert to string from uint64
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_StringUInt64(uint64_t attr) {
|
||||
char buffer[21];
|
||||
size_t len = TRI_StringUInt64InPlace(attr, (char*)&buffer);
|
||||
|
||||
return TRI_DuplicateString(buffer, len);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief convert to hex string from uint32, using the specified buffer.
|
||||
/// A NUL-byte will be appended at the end.
|
||||
|
|
|
@ -144,18 +144,6 @@ size_t TRI_StringInt64InPlace(int64_t, char*);
|
|||
|
||||
size_t TRI_StringUInt64InPlace(uint64_t, char*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief convert to string from uint32
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_StringUInt32(uint32_t);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief convert to string from uint64
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char* TRI_StringUInt64(uint64_t);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief convert to a hex string from uint32, using the specified buffer.
|
||||
/// A NUL-byte will be appended at the end.
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Logger/LogAppender.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/ReadWriteLock.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
#include "Logger/LogAppender.h"
|
||||
#include "Logger/Logger.h"
|
||||
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
#if ARANGODB_ENABLE_BACKTRACE
|
||||
|
@ -42,38 +42,14 @@
|
|||
|
||||
using namespace arangodb;
|
||||
|
||||
/// @brief a global string containing the currently registered failure points
|
||||
/// the string is a comma-separated list of point names
|
||||
static char* FailurePoints = nullptr;
|
||||
|
||||
/// @brief a read-write lock for thread-safe access to the failure-points list
|
||||
arangodb::basics::ReadWriteLock FailurePointsLock;
|
||||
|
||||
#ifdef ARANGODB_ENABLE_FAILURE_TESTS
|
||||
|
||||
/// @brief make a delimited value from a string, so we can unambigiously
|
||||
/// search for it (e.g. searching for just "foo" would find "foo" and "foobar",
|
||||
/// so we'll be putting the value inside some delimiter: ",foo,")
|
||||
static char* MakeValue(char const* value) {
|
||||
if (value == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
size_t const len = strlen(value);
|
||||
if (len == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
namespace {
|
||||
/// @brief a global set containing the currently registered failure points
|
||||
std::unordered_set<std::string> failurePoints;
|
||||
|
||||
char* delimited =
|
||||
static_cast<char*>(TRI_Allocate(len + 3));
|
||||
|
||||
if (delimited != nullptr) {
|
||||
memcpy(delimited + 1, value, len);
|
||||
delimited[0] = ',';
|
||||
delimited[len + 1] = ',';
|
||||
delimited[len + 2] = '\0';
|
||||
}
|
||||
|
||||
return delimited;
|
||||
/// @brief a read-write lock for thread-safe access to the failure points set
|
||||
arangodb::basics::ReadWriteLock failurePointsLock;
|
||||
}
|
||||
|
||||
/// @brief cause a segmentation violation
|
||||
|
@ -95,159 +71,36 @@ void TRI_SegfaultDebugging(char const* message) {
|
|||
|
||||
/// @brief check whether we should fail at a specific failure point
|
||||
bool TRI_ShouldFailDebugging(char const* value) {
|
||||
char* found = nullptr;
|
||||
READ_LOCKER(readLocker, ::failurePointsLock);
|
||||
|
||||
// try without the lock first (to speed things up)
|
||||
if (FailurePoints == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
READ_LOCKER(readLocker, FailurePointsLock);
|
||||
|
||||
if (FailurePoints != nullptr) {
|
||||
char* checkValue = MakeValue(value);
|
||||
|
||||
if (checkValue != nullptr) {
|
||||
found = strstr(FailurePoints, checkValue);
|
||||
TRI_Free(checkValue);
|
||||
}
|
||||
}
|
||||
|
||||
return (found != nullptr);
|
||||
return ::failurePoints.find(value) != ::failurePoints.end();
|
||||
}
|
||||
|
||||
/// @brief add a failure point
|
||||
void TRI_AddFailurePointDebugging(char const* value) {
|
||||
char* checkValue = MakeValue(value);
|
||||
|
||||
if (checkValue == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
WRITE_LOCKER(writeLocker, FailurePointsLock);
|
||||
|
||||
char* found;
|
||||
if (FailurePoints == nullptr) {
|
||||
found = nullptr;
|
||||
} else {
|
||||
found = strstr(FailurePoints, checkValue);
|
||||
}
|
||||
|
||||
if (found == nullptr) {
|
||||
// not yet found. so add it
|
||||
char* copy;
|
||||
WRITE_LOCKER(writeLocker, ::failurePointsLock);
|
||||
|
||||
if (::failurePoints.emplace(value).second) {
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "activating intentional failure point '" << value << "'. the server will misbehave!";
|
||||
size_t n = strlen(checkValue);
|
||||
|
||||
if (FailurePoints == nullptr) {
|
||||
copy =
|
||||
static_cast<char*>(TRI_Allocate(n + 1));
|
||||
|
||||
if (copy == nullptr) {
|
||||
TRI_Free(checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(copy, checkValue, n);
|
||||
copy[n] = '\0';
|
||||
} else {
|
||||
copy = static_cast<char*>(
|
||||
TRI_Allocate(n + strlen(FailurePoints)));
|
||||
|
||||
if (copy == nullptr) {
|
||||
TRI_Free(checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(copy, FailurePoints, strlen(FailurePoints));
|
||||
memcpy(copy + strlen(FailurePoints) - 1, checkValue, n);
|
||||
copy[strlen(FailurePoints) + n - 1] = '\0';
|
||||
|
||||
TRI_Free(FailurePoints);
|
||||
}
|
||||
|
||||
FailurePoints = copy;
|
||||
}
|
||||
|
||||
TRI_Free(checkValue);
|
||||
}
|
||||
|
||||
/// @brief remove a failure point
|
||||
void TRI_RemoveFailurePointDebugging(char const* value) {
|
||||
WRITE_LOCKER(writeLocker, FailurePointsLock);
|
||||
WRITE_LOCKER(writeLocker, ::failurePointsLock);
|
||||
|
||||
if (FailurePoints == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* checkValue = MakeValue(value);
|
||||
|
||||
if (checkValue != nullptr) {
|
||||
char* found = strstr(FailurePoints, checkValue);
|
||||
|
||||
if (found == nullptr) {
|
||||
TRI_Free(checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen(FailurePoints) - strlen(checkValue) <= 2) {
|
||||
TRI_Free(FailurePoints);
|
||||
FailurePoints = nullptr;
|
||||
|
||||
TRI_Free(checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
char* copy = static_cast<char*>(
|
||||
TRI_Allocate( strlen(FailurePoints) - strlen(checkValue) + 2));
|
||||
|
||||
if (copy == nullptr) {
|
||||
TRI_Free(checkValue);
|
||||
return;
|
||||
}
|
||||
|
||||
// copy start of string
|
||||
size_t n = found - FailurePoints;
|
||||
memcpy(copy, FailurePoints, n);
|
||||
|
||||
// copy remainder of string
|
||||
memcpy(copy + n, found + strlen(checkValue) - 1,
|
||||
strlen(FailurePoints) - strlen(checkValue) - n + 1);
|
||||
|
||||
copy[strlen(FailurePoints) - strlen(checkValue) + 1] = '\0';
|
||||
TRI_Free(FailurePoints);
|
||||
FailurePoints = copy;
|
||||
|
||||
TRI_Free(checkValue);
|
||||
}
|
||||
::failurePoints.erase(value);
|
||||
}
|
||||
|
||||
/// @brief clear all failure points
|
||||
void TRI_ClearFailurePointsDebugging() {
|
||||
WRITE_LOCKER(writeLocker, FailurePointsLock);
|
||||
WRITE_LOCKER(writeLocker, ::failurePointsLock);
|
||||
|
||||
if (FailurePoints != nullptr) {
|
||||
TRI_Free(FailurePoints);
|
||||
}
|
||||
|
||||
FailurePoints = nullptr;
|
||||
::failurePoints.clear();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// @brief initialize the debugging
|
||||
void TRI_InitializeDebugging() {}
|
||||
|
||||
/// @brief shutdown the debugging
|
||||
void TRI_ShutdownDebugging() {
|
||||
if (FailurePoints != nullptr) {
|
||||
TRI_Free(FailurePoints);
|
||||
}
|
||||
|
||||
FailurePoints = nullptr;
|
||||
}
|
||||
|
||||
/// @brief appends a backtrace to the string provided
|
||||
void TRI_GetBacktrace(std::string& btstr) {
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
|
@ -382,4 +235,3 @@ void TRI_FlushDebugging(char const* file, int line, char const* message) {
|
|||
Logger::flush();
|
||||
Logger::shutdown();
|
||||
}
|
||||
|
||||
|
|
|
@ -95,12 +95,6 @@ void TRI_PrintBacktrace();
|
|||
/// @brief logs a backtrace in log level warning
|
||||
void TRI_LogBacktrace();
|
||||
|
||||
/// @brief initialize the debugging
|
||||
void TRI_InitializeDebugging();
|
||||
|
||||
/// @brief shutdown the debugging
|
||||
void TRI_ShutdownDebugging();
|
||||
|
||||
/// @brief flushes the logger and shuts it down
|
||||
void TRI_FlushDebugging();
|
||||
void TRI_FlushDebugging(char const* file, int line, char const* message);
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/* lib/Basics/local-configuration.h. Generated from local-configuration.h.in by
|
||||
* configure. */
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief High-Performance Database Framework made by triagens
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
|
||||
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_BASICS_LOCAL__CONFIGURATION__WIN_H
|
||||
#define ARANGODB_BASICS_LOCAL__CONFIGURATION__WIN_H 1
|
||||
|
||||
#ifndef TRI_WITHIN_COMMON
|
||||
#error use <Basics/Common.h>
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -29,141 +29,6 @@
|
|||
|
||||
#include "Logger/Logger.h"
|
||||
|
||||
#define BUSY_LOCK_DELAY (10 * 1000)
|
||||
|
||||
/// @brief initializes a new mutex
|
||||
int TRI_InitMutex(TRI_mutex_t* mutex) {
|
||||
return pthread_mutex_init(mutex, nullptr);
|
||||
}
|
||||
|
||||
/// @brief destroys a mutex
|
||||
int TRI_DestroyMutex(TRI_mutex_t* mutex) {
|
||||
return pthread_mutex_destroy(mutex);
|
||||
}
|
||||
|
||||
/// @brief locks mutex
|
||||
void TRI_LockMutex(TRI_mutex_t* mutex) {
|
||||
int rc = pthread_mutex_lock(mutex);
|
||||
|
||||
if (rc != 0) {
|
||||
if (rc == EDEADLK) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "mutex deadlock detected";
|
||||
}
|
||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "could not lock the TRI_mutex: " << strerror(rc);
|
||||
FATAL_ERROR_ABORT();
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief unlocks mutex
|
||||
void TRI_UnlockMutex(TRI_mutex_t* mutex) {
|
||||
int rc = pthread_mutex_unlock(mutex);
|
||||
|
||||
if (rc != 0) {
|
||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "could not release the mutex: " << strerror(rc);
|
||||
FATAL_ERROR_ABORT();
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief initializes a new read-write lock
|
||||
void TRI_InitReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
pthread_rwlock_init(lock, nullptr);
|
||||
}
|
||||
|
||||
/// @brief destroys a read-write lock
|
||||
void TRI_DestroyReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
pthread_rwlock_destroy(lock);
|
||||
}
|
||||
|
||||
/// @brief tries to read lock read-write lock
|
||||
bool TRI_TryReadLockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
int rc = pthread_rwlock_tryrdlock(lock);
|
||||
|
||||
return (rc == 0);
|
||||
}
|
||||
|
||||
/// @brief read locks read-write lock
|
||||
static void ReadContinue(int rc, TRI_read_write_lock_t* lock) {
|
||||
bool complained = false;
|
||||
|
||||
again:
|
||||
if (rc == EAGAIN) {
|
||||
// use busy waiting if we cannot acquire the read-lock in case of too many
|
||||
// concurrent read locks ("resource temporarily unavailable").
|
||||
// in this case we'll wait in a busy loop until we can acquire the lock
|
||||
if (!complained) {
|
||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "too many read-locks on read-write lock";
|
||||
complained = true;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(BUSY_LOCK_DELAY));
|
||||
#ifdef TRI_HAVE_SCHED_H
|
||||
// let other threads do things
|
||||
sched_yield();
|
||||
#endif
|
||||
|
||||
rc = pthread_rwlock_rdlock(lock);
|
||||
if (rc == 0) {
|
||||
return; // done
|
||||
}
|
||||
// ideal use case for goto :-)
|
||||
goto again;
|
||||
}
|
||||
|
||||
if (rc == EDEADLK) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "rw-lock deadlock detected";
|
||||
}
|
||||
|
||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "could not read-lock the read-write lock: " << strerror(rc);
|
||||
FATAL_ERROR_ABORT();
|
||||
}
|
||||
|
||||
void TRI_ReadLockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
int rc = pthread_rwlock_rdlock(lock);
|
||||
|
||||
if (rc != 0) {
|
||||
ReadContinue(rc, lock);
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief read unlocks read-write lock
|
||||
void TRI_ReadUnlockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
int rc = pthread_rwlock_unlock(lock);
|
||||
|
||||
if (rc != 0) {
|
||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "could not read-unlock the read-write lock: " << strerror(rc);
|
||||
FATAL_ERROR_ABORT();
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief tries to write lock read-write lock
|
||||
bool TRI_TryWriteLockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
int rc = pthread_rwlock_trywrlock(lock);
|
||||
|
||||
return (rc == 0);
|
||||
}
|
||||
|
||||
/// @brief write locks read-write lock
|
||||
void TRI_WriteLockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
int rc = pthread_rwlock_wrlock(lock);
|
||||
|
||||
if (rc != 0) {
|
||||
if (rc == EDEADLK) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "rw-lock deadlock detected";
|
||||
}
|
||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "could not write-lock the read-write lock: " << strerror(rc);
|
||||
FATAL_ERROR_ABORT();
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief write unlocks read-write lock
|
||||
void TRI_WriteUnlockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
int rc = pthread_rwlock_unlock(lock);
|
||||
|
||||
if (rc != 0) {
|
||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "could not write-unlock the read-write lock: " << strerror(rc);
|
||||
FATAL_ERROR_ABORT();
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief initializes a new condition variable
|
||||
void TRI_InitCondition(TRI_condition_t* cond) {
|
||||
pthread_cond_init(&cond->_cond, nullptr);
|
||||
|
|
|
@ -28,12 +28,6 @@
|
|||
|
||||
#ifdef TRI_HAVE_POSIX_THREADS
|
||||
|
||||
/// @brief mutex type
|
||||
#define TRI_mutex_t pthread_mutex_t
|
||||
|
||||
/// @brief read-write-lock type
|
||||
#define TRI_read_write_lock_t pthread_rwlock_t
|
||||
|
||||
/// @brief condition variable
|
||||
struct TRI_condition_t {
|
||||
pthread_cond_t _cond;
|
||||
|
|
|
@ -23,159 +23,42 @@
|
|||
|
||||
#include "locks.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializes a new mutex
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_InitMutex(TRI_mutex_t* mutex) {
|
||||
// as of VS2013, exclusive SRWLocks tend to be faster than native mutexes
|
||||
InitializeSRWLock(&mutex->_mutex);
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroys a mutex
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_DestroyMutex(TRI_mutex_t* mutex) {
|
||||
// as of VS2013, exclusive SRWLocks tend to be faster than native mutexes
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief locks mutex
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_LockMutex(TRI_mutex_t* mutex) {
|
||||
// as of VS2013, exclusive SRWLocks tend to be faster than native mutexes
|
||||
AcquireSRWLockExclusive(&mutex->_mutex);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief unlocks mutex
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_UnlockMutex(TRI_mutex_t* mutex) {
|
||||
// as of VS2013, exclusive SRWLocks tend to be faster than native mutexes
|
||||
ReleaseSRWLockExclusive(&mutex->_mutex);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializes a new read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
InitializeSRWLock(&lock->_lock);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroys a read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_DestroyReadWriteLock(TRI_read_write_lock_t* lock) {}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tries to read lock a read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_TryReadLockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
return (TryAcquireSRWLockShared(&lock->_lock) != 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read locks read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ReadLockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
AcquireSRWLockShared(&lock->_lock);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read unlocks read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ReadUnlockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
ReleaseSRWLockShared(&lock->_lock);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tries to write lock a read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_TryWriteLockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
return (TryAcquireSRWLockExclusive(&lock->_lock) != 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief write locks read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WriteLockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
AcquireSRWLockExclusive(&lock->_lock);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief write unlocks read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WriteUnlockReadWriteLock(TRI_read_write_lock_t* lock) {
|
||||
ReleaseSRWLockExclusive(&lock->_lock);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializes a new condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitCondition(TRI_condition_t* cond) {
|
||||
InitializeCriticalSection(&cond->_lockWaiters);
|
||||
InitializeConditionVariable(&cond->_conditionVariable);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroys a condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_DestroyCondition(TRI_condition_t* cond) {
|
||||
DeleteCriticalSection(&cond->_lockWaiters);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief signals a condition variable
|
||||
///
|
||||
/// Note that you must hold the lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_SignalCondition(TRI_condition_t* cond) {
|
||||
WakeConditionVariable(&cond->_conditionVariable);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief broad casts a condition variable
|
||||
///
|
||||
/// Note that you must hold the lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_BroadcastCondition(TRI_condition_t* cond) {
|
||||
WakeAllConditionVariable(&cond->_conditionVariable);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for a signal on a condition variable
|
||||
///
|
||||
/// Note that you must hold the lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WaitCondition(TRI_condition_t* cond) {
|
||||
SleepConditionVariableCS(&cond->_conditionVariable, &cond->_lockWaiters,
|
||||
INFINITE);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for a signal with a timeout in micro-seconds
|
||||
///
|
||||
/// Note that you must hold the lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_TimedWaitCondition(TRI_condition_t* cond, uint64_t delay) {
|
||||
// ...........................................................................
|
||||
// The POSIX threads function pthread_cond_timedwait accepts microseconds
|
||||
|
@ -197,86 +80,12 @@ bool TRI_TimedWaitCondition(TRI_condition_t* cond, uint64_t delay) {
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief locks the mutex of a condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_LockCondition(TRI_condition_t* cond) {
|
||||
EnterCriticalSection(&cond->_lockWaiters);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief unlocks the mutex of a condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_UnlockCondition(TRI_condition_t* cond) {
|
||||
LeaveCriticalSection(&cond->_lockWaiters);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// COMPARE & SWAP operations below for windows
|
||||
// Note that for the MAC OS we use the 'barrier' functions which ensure that
|
||||
// read/write operations on the scalars are executed in order. According to the
|
||||
// available documentation, the GCC variants of these COMPARE & SWAP operations
|
||||
// are implemented with a memory barrier. The MS Windows variants of these
|
||||
// operations (according to the documentation on MS site) also provide a full
|
||||
// memory barrier.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief atomically compares and swaps 32bit integers with full memory barrier
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_CompareAndSwapIntegerInt32 (volatile int32_t* theValue, int32_t oldValue, int32_t newValue) {
|
||||
return ( (int32_t)( InterlockedCompareExchange((volatile LONG*)(theValue), (LONG)(newValue), (LONG)(oldValue) ) ) == oldValue );
|
||||
}
|
||||
|
||||
bool TRI_CompareIntegerInt32 (volatile int32_t* theValue, int32_t oldValue) {
|
||||
return ( (int32_t)( InterlockedCompareExchange((volatile LONG*)(theValue), (LONG)(oldValue), (LONG)(oldValue) ) ) == oldValue );
|
||||
}
|
||||
|
||||
bool TRI_CompareAndSwapIntegerUInt32 (volatile uint32_t* theValue, uint32_t oldValue, uint32_t newValue) {
|
||||
return ( (uint32_t)(InterlockedCompareExchange((volatile LONG*)(theValue), (LONG)(newValue), (LONG)(oldValue) ) ) == oldValue );
|
||||
}
|
||||
|
||||
bool TRI_CompareIntegerUInt32 (volatile uint32_t* theValue, uint32_t oldValue) {
|
||||
return ( (uint32_t)(InterlockedCompareExchange((volatile LONG*)(theValue), (LONG)(oldValue), (LONG)(oldValue) ) ) == oldValue );
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief atomically compares and swaps 64bit integers with full memory barrier
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_CompareAndSwapIntegerInt64 (volatile int64_t* theValue, int64_t oldValue, int64_t newValue) {
|
||||
return ( (int64_t)(InterlockedCompareExchange64((volatile LONGLONG*)(theValue), (LONGLONG)(newValue), (LONGLONG)(oldValue) ) ) == oldValue );
|
||||
}
|
||||
|
||||
bool TRI_CompareIntegerInt64 (volatile int64_t* theValue, int64_t oldValue) {
|
||||
return ( (int64_t)(InterlockedCompareExchange64((volatile LONGLONG*)(theValue), (LONGLONG)(oldValue), (LONGLONG)(oldValue) ) ) == oldValue );
|
||||
}
|
||||
|
||||
bool TRI_CompareAndSwapIntegerUInt64 (volatile uint64_t* theValue, uint64_t oldValue, uint64_t newValue) {
|
||||
return ( (uint64_t)(InterlockedCompareExchange64((volatile LONGLONG*)(theValue), (LONGLONG)(newValue), (LONGLONG)(oldValue) ) ) == oldValue );
|
||||
}
|
||||
|
||||
bool TRI_CompareIntegerUInt64 (volatile uint64_t* theValue, uint64_t oldValue) {
|
||||
return ( (uint64_t)(InterlockedCompareExchange64((volatile LONGLONG*)(theValue), (LONGLONG)(oldValue), (LONGLONG)(oldValue) ) ) == oldValue );
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief atomically compares and swaps pointers with full memory barrier
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_CompareAndSwapPointer(void* volatile* theValue, void* oldValue, void* newValue) {
|
||||
return ( InterlockedCompareExchangePointer(theValue, newValue, oldValue) == oldValue );
|
||||
}
|
||||
|
||||
bool TRI_ComparePointer(void* volatile* theValue, void* oldValue) {
|
||||
return ( InterlockedCompareExchangePointer(theValue, oldValue, oldValue) == oldValue );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,29 +28,11 @@
|
|||
|
||||
#ifdef TRI_HAVE_WIN32_THREADS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief mutex type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_mutex_s {
|
||||
// as of VS2013, exclusive SRWLocks tend to be faster than native mutexes
|
||||
SRWLOCK _mutex;
|
||||
} TRI_mutex_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read-write-lock type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_read_write_lock_s { SRWLOCK _lock; } TRI_read_write_lock_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct TRI_condition_s {
|
||||
typedef struct TRI_condition_t {
|
||||
CRITICAL_SECTION _lockWaiters;
|
||||
CONDITION_VARIABLE _conditionVariable;
|
||||
} TRI_condition_t;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,157 +34,37 @@
|
|||
#include "Basics/locks-win32.h"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializes a new mutex
|
||||
///
|
||||
/// Mutual exclusion (often abbreviated to mutex) algorithms are used in
|
||||
/// concurrent programming to avoid the simultaneous use of a common resource,
|
||||
/// such as a global variable, by pieces of computer code called critical
|
||||
/// sections. A critical section is a piece of code in which a process or thread
|
||||
/// accesses a common resource. The critical section by itself is not a
|
||||
/// mechanism or algorithm for mutual exclusion. A program, process, or thread
|
||||
/// can have the critical section in it without any mechanism or algorithm which
|
||||
/// implements mutual exclusion. For details see www.wikipedia.org.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_InitMutex(TRI_mutex_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroys a mutex
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TRI_DestroyMutex(TRI_mutex_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief locks mutex
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_LockMutex(TRI_mutex_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief unlocks mutex
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_UnlockMutex(TRI_mutex_t*);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializes a new read-write lock
|
||||
///
|
||||
/// A ReadWriteLock maintains a pair of associated locks, one for read-only
|
||||
/// operations and one for writing. The read lock may be held simultaneously by
|
||||
/// multiple reader threads, so long as there are no writers. The write lock is
|
||||
/// exclusive.
|
||||
///
|
||||
/// A read-write lock allows for a greater level of concurrency in accessing
|
||||
/// shared data than that permitted by a mutual exclusion lock. It exploits the
|
||||
/// fact that while only a single thread at a time (a writer thread) can modify
|
||||
/// the shared data, in many cases any number of threads can concurrently read
|
||||
/// the data (hence reader threads). In theory, the increase in concurrency
|
||||
/// permitted by the use of a read-write lock will lead to performance
|
||||
/// improvements over the use of a mutual exclusion lock. In practice this
|
||||
/// increase in concurrency will only be fully realized on a multi-processor,
|
||||
/// and then only if the access patterns for the shared data are suitable.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitReadWriteLock(TRI_read_write_lock_t* lock);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroyes a read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_DestroyReadWriteLock(TRI_read_write_lock_t* lock);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tries to read lock read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_TryReadLockReadWriteLock(TRI_read_write_lock_t* lock);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read locks read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ReadLockReadWriteLock(TRI_read_write_lock_t* lock);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief read unlocks read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_ReadUnlockReadWriteLock(TRI_read_write_lock_t* lock);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tries to write lock read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_TryWriteLockReadWriteLock(TRI_read_write_lock_t* lock);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief write locks read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WriteLockReadWriteLock(TRI_read_write_lock_t* lock);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief write unlocks read-write lock
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WriteUnlockReadWriteLock(TRI_read_write_lock_t* lock);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief initializes a new condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_InitCondition(TRI_condition_t* cond);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destroys a condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_DestroyCondition(TRI_condition_t* cond);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief signals a condition variable
|
||||
///
|
||||
/// Note that you must hold the lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_SignalCondition(TRI_condition_t* cond);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief broad casts a condition variable
|
||||
///
|
||||
/// Note that you must hold the lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_BroadcastCondition(TRI_condition_t* cond);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for a signal on a condition variable
|
||||
///
|
||||
/// Note that you must hold the lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_WaitCondition(TRI_condition_t* cond);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief waits for a signal with a timeout in micro-seconds
|
||||
/// returns true when the condition was signaled, false on timeout
|
||||
///
|
||||
/// Note that you must hold the lock.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_TimedWaitCondition(TRI_condition_t* cond, uint64_t delay);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief locks the mutex of a condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_LockCondition(TRI_condition_t* cond);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief unlocks the mutex of a condition variable
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_UnlockCondition(TRI_condition_t* cond);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -109,7 +109,7 @@ bool TRI_StartThread(TRI_thread_t* thread, TRI_tid_t* threadId,
|
|||
auto err = pthread_attr_init (&stackSizeAttribute);
|
||||
if (err) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME)
|
||||
<< "could not initialise stack size attribute.";
|
||||
<< "could not initialize stack size attribute.";
|
||||
return false;
|
||||
}
|
||||
err = pthread_attr_getstacksize(&stackSizeAttribute, &stackSize);
|
||||
|
@ -183,14 +183,6 @@ bool TRI_IsSelfThread(TRI_thread_t* thread) {
|
|||
return pthread_self() == *thread;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief allow cancelation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_AllowCancelation() {
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief sets the process affinity
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -160,14 +160,6 @@ bool TRI_IsSelfThread(TRI_thread_t* thread) {
|
|||
return (GetCurrentThreadId() == GetThreadId(thread));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief allow cancelation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_AllowCancelation(void) {
|
||||
// TODO: No native implementation of this
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief sets the process affinity
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -24,51 +24,9 @@
|
|||
#include "tri-strings.h"
|
||||
#include "Basics/conversions.h"
|
||||
#include "Basics/Utf8Helper.h"
|
||||
|
||||
#include <openssl/sha.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief hex values for all characters
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static char const HexValues[513] = {
|
||||
"000102030405060708090a0b0c0d0e0f"
|
||||
"101112131415161718191a1b1c1d1e1f"
|
||||
"202122232425262728292a2b2c2d2e2f"
|
||||
"303132333435363738393a3b3c3d3e3f"
|
||||
"404142434445464748494a4b4c4d4e4f"
|
||||
"505152535455565758595a5b5c5d5e5f"
|
||||
"606162636465666768696a6b6c6d6e6f"
|
||||
"707172737475767778797a7b7c7d7e7f"
|
||||
"808182838485868788898a8b8c8d8e8f"
|
||||
"909192939495969798999a9b9c9d9e9f"
|
||||
"a0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
|
||||
"b0b1b2b3b4b5b6b7b8b9babbbcbdbebf"
|
||||
"c0c1c2c3c4c5c6c7c8c9cacbcccdcecf"
|
||||
"d0d1d2d3d4d5d6d7d8d9dadbdcdddedf"
|
||||
"e0e1e2e3e4e5e6e7e8e9eaebecedeeef"
|
||||
"f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief integer values for all hex characters
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static uint8_t const HexDecodeLookup[256] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // 0123456789
|
||||
0, 0, 0, 0, 0, 0, 0, // :;<=>?@
|
||||
10, 11, 12, 13, 14, 15, // ABCDEF
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // GHIJKLMNOPQRS
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // TUVWXYZ[/]^_`
|
||||
10, 11, 12, 13, 14, 15, // abcdef
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief escapes UTF-8 range U+0000 to U+007F
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -460,14 +418,6 @@ bool TRI_IsPrefixString(char const* full, char const* prefix) {
|
|||
return strncmp(full, prefix, strlen(prefix)) == 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tests if second string is contained in the first
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsContainedString(char const* full, char const* part) {
|
||||
return strstr(full, part) != nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tests if second string is contained in the first, byte-safe
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -74,12 +74,6 @@ bool TRI_CaseEqualString(char const* left, char const* right, size_t n);
|
|||
|
||||
bool TRI_IsPrefixString(char const* full, char const* prefix);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tests if second string is contained in the first
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsContainedString(char const* full, char const* part);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief tests if second string is contained in the first, byte-safe
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
|
||||
namespace arangodb {
|
||||
|
||||
class ExecContext;
|
||||
|
||||
namespace velocypack {
|
||||
class Builder;
|
||||
struct Options;
|
||||
|
@ -83,9 +81,9 @@ class GeneralRequest {
|
|||
_protocol(""),
|
||||
_connectionInfo(connectionInfo),
|
||||
_clientTaskId(0),
|
||||
_authenticated(false),
|
||||
_requestContext(nullptr),
|
||||
_isRequestContextOwner(false),
|
||||
_authenticated(false),
|
||||
_type(RequestType::ILLEGAL),
|
||||
_contentType(ContentType::UNSET),
|
||||
_contentTypeResponse(ContentType::UNSET) {}
|
||||
|
@ -220,12 +218,12 @@ class GeneralRequest {
|
|||
ConnectionInfo _connectionInfo;
|
||||
uint64_t _clientTaskId;
|
||||
std::string _databaseName;
|
||||
bool _authenticated;
|
||||
std::string _user;
|
||||
|
||||
// request context
|
||||
RequestContext* _requestContext;
|
||||
bool _isRequestContextOwner;
|
||||
bool _authenticated;
|
||||
|
||||
rest::AuthenticationMethod _authenticationMethod =
|
||||
rest::AuthenticationMethod::NONE;
|
||||
|
|
|
@ -27,11 +27,8 @@
|
|||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Basics/error.h"
|
||||
#include "Basics/files.h"
|
||||
#include "Basics/hashes.h"
|
||||
#include "Basics/locks.h"
|
||||
#include "Basics/mimetypes.h"
|
||||
#include "Basics/process-utils.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "Random/RandomGenerator.h"
|
||||
#include "Rest/Version.h"
|
||||
|
||||
|
@ -46,7 +43,6 @@ using namespace arangodb::rest;
|
|||
namespace arangodb {
|
||||
namespace rest {
|
||||
void InitializeRest() {
|
||||
TRI_InitializeDebugging();
|
||||
TRI_InitializeError();
|
||||
TRI_InitializeFiles();
|
||||
TRI_InitializeMimetypes();
|
||||
|
@ -72,7 +68,6 @@ void ShutdownRest() {
|
|||
TRI_ShutdownProcess();
|
||||
TRI_ShutdownMimetypes();
|
||||
TRI_ShutdownFiles();
|
||||
TRI_ShutdownDebugging();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include "Basics/FileUtils.h"
|
||||
#include "Basics/Thread.h"
|
||||
#include "Basics/locks.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "ProgramOptions/ProgramOptions.h"
|
||||
#include "ProgramOptions/Section.h"
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "SslServerFeature.h"
|
||||
|
||||
#include "Basics/FileUtils.h"
|
||||
#include "Basics/locks.h"
|
||||
#include "Logger/Logger.h"
|
||||
#include "ProgramOptions/ProgramOptions.h"
|
||||
#include "ProgramOptions/Section.h"
|
||||
|
|
|
@ -534,11 +534,11 @@ class RetainedBufferInfo : public v8::RetainedObjectInfo {
|
|||
explicit RetainedBufferInfo(V8Buffer* buffer);
|
||||
|
||||
public:
|
||||
virtual void Dispose();
|
||||
virtual bool IsEquivalent(RetainedObjectInfo* other);
|
||||
virtual intptr_t GetHash();
|
||||
virtual char const* GetLabel();
|
||||
virtual intptr_t GetSizeInBytes();
|
||||
virtual void Dispose() override;
|
||||
virtual bool IsEquivalent(RetainedObjectInfo* other) override;
|
||||
virtual intptr_t GetHash() override;
|
||||
virtual char const* GetLabel() override;
|
||||
virtual intptr_t GetSizeInBytes() override;
|
||||
|
||||
private:
|
||||
static char const _label[];
|
||||
|
|
Loading…
Reference in New Issue