Inline start the tcp servers

pull/18869/head
yang-g 6 years ago
parent a3062ca04a
commit 9cac231163
  1. 31
      src/core/lib/surface/server.cc

@ -1098,20 +1098,6 @@ void* grpc_server_register_method(
return m; return m;
} }
static void start_listeners(void* s, grpc_error* error) {
grpc_server* server = static_cast<grpc_server*>(s);
for (listener* l = server->listeners; l; l = l->next) {
l->start(server, l->arg, server->pollsets, server->pollset_count);
}
gpr_mu_lock(&server->mu_global);
server->starting = false;
gpr_cv_signal(&server->starting_cv);
gpr_mu_unlock(&server->mu_global);
server_unref(server);
}
void grpc_server_start(grpc_server* server) { void grpc_server_start(grpc_server* server) {
size_t i; size_t i;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
@ -1133,13 +1119,18 @@ void grpc_server_start(grpc_server* server) {
request_matcher_init(&rm->matcher, server); request_matcher_init(&rm->matcher, server);
} }
server_ref(server); gpr_mu_lock(&server->mu_global);
server->starting = true; server->starting = true;
GRPC_CLOSURE_SCHED( gpr_mu_unlock(&server->mu_global);
GRPC_CLOSURE_CREATE(
start_listeners, server, for (listener* l = server->listeners; l; l = l->next) {
grpc_core::Executor::Scheduler(grpc_core::ExecutorJobType::SHORT)), l->start(server, l->arg, server->pollsets, server->pollset_count);
GRPC_ERROR_NONE); }
gpr_mu_lock(&server->mu_global);
server->starting = false;
gpr_cv_signal(&server->starting_cv);
gpr_mu_unlock(&server->mu_global);
} }
void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets, void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,

Loading…
Cancel
Save