1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
Jan Steemann 2016-01-27 18:53:29 +01:00
commit 37a083edca
45 changed files with 141 additions and 115 deletions

View File

@ -74,7 +74,7 @@ class RestActionHandler : public RestVocbaseBaseHandler {
/// @brief data lock
//////////////////////////////////////////////////////////////////////////////
basics::Mutex _dataLock;
Mutex _dataLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief data for cancelation

View File

@ -76,10 +76,10 @@ class TRI_action_t {
virtual TRI_action_result_t execute(TRI_vocbase_t*,
arangodb::rest::HttpRequest*,
arangodb::basics::Mutex* dataLock,
arangodb::Mutex* dataLock,
void** data) = 0;
virtual bool cancel(arangodb::basics::Mutex* dataLock, void** data) = 0;
virtual bool cancel(arangodb::Mutex* dataLock, void** data) = 0;
std::string _type;
std::string _url;

View File

@ -28,7 +28,7 @@
using namespace arangodb::aql;
arangodb::basics::Mutex Optimizer::SetupLock;
arangodb::Mutex Optimizer::SetupLock;
////////////////////////////////////////////////////////////////////////////////
// @brief list of all rules

View File

@ -609,7 +609,7 @@ class Optimizer {
/// @brief mutex to protect rule setup
//////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex SetupLock;
static arangodb::Mutex SetupLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief the current set of plans to be optimized

View File

@ -360,7 +360,7 @@ class QueryCache {
/// @brief protect mode changes with a mutex
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _propertiesLock;
arangodb::Mutex _propertiesLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief read-write lock for the cache

View File

@ -162,15 +162,7 @@ typedef void* yyscan_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k.
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
* Ditto for the __ia64__ case accordingly.
*/
#define YY_BUF_SIZE 32768
#else
#define YY_BUF_SIZE 16384
#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@ -853,12 +845,7 @@ static int input (yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
#ifdef __ia64__
/* On IA-64, the buffer size is 16k, not 8k */
#define YY_READ_BUF_SIZE 16384
#else
#define YY_READ_BUF_SIZE 8192
#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */

View File

@ -886,7 +886,7 @@ class ClusterInfo {
struct ProtectionData {
std::atomic<bool> isValid;
arangodb::basics::Mutex mutex;
arangodb::Mutex mutex;
std::atomic<uint64_t> version;
arangodb::basics::ReadWriteLock lock;
@ -962,7 +962,7 @@ class ClusterInfo {
/// @brief lock for uniqid sequence
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _idLock;
arangodb::Mutex _idLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief the sole instance

View File

@ -197,7 +197,7 @@ class HeartbeatThread : public basics::Thread {
/// @brief status lock
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _statusLock;
arangodb::Mutex _statusLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief AgencyComm instance

View File

@ -36,7 +36,7 @@
using namespace arangodb;
using namespace arangodb::rest;
static arangodb::basics::Mutex ExecutorLock;
static arangodb::Mutex ExecutorLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief constructs a new db server job

View File

@ -122,7 +122,7 @@ class ServerJob : public arangodb::rest::Job {
/// @brief server is dead lock
//////////////////////////////////////////////////////////////////////////////
basics::Mutex _abandonLock;
Mutex _abandonLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief server is dead

View File

@ -189,7 +189,7 @@ class DispatcherQueue {
/// @brief guard for hazard pointer
//////////////////////////////////////////////////////////////////////////////
basics::Mutex _hazardLock;
Mutex _hazardLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief hazard pointer for jobs
@ -207,7 +207,7 @@ class DispatcherQueue {
/// @brief guard for _startedThreads
//////////////////////////////////////////////////////////////////////////////
basics::Mutex _threadsLock;
Mutex _threadsLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief list of started threads

View File

@ -244,7 +244,7 @@ class HttpServer : protected TaskManager {
/// @brief mutex for comm tasks
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _commTasksLock;
arangodb::Mutex _commTasksLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief active comm tasks

View File

@ -150,7 +150,7 @@ class RestCursorHandler : public RestVocbaseBaseHandler {
/// @brief lock for currently running query
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _queryLock;
Mutex _queryLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief currently running query

View File

@ -106,7 +106,7 @@ class RestSimpleHandler : public RestVocbaseBaseHandler {
/// @brief lock for currently running query
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _queryLock;
Mutex _queryLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief currently running query

View File

@ -59,7 +59,7 @@ class ConsoleThread : public basics::Thread {
/// @brief mutex for console access
//////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex serverConsoleMutex;
static arangodb::Mutex serverConsoleMutex;
public:
ConsoleThread(arangodb::rest::ApplicationServer*, ApplicationV8*,

View File

@ -39,7 +39,7 @@ using namespace arangodb::rest;
/// @brief sid lock
////////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex SidLock;
static arangodb::Mutex SidLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief sid cache

View File

@ -126,7 +126,7 @@ class ListenTask : virtual public Task {
size_t _acceptFailures;
mutable basics::Mutex _changeLock;
mutable Mutex _changeLock;
};
}
}

View File

@ -358,7 +358,7 @@ class Scheduler : private TaskManager {
/// @brief lock for scheduler threads
//////////////////////////////////////////////////////////////////////////////
basics::Mutex schedulerLock;
Mutex schedulerLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief tasks to thread

View File

@ -159,7 +159,7 @@ class SchedulerThread : public basics::Thread, private TaskManager {
/// @brief queue lock
////////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _queueLock;
Mutex _queueLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief work queue

View File

@ -96,7 +96,7 @@ class SignalTask : virtual public Task {
private:
std::set<int> _signals;
basics::Mutex _changeLock;
Mutex _changeLock;
};
}
}

View File

@ -37,7 +37,7 @@ static size_t const QUEUE_SIZE = 1000;
/// @brief lock for request statistics data
////////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex RequestDataLock;
static arangodb::Mutex RequestDataLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief the request statistics queue
@ -196,7 +196,7 @@ void TRI_FillRequestStatistics(StatisticsDistribution& totalTime,
/// @brief lock for connection data
////////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex ConnectionDataLock;
static arangodb::Mutex ConnectionDataLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief free list

View File

@ -93,7 +93,7 @@ class CollectionKeysRepository {
/// @brief mutex for the repository
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _lock;
Mutex _lock;
//////////////////////////////////////////////////////////////////////////////
/// @brief list of current keys

View File

@ -111,7 +111,7 @@ class CursorRepository {
/// @brief mutex for the cursors repository
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _lock;
Mutex _lock;
//////////////////////////////////////////////////////////////////////////////
/// @brief list of current cursors

View File

@ -229,7 +229,7 @@ class ApplicationV8 : public rest::ApplicationFeature {
/// @brief mutex to protect _globalMethods
////////////////////////////////////////////////////////////////////////////////
basics::Mutex _globalMethodsLock;
Mutex _globalMethodsLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief open global methods

View File

@ -421,7 +421,7 @@ class Ditches {
private:
struct TRI_document_collection_t* _collection;
arangodb::basics::Mutex _lock;
arangodb::Mutex _lock;
Ditch* _begin;
Ditch* _end;
uint64_t _numDocumentDitches;

View File

@ -244,7 +244,7 @@ class AutoIncrementKeyGenerator : public KeyGenerator {
virtual void toVelocyPack(arangodb::velocypack::Builder&) const override;
private:
arangodb::basics::Mutex _lock;
arangodb::Mutex _lock;
uint64_t _lastValue; // last value assigned

View File

@ -154,7 +154,7 @@ class VocShaper : public Shaper {
TRI_document_collection_t* _collection;
// attribute paths
arangodb::basics::Mutex _attributePathsCreateLock;
arangodb::Mutex _attributePathsCreateLock;
arangodb::basics::ReadWriteLock _attributePathsByNameLock;
TRI_associative_pointer_t _attributePathsByName;
@ -163,7 +163,7 @@ class VocShaper : public Shaper {
TRI_associative_pointer_t _attributePathsByPid;
// attributes
arangodb::basics::Mutex _attributeCreateLock;
arangodb::Mutex _attributeCreateLock;
arangodb::basics::ReadWriteLock _attributeNamesLock;
TRI_associative_pointer_t _attributeNames;
@ -172,7 +172,7 @@ class VocShaper : public Shaper {
TRI_associative_pointer_t _attributeIds;
// shapes
arangodb::basics::Mutex _shapeCreateLock;
arangodb::Mutex _shapeCreateLock;
arangodb::basics::ReadWriteLock _shapeDictionaryLock;
TRI_associative_pointer_t _shapeDictionary;

View File

@ -248,7 +248,7 @@ struct TRI_document_collection_t : public TRI_collection_t {
private:
VocShaper* _shaper;
arangodb::basics::Mutex _compactionStatusLock;
arangodb::Mutex _compactionStatusLock;
size_t _nextCompactionStartIndex;
char const* _lastCompactionStatus;
char _lastCompactionStamp[21];

View File

@ -74,7 +74,7 @@ size_t PageSize;
/// @brief lock for serializing the creation of database
////////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex DatabaseCreateLock;
static arangodb::Mutex DatabaseCreateLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief variable protecting the server shutdown

View File

@ -65,7 +65,7 @@ struct TRI_server_t {
// TODO: Make this again a template once everybody has gcc >= 4.9.2
// arangodb::basics::DataProtector<64>
arangodb::basics::DataProtector _databasesProtector;
arangodb::basics::Mutex _databasesMutex;
arangodb::Mutex _databasesMutex;
TRI_thread_t _databaseManager;

View File

@ -360,7 +360,7 @@ class CollectorThread : public basics::Thread {
/// @brief operations lock
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _operationsQueueLock;
arangodb::Mutex _operationsQueueLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief operations to collect later

View File

@ -886,7 +886,7 @@ class LogfileManager : public rest::ApplicationFeature {
/// @brief a lock protecting the shutdown file
//////////////////////////////////////////////////////////////////////////////
basics::Mutex _shutdownFileLock;
Mutex _shutdownFileLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief a lock protecting _transactions and _failedTransactions
@ -926,7 +926,7 @@ class LogfileManager : public rest::ApplicationFeature {
/// and _lastOpenedId
//////////////////////////////////////////////////////////////////////////////
basics::Mutex _idLock;
Mutex _idLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief whether or not write-throttling is currently enabled

View File

@ -208,7 +208,7 @@ class Slots {
/// @brief mutex protecting the slots interface
//////////////////////////////////////////////////////////////////////////////
basics::Mutex _lock;
Mutex _lock;
//////////////////////////////////////////////////////////////////////////////
/// @brief all slots

View File

@ -146,7 +146,7 @@ class BenchmarkCounter {
/// @brief mutex protecting the counter
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _mutex;
arangodb::Mutex _mutex;
//////////////////////////////////////////////////////////////////////////////
/// @brief the current value

View File

@ -387,7 +387,7 @@ class AssocMulti {
typedef std::vector<std::pair<Element*, uint64_t>> DocumentsPerBucket;
arangodb::basics::Mutex bucketMapLocker;
arangodb::Mutex bucketMapLocker;
std::unordered_map<uint64_t, std::vector<DocumentsPerBucket>> allBuckets;

View File

@ -595,7 +595,7 @@ class AssocUnique {
size_t const chunkSize = elements.size() / numThreads;
typedef std::vector<std::pair<Element*, uint64_t>> DocumentsPerBucket;
arangodb::basics::Mutex bucketMapLocker;
arangodb::Mutex bucketMapLocker;
std::unordered_map<uint64_t, std::vector<DocumentsPerBucket>> allBuckets;

View File

@ -152,7 +152,7 @@ class DeadlockDetector {
/// @brief lock for managing the readers
//////////////////////////////////////////////////////////////////////////////
arangodb::basics::Mutex _readersLock;
arangodb::Mutex _readersLock;
//////////////////////////////////////////////////////////////////////////////
/// @brief readers that are blocked on writers

View File

@ -24,28 +24,85 @@
#include "Mutex.h"
using namespace arangodb::basics;
#include "Basics/logging.h"
using namespace arangodb;
////////////////////////////////////////////////////////////////////////////////
/// @brief constructs a mutex
////////////////////////////////////////////////////////////////////////////////
Mutex::Mutex() : _mutex() { TRI_InitMutex(&_mutex); }
#ifdef TRI_HAVE_POSIX_THREADS
Mutex::Mutex() : _mutex() { pthread_mutex_init(&_mutex, nullptr); }
#endif
#ifdef TRI_HAVE_WIN32_THREADS
Mutex::Mutex() : _mutex() { InitializeSRWLock(&_mutex); }
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief deletes the mutex
////////////////////////////////////////////////////////////////////////////////
Mutex::~Mutex() { TRI_DestroyMutex(&_mutex); }
#ifdef TRI_HAVE_POSIX_THREADS
Mutex::~Mutex() { pthread_mutex_destroy(&_mutex); }
#endif
#ifdef TRI_HAVE_WIN32_THREADS
Mutex::~Mutex() {}
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief acquires the lock
////////////////////////////////////////////////////////////////////////////////
void Mutex::lock() { TRI_LockMutex(&_mutex); }
#ifdef TRI_HAVE_POSIX_THREADS
void Mutex::lock() {
int rc = pthread_mutex_lock(&_mutex);
if (rc != 0) {
if (rc == EDEADLK) {
LOG_ERROR("mutex deadlock detected");
}
LOG_FATAL_AND_EXIT("could not lock the mutex: %s", strerror(rc));
}
}
#endif
#ifdef TRI_HAVE_WIN32_THREADS
void Mutex::lock() { AcquireSRWLockExclusive(&_mutex); }
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief releases the lock
////////////////////////////////////////////////////////////////////////////////
void Mutex::unlock() { TRI_UnlockMutex(&_mutex); }
#ifdef TRI_HAVE_POSIX_THREADS
void Mutex::unlock() {
int rc = pthread_mutex_unlock(&_mutex);
if (rc != 0) {
LOG_FATAL_AND_EXIT("could not release the mutex: %s", strerror(rc));
}
}
#endif
#ifdef TRI_HAVE_WIN32_THREADS
void Mutex::unlock() { ReleaseSRWLockExclusive(&_mutex); }
#endif

View File

@ -26,10 +26,8 @@
#define LIB_BASICS_MUTEX_H 1
#include "Basics/Common.h"
#include "Basics/locks.h"
namespace arangodb {
namespace basics {
////////////////////////////////////////////////////////////////////////////////
/// @brief mutex
@ -67,13 +65,24 @@ class Mutex {
void unlock();
private:
#ifdef TRI_HAVE_POSIX_THREADS
//////////////////////////////////////////////////////////////////////////////
/// @brief mutex variable
/// @brief pthread mutex
//////////////////////////////////////////////////////////////////////////////
TRI_mutex_t _mutex;
pthread_mutex_t _mutex;
#endif
#ifdef TRI_HAVE_WIN32_THREADS
//////////////////////////////////////////////////////////////////////////////
/// @brief SRWLocks
///
/// as of VS2013, exclusive SRWLocks tend to be faster than native mutexes
//////////////////////////////////////////////////////////////////////////////
SRWLOCK _mutex;
#endif
};
}
}
#endif

View File

@ -28,6 +28,7 @@
#include "Basics/logging.h"
#endif
using namespace arangodb;
using namespace arangodb::basics;
////////////////////////////////////////////////////////////////////////////////

View File

@ -32,12 +32,9 @@
#include "Basics/StringUtils.h"
using namespace std;
using namespace arangodb;
using namespace arangodb::basics;
// -----------------------------------------------------------------------------
// statistic nonce buffer
// -----------------------------------------------------------------------------
namespace {
Mutex MutexNonce;
@ -45,48 +42,21 @@ size_t SizeNonces = 16777216;
uint32_t* TimestampNonces = 0;
uint32_t StatisticsNonces[32][5] = {{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, 0, 0},
{0, 0, 0, 0, 0}};
uint32_t StatisticsNonces[32][5] = {
{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, 0, 0}, {0, 0, 0, 0, 0}};
}
namespace arangodb {
namespace basics {
namespace Nonce {
// -----------------------------------------------------------------------------
// static functions
// -----------------------------------------------------------------------------
void create(size_t size) {
if (SizeNonces < 64) {
SizeNonces = 64;

View File

@ -33,6 +33,7 @@
#include <chrono>
using namespace std;
using namespace arangodb;
using namespace arangodb::basics;
// -----------------------------------------------------------------------------

View File

@ -35,12 +35,13 @@
#endif
#include "Basics/Exceptions.h"
#include "Basics/files.h"
#include "Basics/hashes.h"
#include "Basics/Mutex.h"
#include "Basics/MutexLocker.h"
#include "Basics/shell-colors.h"
#include "Basics/Thread.h"
#include "Basics/files.h"
#include "Basics/hashes.h"
#include "Basics/locks.h"
#include "Basics/shell-colors.h"
#include "Basics/tri-strings.h"
#include "Basics/vector.h"
@ -173,7 +174,7 @@ static std::vector<TRI_log_appender_t*> Appenders;
/// @brief log appenders
////////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex AppendersLock;
static arangodb::Mutex AppendersLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief maximal output length
@ -215,7 +216,7 @@ static TRI_log_buffer_t BufferOutput[OUTPUT_LOG_LEVELS][OUTPUT_BUFFER_SIZE];
/// @brief buffer lock
////////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex BufferLock;
static arangodb::Mutex BufferLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief condition variable for the logger
@ -227,7 +228,7 @@ static TRI_condition_t LogCondition;
/// @brief message queue lock
////////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex LogMessageQueueLock;
static arangodb::Mutex LogMessageQueueLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief message queue
@ -1496,7 +1497,7 @@ struct log_appender_syslog_t : public TRI_log_appender_t {
char const* typeName() override final { return "syslog"; }
private:
arangodb::basics::Mutex _lock;
arangodb::Mutex _lock;
bool _opened;
};

View File

@ -183,7 +183,7 @@ static std::vector<TRI_external_t*> ExternalProcesses;
/// @brief lock for protected access to vector ExternalProcesses
////////////////////////////////////////////////////////////////////////////////
static arangodb::basics::Mutex ExternalProcessesLock;
static arangodb::Mutex ExternalProcessesLock;
////////////////////////////////////////////////////////////////////////////////
/// @brief creates pipe pair

View File

@ -98,7 +98,7 @@ class ScriptLoader {
/// @brief mutex for _scripts
//////////////////////////////////////////////////////////////////////////////
basics::Mutex _lock;
Mutex _lock;
};
}