Commit b0005c7d authored by Ben Maurer's avatar Ben Maurer Committed by facebook-github-bot-4

Fix ThreadLocal on android/apple

Summary: The thread local destructor was assuming that the singleton object
had been created.

Reviewed By: @​yangchi

Differential Revision: D2536166

fb-gh-sync-id: b0c08e0990f684c0afae054ee17c62a924260f2b
parent cef57896
......@@ -275,11 +275,12 @@ struct StaticMeta {
#ifdef FOLLY_TLD_USE_FOLLY_TLS
return &threadEntry_;
#else
auto key = instance().pthreadKey_;
ThreadEntry* threadEntry =
static_cast<ThreadEntry*>(pthread_getspecific(inst_->pthreadKey_));
static_cast<ThreadEntry*>(pthread_getspecific(key));
if (!threadEntry) {
threadEntry = new ThreadEntry();
int ret = pthread_setspecific(inst_->pthreadKey_, threadEntry);
int ret = pthread_setspecific(key, threadEntry);
checkPosixError(ret, "pthread_setspecific failed");
}
return threadEntry;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment