aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/surface
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-08-19 11:15:38 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-08-19 11:15:38 -0700
commit00a3dab83a7f8e08ba9e9b8349da2d76ea1e4731 (patch)
treeb4a49a16a45ea3495d135caf9e9e15d3ea43f883 /src/core/surface
parent4836492061381701f15c4a121f44e6377786a07d (diff)
Short-circuit shutdown when it is already published (core)
Diffstat (limited to 'src/core/surface')
-rw-r--r--src/core/surface/server.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index 4990e6583a..1c402418e8 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -975,6 +975,11 @@ void grpc_server_setup_transport(grpc_server *s, grpc_transport *transport,
grpc_transport_perform_op(transport, &op);
}
+void done_published_shutdown(void *done_arg, grpc_cq_completion *storage) {
+ (void) done_arg;
+ gpr_free(storage);
+}
+
void grpc_server_shutdown_and_notify(grpc_server *server,
grpc_completion_queue *cq, void *tag) {
listener *l;
@@ -986,6 +991,12 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
/* lock, and gather up some stuff to do */
gpr_mu_lock(&server->mu_global);
grpc_cq_begin_op(cq);
+ if (server->shutdown_published) {
+ grpc_cq_end_op(cq, tag, 1, done_published_shutdown, NULL,
+ gpr_malloc(sizeof(grpc_cq_completion)));
+ gpr_mu_unlock(&server->mu_global);
+ return;
+ }
server->shutdown_tags =
gpr_realloc(server->shutdown_tags,
sizeof(shutdown_tag) * (server->num_shutdown_tags + 1));