Skip to content

Commit 1fc2348

Browse files
committed
More fix
1 parent 851393c commit 1fc2348

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/core/lib/iomgr/exec_ctx.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ static void exec_ctx_sched(grpc_closure* closure) {
5353

5454
namespace grpc_core {
5555

56-
thread_local ExecCtx* ExecCtx::exec_ctx_;
57-
thread_local ApplicationCallbackExecCtx*
58-
ApplicationCallbackExecCtx::callback_exec_ctx_;
56+
ExecCtx** ExecCtx::GetExecCtx() {
57+
static thread_local ExecCtx* exec_ctx = nullptr;
58+
return &exec_ctx;
59+
}
60+
61+
ApplicationCallbackExecCtx** ApplicationCallbackExecCtx::GetCallbackExecCtx() {
62+
static thread_local ApplicationCallbackExecCtx* callback_exec_ctx = nullptr;
63+
return &callback_exec_ctx;
64+
}
5965

6066
bool ExecCtx::Flush() {
6167
bool did_something = false;

src/core/lib/iomgr/exec_ctx.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,7 @@ class ExecCtx {
210210
unsigned starting_cpu_ = std::numeric_limits<unsigned>::max();
211211

212212
ScopedTimeCache time_cache_;
213-
214-
static ExecCtx** GetExecCtx() {
215-
static thread_local ExecCtx* exec_ctx = nullptr;
216-
return &exec_ctx;
217-
}
213+
static ExecCtx** GetExecCtx();
218214

219215
ExecCtx* last_exec_ctx_ = Get();
220216
};
@@ -286,7 +282,7 @@ class ApplicationCallbackExecCtx {
286282
}
287283
(*f->functor_run)(f, f->internal_success);
288284
}
289-
callback_exec_ctx_ = nullptr;
285+
*GetCallbackExecCtx() = nullptr;
290286
if (!(GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD & flags_)) {
291287
Fork::DecExecCtxCount();
292288
}
@@ -298,14 +294,14 @@ class ApplicationCallbackExecCtx {
298294

299295
uintptr_t Flags() { return flags_; }
300296

301-
static ApplicationCallbackExecCtx* Get() { return callback_exec_ctx_; }
297+
static ApplicationCallbackExecCtx* Get() { return *GetCallbackExecCtx(); }
302298

303299
static void Set(ApplicationCallbackExecCtx* exec_ctx, uintptr_t flags) {
304300
if (Get() == nullptr) {
305301
if (!(GRPC_APP_CALLBACK_EXEC_CTX_FLAG_IS_INTERNAL_THREAD & flags)) {
306302
Fork::IncExecCtxCount();
307303
}
308-
callback_exec_ctx_ = exec_ctx;
304+
*GetCallbackExecCtx() = exec_ctx;
309305
}
310306
}
311307

@@ -330,7 +326,8 @@ class ApplicationCallbackExecCtx {
330326
uintptr_t flags_{0u};
331327
grpc_completion_queue_functor* head_{nullptr};
332328
grpc_completion_queue_functor* tail_{nullptr};
333-
static thread_local ApplicationCallbackExecCtx* callback_exec_ctx_;
329+
330+
static ApplicationCallbackExecCtx** GetCallbackExecCtx();
334331
};
335332

336333
} // namespace grpc_core

0 commit comments

Comments
 (0)