aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-11-28 18:06:23 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2017-11-28 18:06:23 -0800
commit03412ee9de902e378bc4cea933397ebe5faddc29 (patch)
tree8976a958d4c9855481425452e578ab4a4e315ad0 /src/core
parent81fc8c9c336fab7a71b448f748a32d680301277c (diff)
Remove TLS_NO_SUPPORT and always use GPR_TLS. Reorder statements in grpc_init and grpc_shutdown. Add grpc_init and grpc_shutdown in failing test/cpp tests
Diffstat (limited to 'src/core')
-rw-r--r--src/core/lib/iomgr/exec_ctx.cc6
-rw-r--r--src/core/lib/iomgr/exec_ctx.h18
-rw-r--r--src/core/lib/iomgr/iomgr.cc13
-rw-r--r--src/core/lib/surface/init.cc10
4 files changed, 11 insertions, 36 deletions
diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc
index f4247db754..e005437e0a 100644
--- a/src/core/lib/iomgr/exec_ctx.cc
+++ b/src/core/lib/iomgr/exec_ctx.cc
@@ -104,17 +104,11 @@ static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable};
grpc_closure_scheduler* grpc_schedule_on_exec_ctx = &exec_ctx_scheduler;
namespace grpc_core {
-#ifdef TLS_NO_SUPPORT
GPR_TLS_CLASS_DEF(ExecCtx::exec_ctx_);
-#else
-thread_local ExecCtx* ExecCtx::exec_ctx_ = nullptr;
-#endif
void ExecCtx::GlobalInit(void) {
g_start_time = gpr_now(GPR_CLOCK_MONOTONIC);
-#ifdef TLS_NO_SUPPORT
gpr_tls_init(&exec_ctx_);
-#endif
}
bool ExecCtx::Flush() {
diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h
index b04aab61fa..c8700f3352 100644
--- a/src/core/lib/iomgr/exec_ctx.h
+++ b/src/core/lib/iomgr/exec_ctx.h
@@ -170,19 +170,11 @@ on outside context */
static void GlobalInit(void);
/** Global shutdown for ExecCtx. Called by iomgr */
- static void GlobalShutdown(void) {
-#ifdef TLS_NO_SUPPORT
- gpr_tls_destroy(&exec_ctx_);
-#endif
- }
+ static void GlobalShutdown(void) { gpr_tls_destroy(&exec_ctx_); }
/** Gets pointer to current exec_ctx */
static ExecCtx* Get() {
-#ifdef TLS_NO_SUPPORT
return reinterpret_cast<ExecCtx*>(gpr_tls_get(&exec_ctx_));
-#else
- return exec_ctx_;
-#endif
}
protected:
@@ -192,11 +184,7 @@ on outside context */
private:
/** Set exec_ctx_ to exec_ctx */
void Set(ExecCtx* exec_ctx) {
-#ifdef TLS_NO_SUPPORT
gpr_tls_set(&exec_ctx_, reinterpret_cast<intptr_t>(exec_ctx));
-#else
- exec_ctx_ = exec_ctx;
-#endif
}
grpc_closure_list closure_list_ = GRPC_CLOSURE_LIST_INIT;
@@ -207,11 +195,7 @@ on outside context */
bool now_is_valid_ = false;
grpc_millis now_ = 0;
-#ifdef TLS_NO_SUPPORT
GPR_TLS_CLASS_DECL(exec_ctx_);
-#else
- static thread_local ExecCtx* exec_ctx_;
-#endif
ExecCtx* last_exec_ctx_ = Get();
};
} // namespace grpc_core
diff --git a/src/core/lib/iomgr/iomgr.cc b/src/core/lib/iomgr/iomgr.cc
index 570d97443d..27e9376272 100644
--- a/src/core/lib/iomgr/iomgr.cc
+++ b/src/core/lib/iomgr/iomgr.cc
@@ -46,15 +46,12 @@ static int g_shutdown;
static grpc_iomgr_object g_root_object;
void grpc_iomgr_init() {
+ grpc_core::ExecCtx _local_exec_ctx;
g_shutdown = 0;
gpr_mu_init(&g_mu);
gpr_cv_init(&g_rcv);
- grpc_core::ExecCtx::GlobalInit();
- {
- grpc_core::ExecCtx _local_exec_ctx;
- grpc_executor_init();
- grpc_timer_list_init();
- }
+ grpc_executor_init();
+ grpc_timer_list_init();
g_root_object.next = g_root_object.prev = &g_root_object;
g_root_object.name = (char*)"root";
grpc_network_status_init();
@@ -85,7 +82,6 @@ void grpc_iomgr_shutdown() {
gpr_timespec last_warning_time = gpr_now(GPR_CLOCK_REALTIME);
{
- grpc_core::ExecCtx _local_exec_ctx(0);
grpc_timer_manager_shutdown();
grpc_iomgr_platform_flush();
grpc_executor_shutdown();
@@ -141,8 +137,8 @@ void grpc_iomgr_shutdown() {
}
}
gpr_mu_unlock(&g_mu);
-
grpc_timer_list_shutdown();
+ grpc_core::ExecCtx::Get()->Flush();
}
/* ensure all threads have left g_mu */
@@ -150,7 +146,6 @@ void grpc_iomgr_shutdown() {
gpr_mu_unlock(&g_mu);
grpc_iomgr_platform_shutdown();
- grpc_core::ExecCtx::GlobalShutdown();
grpc_network_status_shutdown();
gpr_mu_destroy(&g_mu);
gpr_cv_destroy(&g_rcv);
diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc
index 2d7a33e147..e6ff475a90 100644
--- a/src/core/lib/surface/init.cc
+++ b/src/core/lib/surface/init.cc
@@ -124,6 +124,7 @@ void grpc_init(void) {
grpc_mdctx_global_init();
grpc_channel_init_init();
grpc_security_pre_init();
+ grpc_core::ExecCtx::GlobalInit();
grpc_iomgr_init();
gpr_timers_global_init();
grpc_handshaker_factory_registry_init();
@@ -156,8 +157,8 @@ void grpc_shutdown(void) {
gpr_mu_lock(&g_init_mu);
if (--g_initializations == 0) {
{
+ grpc_core::ExecCtx _local_exec_ctx(0);
{
- grpc_core::ExecCtx _local_exec_ctx(0);
grpc_executor_shutdown();
grpc_timer_manager_set_threading(
false); // shutdown timer_manager thread
@@ -166,15 +167,16 @@ void grpc_shutdown(void) {
g_all_of_the_plugins[i].destroy();
}
}
- grpc_mdctx_global_shutdown();
- grpc_handshaker_factory_registry_shutdown();
}
- grpc_iomgr_shutdown();
gpr_timers_global_destroy();
grpc_tracer_shutdown();
+ grpc_handshaker_factory_registry_shutdown();
+ grpc_iomgr_shutdown();
+ grpc_mdctx_global_shutdown();
grpc_slice_intern_shutdown();
grpc_stats_shutdown();
}
+ grpc_core::ExecCtx::GlobalShutdown();
}
gpr_mu_unlock(&g_init_mu);
}