From 2d7e477a6c9401e04e7c91e708d5498c1e604f13 Mon Sep 17 00:00:00 2001 From: Moiz Haidry Date: Tue, 1 Oct 2019 14:12:01 -0700 Subject: [PATCH] Clear the thread state before shutdown on executor, make exception for MacOS and iOS --- src/core/lib/iomgr/executor.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index c855d1535a9..87e9f6cf507 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -264,6 +264,15 @@ void Executor::ThreadMain(void* arg) { grpc_core::ExecCtx::Get()->InvalidateNow(); subtract_depth = RunClosures(ts->name, closures); } + + // We have an issue with Apple platforms where applying gpr_tls_set here + // leads to an EAGAIN error while performing a gpr_tls_get, so we are + // skipping this cleanup for Apple platforms. See PR #19978 + // TODO(mhaidry) : Fix this by switching to using thread_local once we have + // support for it in Xcode (PR #20413)or whatever else it takes +#if !defined(__APPLE__) + gpr_tls_set(&g_this_thread_state, reinterpret_cast(nullptr)); +#endif // !__APPLE__ } void Executor::Enqueue(grpc_closure* closure, grpc_error* error,