diff options
author | Yash Tibrewal <yashkt@google.com> | 2018-04-09 17:12:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-09 17:12:44 -0700 |
commit | 09d6e8cbc30e6f278415b2b06aa8617f638e6b86 (patch) | |
tree | e96f84cfebcdb0d51f278a70b145f20dc1711125 | |
parent | 7312860e3ed9c0ff028d1ca293d78150a5a83c15 (diff) | |
parent | 6b3db74df988fac2b528ba81aebaf2baa53e7991 (diff) |
Merge pull request #14890 from yashykt/execctx_cleanup
Remove exec_ctx from slice and slice buffer
-rw-r--r-- | src/core/lib/slice/slice.cc | 8 | ||||
-rw-r--r-- | src/core/lib/slice/slice_buffer.cc | 16 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc index 585b41cf91..419474129b 100644 --- a/src/core/lib/slice/slice.cc +++ b/src/core/lib/slice/slice.cc @@ -69,8 +69,12 @@ grpc_slice grpc_slice_ref(grpc_slice slice) { /* Public API */ void grpc_slice_unref(grpc_slice slice) { - grpc_core::ExecCtx exec_ctx; - grpc_slice_unref_internal(slice); + if (grpc_core::ExecCtx::Get() == nullptr) { + grpc_core::ExecCtx exec_ctx; + grpc_slice_unref_internal(slice); + } else { + grpc_slice_unref_internal(slice); + } } /* grpc_slice_from_static_string support structure - a refcount that does diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc index 58ca495517..fd56997388 100644 --- a/src/core/lib/slice/slice_buffer.cc +++ b/src/core/lib/slice/slice_buffer.cc @@ -75,8 +75,12 @@ void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb) { } void grpc_slice_buffer_destroy(grpc_slice_buffer* sb) { - grpc_core::ExecCtx exec_ctx; - grpc_slice_buffer_destroy_internal(sb); + if (grpc_core::ExecCtx::Get() == nullptr) { + grpc_core::ExecCtx exec_ctx; + grpc_slice_buffer_destroy_internal(sb); + } else { + grpc_slice_buffer_destroy_internal(sb); + } } uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) { @@ -176,8 +180,12 @@ void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb) { } void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb) { - grpc_core::ExecCtx exec_ctx; - grpc_slice_buffer_reset_and_unref_internal(sb); + if (grpc_core::ExecCtx::Get() == nullptr) { + grpc_core::ExecCtx exec_ctx; + grpc_slice_buffer_reset_and_unref_internal(sb); + } else { + grpc_slice_buffer_reset_and_unref_internal(sb); + } } void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b) { |