Fix ThreadLocal races
authorDave Watson <davejwatson@fb.com>
Tue, 19 Dec 2017 21:17:28 +0000 (13:17 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 19 Dec 2017 21:24:46 +0000 (13:24 -0800)
commit74502e3cc02daef719f6255cc55a7bebe0772a26
treeb926ad1de6c663af731168b8ec34f768fc359afb
parent58399f25e774f06b3048eb7cde4302b917848d19
Fix ThreadLocal races

Summary:
I misread the ThreadLocal docs, thread destruction functions do *not* grab the accessAllTHreads_ lock
unless you use *strict* mode, and even then, it is only a read lock.

Easy enough to make the thread-destruction global bits to be atomic / use folly::Synchronized.

Reviewed By: yfeldblum

Differential Revision: D6592905

fbshipit-source-id: 4ae600dff4c8c04751483a452ca7c07ef3f26380
folly/synchronization/detail/ThreadCachedInts.h
folly/synchronization/detail/ThreadCachedLists.h
folly/synchronization/test/RcuTest.cpp