@@ -116,7 +116,7 @@ inline static bool endpointPathFromUrl(std::string const& url,
116
116
Store::Store (Agent* agent, std::string const & name)
117
117
: Thread(name), _agent(agent), _node(name, this ) {}
118
118
119
- // / Move constructor
119
+ // / Move constructor. note: this is not thread-safe!
120
120
Store::Store (Store&& other)
121
121
: Thread(other._node.name()),
122
122
_agent(std::move(other._agent)),
@@ -141,6 +141,7 @@ Store& Store::operator=(Store const& rhs) {
141
141
// / Move assignment operator
142
142
Store& Store::operator =(Store&& rhs) {
143
143
if (&rhs != this ) {
144
+ MUTEX_LOCKER (otherLock, rhs._storeLock );
144
145
_agent = std::move (rhs._agent );
145
146
_timeTable = std::move (rhs._timeTable );
146
147
_observerTable = std::move (rhs._o
8000
bserverTable );
@@ -375,6 +376,8 @@ check_ret_t Store::check(VPackSlice const& slice, CheckMode mode) const {
375
376
check_ret_t ret;
376
377
ret.open ();
377
378
379
+ _storeLock.assertLockedByCurrentThread ();
380
+
378
381
for (auto const & precond : VPackObjectIterator (slice)) { // Preconditions
379
382
380
383
std::string key = precond.key .copyString ();
@@ -671,6 +674,8 @@ bool Store::applies(arangodb::velocypack::Slice const& transaction) {
671
674
672
675
sort (idx.begin (), idx.end (),
673
676
[&abskeys](size_t i1, size_t i2) { return abskeys[i1] < abskeys[i2]; });
677
+
678
+ _storeLock.assertLockedByCurrentThread ();
674
679
675
680
for (const auto & i : idx) {
676
681
std::string const & key = keys.at (i);
@@ -689,6 +694,7 @@ bool Store::applies(arangodb::velocypack::Slice const& transaction) {
689
694
690
695
// Clear my data
691
696
void Store::clear () {
697
+ MUTEX_LOCKER (storeLocker, _storeLock);
692
698
_timeTable.clear ();
693
699
_observerTable.clear ();
694
700
_observedTable.clear ();
@@ -730,30 +736,42 @@ Store& Store::operator=(VPackSlice const& slice) {
730
736
731
737
// / Put key value store in velocypack, guarded by caller
732
738
void Store::toBuilder (Builder& b, bool showHidden) const {
739
+ _storeLock.assertLockedByCurrentThread ();
733
740
_node.toBuilder (b, showHidden); }
734
741
735
742
// / Time table
736
- std::multimap<TimePoint, std::string>& Store::timeTable () { return _timeTable; }
743
+ std::multimap<TimePoint, std::string>& Store::timeTable () {
744
+ _storeLock.assertLockedByCurrentThread ();
745
+ return _timeTable;
746
+ }
747
+
737
748
// / Time table
738
- const std::multimap<TimePoint, std::string>& Store::timeTable () const {
749
+ std::multimap<TimePoint, std::string> const & Store::timeTable () const {
750
+ _storeLock.assertLockedByCurrentThread ();
739
751
return _timeTable;
740
752
}
741
753
742
754
// / Observer table
743
755
std::multimap<std::string, std::string>& Store::observerTable () {
756
+ _storeLock.assertLockedByCurrentThread ();
744
757
return _observerTable;
745
758
}
759
+
746
760
// / Observer table
747
761
std::multimap<std::string, std::string> const & Store::observerTable () const {
762
+ _storeLock.assertLockedByCurrentThread ();
748
763
return _observerTable;
749
764
}
750
765
751
766
// / Observed table
752
767
std::multimap<std::string, std::string>& Store::observedTable () {
768
+ _storeLock.assertLockedByCurrentThread ();
753
769
return _observedTable;
754
770
}
771
+
755
772
// / Observed table
756
773
std::multimap<std::string, std::string> const & Store::observedTable () const {
774
+ _storeLock.assertLockedByCurrentThread ();
757
775
return _observedTable;
758
776
}
759
777
@@ -771,6 +789,8 @@ bool Store::has(std::string const& path) const {
771
789
772
790
// / Remove ttl entry for path, guarded by caller
773
791
void Store::removeTTL (std::string const & uri) {
792
+ _storeLock.assertLockedByCurrentThread ();
793
+
774
794
if (!_timeTable.empty ()) {
775
795
for (auto it = _timeTable.cbegin (); it != _timeTable.cend ();) {
776
796
if (it->second == uri) {
0 commit comments