Fix ThreadCachedInt race condition
authorDan Schatzberg <dschatzberg@fb.com>
Mon, 29 Aug 2016 23:42:44 +0000 (16:42 -0700)
committerFacebook Github Bot 4 <facebook-github-bot-4-bot@fb.com>
Mon, 29 Aug 2016 23:53:29 +0000 (16:53 -0700)
commitbae33d680bbba07b74d9bf9b2ba99766ebb3795e
tree4fd80e57be37a58b7292b127df004a4a46d155de
parentc93226d1035504e84e4015593dd8449503c02a2e
Fix ThreadCachedInt race condition

Summary:
Move ThreadLocal object destruction to occur under the lock to avoid races.
This causes a few cascading changes - the Tag lock needs to be a recursive_mutex so
constructing a new object while destroying another st. Also, forking requires
a new mutex to avoid deadlocking on accessing a recursive_mutex across a fork()

Reviewed By: andriigrynenko

Differential Revision: D3755446

fbshipit-source-id: bb4c4f29bab98d763490df29b460066f124303e0
folly/ThreadCachedInt.h
folly/ThreadLocal.h
folly/detail/ThreadLocalDetail.cpp
folly/detail/ThreadLocalDetail.h
folly/test/ThreadCachedIntTest.cpp