folly::AtomicHashMap: fixed race between erase() and find()
authorMike Kolupaev <kolmike@fb.com>
Tue, 23 Dec 2014 12:28:32 +0000 (04:28 -0800)
committerDave Watson <davejwatson@fb.com>
Mon, 29 Dec 2014 18:40:12 +0000 (10:40 -0800)
commitb4746252b468b726482d491994d9be8905de13a4
treeaeb99019a02b1994cae96b23b089aa13fdf14dfb
parentcc42e3ad3a3ef875f5353c06b9b4a99202ba445f
folly::AtomicHashMap: fixed race between erase() and find()

Summary: advancePastEmpty() was called for all created iterators. It only makes sense for begin(). For find() it's harmful: find() shouldn't return an iterator to the next element if the key was removed. I suspect that the same race condition was possible for insert(), but I haven't tried to reproduce it.

Test Plan: Added a test for it. It fails without these changes.

Reviewed By: delong.j@fb.com

Subscribers: folly-diffs@, lovro

FB internal diff: D1751280

Tasks: 5841499

Signature: t1:1751280:1419107193:71311ff68d92d0a4dcf1941dacdfdc23c25255cc
folly/AtomicHashArray-inl.h
folly/AtomicHashArray.h
folly/AtomicHashMap-inl.h
folly/AtomicHashMap.h
folly/test/AtomicHashMapTest.cpp