Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kpayson64 committed Jun 20, 2018
1 parent 062f369 commit 46a6059
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/core/lib/iomgr/exec_ctx.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ typedef struct grpc_combiner grpc_combiner;
/* The exec_ctx's thread is (potentially) owned by a call or channel: care
should be given to not delete said call/channel from this exec_ctx */
#define GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP 2
/* This exec ctx was initialized by an internal thread, and should not
be counted by fork handlers */
#define GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD 4

extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;

Expand Down Expand Up @@ -93,7 +96,9 @@ class ExecCtx {

/** Parameterised Constructor */
ExecCtx(uintptr_t fl) : flags_(fl) {
grpc_core::Fork::IncExecCtxCount();
if (!(GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD & flags_)) {
grpc_core::Fork::IncExecCtxCount();
}
Set(this);
}

Expand All @@ -102,7 +107,9 @@ class ExecCtx {
flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
Flush();
Set(last_exec_ctx_);
grpc_core::Fork::DecExecCtxCount();
if (!(GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD & flags_)) {
grpc_core::Fork::DecExecCtxCount();
}
}

/** Disallow copy and assignment operators */
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/iomgr/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void executor_thread(void* arg) {
thread_state* ts = static_cast<thread_state*>(arg);
gpr_tls_set(&g_this_thread_state, (intptr_t)ts);

grpc_core::ExecCtx exec_ctx(0);
grpc_core::ExecCtx exec_ctx(GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD);

size_t subtract_depth = 0;
for (;;) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/iomgr/timer_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static void timer_thread_cleanup(completed_thread* ct) {
static void timer_thread(void* completed_thread_ptr) {
// this threads exec_ctx: we try to run things through to completion here
// since it's easy to spin up new threads
grpc_core::ExecCtx exec_ctx(0);
grpc_core::ExecCtx exec_ctx(GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD);
timer_main_loop();

timer_thread_cleanup(static_cast<completed_thread*>(completed_thread_ptr));
Expand Down

0 comments on commit 46a6059

Please sign in to comment.