Merge pull request #1269 from ctiller/racefix
Fix race on shutdown
diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c
index 895f85f..7e31f2d 100644
--- a/src/core/iomgr/tcp_server_posix.c
+++ b/src/core/iomgr/tcp_server_posix.c
@@ -174,7 +174,6 @@
while (s->active_ports) {
gpr_cv_wait(&s->cv, &s->mu, gpr_inf_future);
}
- gpr_mu_unlock(&s->mu);
/* delete ALL the things */
if (s->nports) {
@@ -185,7 +184,9 @@
}
grpc_fd_orphan(sp->emfd, destroyed_port, s);
}
+ gpr_mu_unlock(&s->mu);
} else {
+ gpr_mu_unlock(&s->mu);
finish_shutdown(s);
}
}