Add missing APP callback context for custom iomgr

This PR adds the following missing APP callback context rerlated to the
usage of a custom iomgr.

- When a new TCP connection is established
- When a new TCP connection is accepted
- When a new domain resolution finishes
- When network primitives, like read and write, finish they job

Without these APP contexts, pending user app callbacks are never
executed.
pull/19687/head
Pau Freixes 6 years ago
parent 8fe1abebbf
commit 9e80f74326
  1. 1
      src/core/lib/iomgr/resolve_address_custom.cc
  2. 1
      src/core/lib/iomgr/tcp_client_custom.cc
  3. 4
      src/core/lib/iomgr/tcp_custom.cc
  4. 1
      src/core/lib/iomgr/tcp_server_custom.cc

@ -71,6 +71,7 @@ void grpc_custom_resolve_callback(grpc_custom_resolver* r,
grpc_resolved_addresses* result,
grpc_error* error) {
GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
if (error == GRPC_ERROR_NONE) {
*r->addresses = result;

@ -101,6 +101,7 @@ static void custom_connect_callback_internal(grpc_custom_socket* socket,
static void custom_connect_callback(grpc_custom_socket* socket,
grpc_error* error) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
if (grpc_core::ExecCtx::Get() == nullptr) {
/* If we are being run on a thread which does not have an exec_ctx created
* yet, we should create one. */

@ -145,6 +145,7 @@ static void call_read_cb(custom_tcp_endpoint* tcp, grpc_error* error) {
static void custom_read_callback(grpc_custom_socket* socket, size_t nread,
grpc_error* error) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_slice_buffer garbage;
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint;
@ -207,6 +208,7 @@ static void endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
static void custom_write_callback(grpc_custom_socket* socket,
grpc_error* error) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint;
grpc_closure* cb = tcp->write_cb;
@ -301,6 +303,7 @@ static void custom_close_callback(grpc_custom_socket* socket) {
grpc_custom_socket_vtable->destroy(socket);
gpr_free(socket);
} else if (socket->endpoint) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
custom_tcp_endpoint* tcp = (custom_tcp_endpoint*)socket->endpoint;
TCP_UNREF(tcp, "destroy");
@ -343,6 +346,7 @@ grpc_endpoint* custom_tcp_endpoint_create(grpc_custom_socket* socket,
char* peer_string) {
custom_tcp_endpoint* tcp =
(custom_tcp_endpoint*)gpr_malloc(sizeof(custom_tcp_endpoint));
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
if (GRPC_TRACE_FLAG_ENABLED(grpc_tcp_trace)) {

@ -245,6 +245,7 @@ static void custom_accept_callback(grpc_custom_socket* socket,
static void custom_accept_callback(grpc_custom_socket* socket,
grpc_custom_socket* client,
grpc_error* error) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_tcp_listener* sp = socket->listener;
if (error != GRPC_ERROR_NONE) {

Loading…
Cancel
Save