diff options
author | Craig Tiller <ctiller@google.com> | 2015-09-21 21:27:54 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-09-21 21:27:54 -0700 |
commit | 62aef621360403c15a7c58f4b7a3e8daadc7b07a (patch) | |
tree | 52b3dcacf4413372ce4e88d4586091d3cc09e4c6 /src/core/iomgr | |
parent | ba496454b2f0909a64845f1305f3b0a81073a4f1 (diff) |
Fixes
Diffstat (limited to 'src/core/iomgr')
-rw-r--r-- | src/core/iomgr/fd_posix.c | 2 | ||||
-rw-r--r-- | src/core/iomgr/iomgr.c | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 294cb70746..7c1db32553 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -150,6 +150,8 @@ static void unref_by(grpc_fd *fd, int n) { void grpc_fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); } void grpc_fd_global_shutdown(void) { + gpr_mu_lock(&fd_freelist_mu); + gpr_mu_unlock(&fd_freelist_mu); while (fd_freelist != NULL) { grpc_fd *fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; diff --git a/src/core/iomgr/iomgr.c b/src/core/iomgr/iomgr.c index 5cb20a7ba0..b2c17b1ef2 100644 --- a/src/core/iomgr/iomgr.c +++ b/src/core/iomgr/iomgr.c @@ -134,6 +134,10 @@ void grpc_iomgr_shutdown(void) { grpc_alarm_list_shutdown(&call_list); grpc_call_list_run(&call_list); + /* ensure all threads have left g_mu */ + gpr_mu_lock(&g_mu); + gpr_mu_unlock(&g_mu); + grpc_iomgr_platform_shutdown(); gpr_mu_destroy(&g_mu); gpr_cv_destroy(&g_rcv); @@ -166,10 +170,10 @@ void grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb, void grpc_call_list_add(grpc_call_list *call_list, grpc_closure *closure, int success) { - if (!closure) return; + if (closure == NULL) return; closure->next = NULL; closure->success = success; - if (!call_list->head) { + if (call_list->head == NULL) { call_list->head = closure; } else { call_list->tail->next = closure; @@ -181,7 +185,7 @@ void grpc_call_list_run(grpc_call_list *call_list) { while (!grpc_call_list_empty(*call_list)) { grpc_closure *c = call_list->head; call_list->head = call_list->tail = NULL; - while (c) { + while (c != NULL) { grpc_closure *next = c->next; c->cb(c->cb_arg, c->success, call_list); c = next; |