From c51e144678a71993caf176355938dfe564d6ada2 Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Fri, 28 Apr 2017 11:57:20 +0200 Subject: [PATCH] ASAN runtime errors --- lib/Basics/DataProtector.cpp | 17 +++++++++++++++++ lib/Basics/DataProtector.h | 17 +---------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/Basics/DataProtector.cpp b/lib/Basics/DataProtector.cpp index a9daedaa7e..d57567d4f7 100644 --- a/lib/Basics/DataProtector.cpp +++ b/lib/Basics/DataProtector.cpp @@ -39,3 +39,20 @@ std::atomic arangodb::basics::DataProtector::_last(0); // TODO: Reactivate this template instantiation once everybody has gcc >= 4.9.2 // template class arangodb::basics::DataProtector<64>; + +int arangodb::basics::DataProtector::getMyId() { + int id = _mySlot; + if (id >= 0) { + return id; + } + while (true) { + int newId = _last + 1; + if (newId >= DATA_PROTECTOR_MULTIPLICITY) { + newId = 0; + } + if (_last.compare_exchange_strong(id, newId)) { + _mySlot = newId; + return newId; + } + } +} diff --git a/lib/Basics/DataProtector.h b/lib/Basics/DataProtector.h index 86c02dc7e0..bf240e0caa 100644 --- a/lib/Basics/DataProtector.h +++ b/lib/Basics/DataProtector.h @@ -146,22 +146,7 @@ class DataProtector { _list[id]._count--; // this is implicitly using memory_order_seq_cst } - int getMyId() { - int id = _mySlot; - if (id >= 0) { - return id; - } - while (true) { - int newId = _last + 1; - if (newId >= DATA_PROTECTOR_MULTIPLICITY) { - newId = 0; - } - if (_last.compare_exchange_strong(id, newId)) { - _mySlot = newId; - return newId; - } - } - } + int getMyId(); }; } // namespace arangodb::basics