From: Sean Cannella Date: Thu, 16 Oct 2014 19:16:41 +0000 (-0700) Subject: Fix one missing conditional for Android X-Git-Tag: v0.22.0~265 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=581f790c8475d87f95800e865e92bbf6c297e59e;p=folly.git 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 --- 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!";