aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <y-zeng@users.noreply.github.com>2017-12-07 11:57:54 -0800
committerGravatar GitHub <noreply@github.com>2017-12-07 11:57:54 -0800
commitc01a91da2d43e858cace8b34119fa35148818458 (patch)
tree601fa0cb754d94d649d9b691356f3773facbfea2 /src/core/lib
parent4ff97d29069022842bc33d103ee383da7f79e324 (diff)
parent625a5c05456a3001ecd4519b133aecd61e5b333b (diff)
Merge pull request #13647 from y-zeng/send_ping
Add on_initiate callback for the send_ping tranport op
Diffstat (limited to 'src/core/lib')
-rw-r--r--src/core/lib/surface/channel_ping.cc2
-rw-r--r--src/core/lib/surface/lame_client.cc9
-rw-r--r--src/core/lib/transport/transport.h10
-rw-r--r--src/core/lib/transport/transport_op_string.cc2
4 files changed, 17 insertions, 6 deletions
diff --git a/src/core/lib/surface/channel_ping.cc b/src/core/lib/surface/channel_ping.cc
index e8f47f01cf..7b1964fd55 100644
--- a/src/core/lib/surface/channel_ping.cc
+++ b/src/core/lib/surface/channel_ping.cc
@@ -57,7 +57,7 @@ void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
pr->tag = tag;
pr->cq = cq;
GRPC_CLOSURE_INIT(&pr->closure, ping_done, pr, grpc_schedule_on_exec_ctx);
- op->send_ping = &pr->closure;
+ op->send_ping.on_ack = &pr->closure;
op->bind_pollset = grpc_cq_pollset(cq);
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
top_elem->filter->start_transport_op(&exec_ctx, top_elem, op);
diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc
index c32c9af50e..559d7af43e 100644
--- a/src/core/lib/surface/lame_client.cc
+++ b/src/core/lib/surface/lame_client.cc
@@ -104,9 +104,14 @@ static void lame_start_transport_op(grpc_exec_ctx* exec_ctx,
GRPC_CLOSURE_SCHED(exec_ctx, op->on_connectivity_state_change,
GRPC_ERROR_NONE);
}
- if (op->send_ping != nullptr) {
+ if (op->send_ping.on_initiate != nullptr) {
GRPC_CLOSURE_SCHED(
- exec_ctx, op->send_ping,
+ exec_ctx, op->send_ping.on_initiate,
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
+ }
+ if (op->send_ping.on_ack != nullptr) {
+ GRPC_CLOSURE_SCHED(
+ exec_ctx, op->send_ping.on_ack,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("lame client channel"));
}
GRPC_ERROR_UNREF(op->disconnect_with_error);
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"));