From caaf416eba1390b1acc2f1735448277f69ee50b6 Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Thu, 7 Dec 2017 21:09:11 -0800 Subject: [PATCH] virtual destructor in exec_ctx, remove unneeded flush in grpc_shutdown and remove grpc_exec_ctx from .pxi files in python --- src/core/ext/filters/client_channel/lb_policy.cc | 2 +- src/core/lib/iomgr/exec_ctx.h | 2 +- src/core/lib/surface/init.cc | 3 --- src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 11 ++--------- .../grpcio/grpc/_cython/_cygrpc/records.pyx.pxi | 4 ++-- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index 0a097e58846..7a5a8dec34b 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -130,7 +130,7 @@ void grpc_lb_policy_exit_idle_locked(grpc_lb_policy* policy) { void grpc_lb_policy_ping_one_locked(grpc_lb_policy* policy, grpc_closure* on_initiate, grpc_closure* on_ack) { - policy->vtable->ping_one_locked(exec_ctx, policy, on_initiate, on_ack); + policy->vtable->ping_one_locked(policy, on_initiate, on_ack); } void grpc_lb_policy_notify_on_state_change_locked( diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index b0c1740155f..dbb76af1ebd 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -80,7 +80,7 @@ class ExecCtx { ExecCtx(uintptr_t fl) : flags_(fl) { Set(this); } /** Destructor */ - ~ExecCtx() { + virtual ~ExecCtx() { flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED; Flush(); Set(last_exec_ctx_); diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index c6ce235da7f..0f40965f16c 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -157,9 +157,6 @@ void grpc_init(void) { void grpc_shutdown(void) { int i; GRPC_API_TRACE("grpc_shutdown(void)", 0, ()); - if (grpc_core::ExecCtx::Get()) { - grpc_core::ExecCtx::Get()->Flush(); - } gpr_mu_lock(&g_init_mu); if (--g_initializations == 0) { { diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 660263fc09d..6a72bbf6930 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -36,13 +36,6 @@ cdef extern from "grpc/byte_buffer_reader.h": pass -cdef extern from "grpc/impl/codegen/exec_ctx_fwd.h": - - struct grpc_exec_ctx: - # We don't care about the internals - pass - - cdef extern from "grpc/grpc.h": ctypedef struct grpc_slice: @@ -169,7 +162,7 @@ cdef extern from "grpc/grpc.h": ctypedef struct grpc_arg_pointer_vtable: void *(*copy)(void *) - void (*destroy)(grpc_exec_ctx *, void *) + void (*destroy)(void *) int (*cmp)(void *, void *) ctypedef struct grpc_arg_value_pointer: @@ -524,7 +517,7 @@ cdef extern from "grpc/grpc_security.h": grpc_auth_property_iterator grpc_auth_context_property_iterator( const grpc_auth_context *ctx) - + grpc_auth_property_iterator grpc_auth_context_peer_identity( const grpc_auth_context *ctx) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index 4f87261e173..03fb2261901 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -320,7 +320,7 @@ cdef void* copy_ptr(void* ptr): return ptr -cdef void destroy_ptr(grpc_exec_ctx* ctx, void* ptr): +cdef void destroy_ptr(void* ptr): pass @@ -348,7 +348,7 @@ cdef class ChannelArg: elif hasattr(value, '__int__'): # Pointer objects must override __int__() to return # the underlying C address (Python ints are word size). The - # lifecycle of the pointer is fixed to the lifecycle of the + # lifecycle of the pointer is fixed to the lifecycle of the # python object wrapping it. self.ptr_vtable.copy = ©_ptr self.ptr_vtable.destroy = &destroy_ptr