From 581f790c8475d87f95800e865e92bbf6c297e59e Mon Sep 17 00:00:00 2001 From: Sean Cannella Date: Thu, 16 Oct 2014 12:16:41 -0700 Subject: [PATCH] Fix one missing conditional for Android Summary: pthread_atfork isn't defined in the Android NDK (and therefore is not actually supported even though it's in bionic/libc) so don't call it there. Test Plan: compiled on Linux, Android Reviewed By: meyering@fb.com Subscribers: njormrod, shikong, kmdent, fma FB internal diff: D1620584 Tasks: 5183325 --- folly/detail/ThreadLocalDetail.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/folly/detail/ThreadLocalDetail.h b/folly/detail/ThreadLocalDetail.h index 55985ad3..efaadc57 100644 --- a/folly/detail/ThreadLocalDetail.h +++ b/folly/detail/ThreadLocalDetail.h @@ -193,10 +193,15 @@ struct StaticMeta { int ret = pthread_key_create(&pthreadKey_, &onThreadExit); checkPosixError(ret, "pthread_key_create failed"); + // pthread_atfork is not part of the Android NDK at least as of n9d. If + // something is trying to call native fork() directly at all with Android's + // process management model, this is probably the least of the problems. +#if !__ANDROID__ ret = pthread_atfork(/*prepare*/ &StaticMeta::preFork, /*parent*/ &StaticMeta::onForkParent, /*child*/ &StaticMeta::onForkChild); checkPosixError(ret, "pthread_atfork failed"); +#endif } ~StaticMeta() { LOG(FATAL) << "StaticMeta lives forever!"; -- 2.34.1