Make C/C++ tests pass

pull/1731/head
Craig Tiller 10 years ago
parent e511fdbd51
commit 29f79dcb08
  1. 4
      src/core/support/sync.c
  2. 13
      src/core/surface/server.c
  3. 3
      src/cpp/server/server.cc

@ -118,7 +118,9 @@ void gpr_refn(gpr_refcount *r, int n) {
} }
int gpr_unref(gpr_refcount *r) { int gpr_unref(gpr_refcount *r) {
return gpr_atm_full_fetch_add(&r->count, -1) == 1; gpr_atm prior = gpr_atm_full_fetch_add(&r->count, -1);
GPR_ASSERT(prior > 0);
return prior == 1;
} }
void gpr_stats_init(gpr_stats_counter *c, gpr_intptr n) { void gpr_stats_init(gpr_stats_counter *c, gpr_intptr n) {

@ -144,6 +144,7 @@ struct grpc_server {
requested_call_array requested_calls; requested_call_array requested_calls;
gpr_uint8 shutdown; gpr_uint8 shutdown;
gpr_uint8 shutdown_published;
size_t num_shutdown_tags; size_t num_shutdown_tags;
shutdown_tag *shutdown_tags; shutdown_tag *shutdown_tags;
@ -389,7 +390,8 @@ static int num_listeners(grpc_server *server) {
static void maybe_finish_shutdown(grpc_server *server) { static void maybe_finish_shutdown(grpc_server *server) {
size_t i; size_t i;
if (server->shutdown && server->lists[ALL_CALLS] == NULL && server->listeners_destroyed == num_listeners(server)) { if (server->shutdown && !server->shutdown_published && server->lists[ALL_CALLS] == NULL && server->listeners_destroyed == num_listeners(server)) {
server->shutdown_published = 1;
for (i = 0; i < server->num_shutdown_tags; i++) { for (i = 0; i < server->num_shutdown_tags; i++) {
grpc_cq_end_op(server->shutdown_tags[i].cq, server->shutdown_tags[i].tag, grpc_cq_end_op(server->shutdown_tags[i].cq, server->shutdown_tags[i].tag,
NULL, 1); NULL, 1);
@ -456,8 +458,9 @@ static void server_on_recv(void *ptr, int success) {
calld->state = ZOMBIED; calld->state = ZOMBIED;
grpc_iomgr_add_callback(kill_zombie, elem); grpc_iomgr_add_callback(kill_zombie, elem);
} }
call_list_remove(calld, ALL_CALLS); if (call_list_remove(calld, ALL_CALLS)) {
maybe_finish_shutdown(chand->server); maybe_finish_shutdown(chand->server);
}
gpr_mu_unlock(&chand->server->mu); gpr_mu_unlock(&chand->server->mu);
break; break;
} }
@ -822,9 +825,7 @@ void grpc_server_shutdown_and_notify(grpc_server *server,
/* lock, and gather up some stuff to do */ /* lock, and gather up some stuff to do */
gpr_mu_lock(&server->mu); gpr_mu_lock(&server->mu);
for (i = 0; i < server->cq_count; i++) { grpc_cq_begin_op(cq, NULL);
grpc_cq_begin_op(server->cqs[i], NULL);
}
server->shutdown_tags = server->shutdown_tags =
gpr_realloc(server->shutdown_tags, gpr_realloc(server->shutdown_tags,
sizeof(void *) * (server->num_shutdown_tags + 1)); sizeof(void *) * (server->num_shutdown_tags + 1));

@ -221,6 +221,9 @@ Server::~Server() {
Shutdown(); Shutdown();
} }
} }
void* got_tag;
bool ok;
GPR_ASSERT(!cq_.Next(&got_tag, &ok));
grpc_server_destroy(server_); grpc_server_destroy(server_);
if (thread_pool_owned_) { if (thread_pool_owned_) {
delete thread_pool_; delete thread_pool_;

Loading…
Cancel
Save