From c272dd73aad1273b70fbd038efb02d6f0e169b60 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Tue, 5 Dec 2017 12:18:34 -0800 Subject: Add on_initiate callback for the send_ping tranport op --- src/core/lib/transport/transport.h | 10 ++++++++-- src/core/lib/transport/transport_op_string.cc | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/core/lib/transport') diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index b3cf04c22d..73264142d9 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -245,8 +245,14 @@ typedef struct grpc_transport_op { grpc_pollset* bind_pollset; /** add this transport to a pollset_set */ grpc_pollset_set* bind_pollset_set; - /** send a ping, call this back if not NULL */ - grpc_closure* send_ping; + /** send a ping, if either on_initiate or on_ack is not NULL */ + struct { + /** Ping may be delayed by the transport, on_initiate callback will be + called when the ping is actually being sent. */ + grpc_closure* on_initiate; + /** Called when the ping ack is received */ + grpc_closure* on_ack; + } send_ping; /*************************************************************************** * remaining fields are initialized and used at the discretion of the diff --git a/src/core/lib/transport/transport_op_string.cc b/src/core/lib/transport/transport_op_string.cc index e69ab02570..c0f82fea0d 100644 --- a/src/core/lib/transport/transport_op_string.cc +++ b/src/core/lib/transport/transport_op_string.cc @@ -187,7 +187,7 @@ char* grpc_transport_op_string(grpc_transport_op* op) { gpr_strvec_add(&b, gpr_strdup("BIND_POLLSET_SET")); } - if (op->send_ping != nullptr) { + if (op->send_ping.on_initiate != nullptr || op->send_ping.on_ack != nullptr) { if (!first) gpr_strvec_add(&b, gpr_strdup(" ")); // first = false; gpr_strvec_add(&b, gpr_strdup("SEND_PING")); -- cgit v1.2.3