Skip to content

Commit 5aba40d

Browse files
committed
Address lock-order-inversion warning from TSAN.
1 parent 573ab84 commit 5aba40d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

hnswlib/hnswalg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,14 +1099,15 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
10991099
label_lookup_[label] = cur_c;
11001100
}
11011101

1102+
std::unique_lock <std::mutex> templock(global);
1103+
11021104
std::unique_lock <std::mutex> lock_el(link_list_locks_[cur_c]);
11031105
int curlevel = getRandomLevel(mult_);
11041106
if (level > 0)
11051107
curlevel = level;
11061108

11071109
element_levels_[cur_c] = curlevel;
11081110

1109-
std::unique_lock <std::mutex> templock(global);
11101111
int maxlevelcopy = maxlevel_;
11111112
if (curlevel <= maxlevelcopy)
11121113
templock.unlock();

0 commit comments

Comments
 (0)