diff options
-rw-r--r-- | src/core/client_config/lb_policies/pick_first.c | 2 | ||||
-rw-r--r-- | src/core/iomgr/fd_posix.c | 2 | ||||
-rw-r--r-- | src/core/iomgr/iomgr.c | 10 | ||||
-rw-r--r-- | src/core/transport/connectivity_state.c | 4 | ||||
-rw-r--r-- | test/core/iomgr/tcp_server_posix_test.c | 4 |
5 files changed, 17 insertions, 5 deletions
diff --git a/src/core/client_config/lb_policies/pick_first.c b/src/core/client_config/lb_policies/pick_first.c index c9a200eb8c..eebc7191ba 100644 --- a/src/core/client_config/lb_policies/pick_first.c +++ b/src/core/client_config/lb_policies/pick_first.c @@ -232,7 +232,7 @@ static void pf_connectivity_changed(void *arg, int iomgr_success, break; case GRPC_CHANNEL_CONNECTING: case GRPC_CHANNEL_IDLE: - grpc_connectivity_state_set(&p->state_tracker, p->checking_connectivity, + grpc_connectivity_state_set(&p->state_tracker, GRPC_CHANNEL_CONNECTING, "connecting_changed", call_list); grpc_subchannel_notify_on_state_change( p->subchannels[p->checking_subchannel], &p->checking_connectivity, 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; diff --git a/src/core/transport/connectivity_state.c b/src/core/transport/connectivity_state.c index dc8392159b..d04c3a2209 100644 --- a/src/core/transport/connectivity_state.c +++ b/src/core/transport/connectivity_state.c @@ -87,6 +87,10 @@ void grpc_connectivity_state_destroy(grpc_connectivity_state_tracker *tracker, grpc_connectivity_state grpc_connectivity_state_check( grpc_connectivity_state_tracker *tracker) { + if (grpc_connectivity_state_trace) { + gpr_log(GPR_DEBUG, "CONWATCH: %s: get %s", tracker->name, + grpc_connectivity_state_name(tracker->current_state)); + } return tracker->current_state; } diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c index 5bd3792a01..75026f651c 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.c @@ -74,6 +74,7 @@ static void test_no_op_with_start(void) { } static void test_no_op_with_port(void) { + grpc_call_list call_list = GRPC_CALL_LIST_INIT; struct sockaddr_in addr; grpc_tcp_server *s = grpc_tcp_server_create(); LOG_TEST("test_no_op_with_port"); @@ -83,7 +84,8 @@ static void test_no_op_with_port(void) { GPR_ASSERT( grpc_tcp_server_add_port(s, (struct sockaddr *)&addr, sizeof(addr))); - grpc_tcp_server_destroy(s, NULL, NULL); + grpc_tcp_server_destroy(s, NULL, &call_list); + grpc_call_list_run(&call_list); } static void test_no_op_with_port_and_start(void) { |