diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-09-01 12:23:28 -0700 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-09-01 12:23:28 -0700 |
commit | 5100ea0043be791587b7d21b4cb32dac3648f17c (patch) | |
tree | 42ff43d64f4ced826a2a091ab48aa4ea42ed5969 /src/core/iomgr | |
parent | f418260787e8af1b635084133ce14615c88a7331 (diff) |
fixes for windows
Diffstat (limited to 'src/core/iomgr')
-rw-r--r-- | src/core/iomgr/iocp_windows.c | 1 | ||||
-rw-r--r-- | src/core/iomgr/socket_windows.c | 3 | ||||
-rw-r--r-- | src/core/iomgr/tcp_server_windows.c | 40 |
3 files changed, 23 insertions, 21 deletions
diff --git a/src/core/iomgr/iocp_windows.c b/src/core/iomgr/iocp_windows.c index 0799622497..006f8b2abf 100644 --- a/src/core/iomgr/iocp_windows.c +++ b/src/core/iomgr/iocp_windows.c @@ -112,7 +112,6 @@ static void do_iocp_work() { static void iocp_loop(void *p) { while (gpr_atm_acq_load(&g_custom_events) || !gpr_event_get(&g_shutdown_iocp)) { - grpc_maybe_call_delayed_callbacks(NULL, 1); do_iocp_work(); } diff --git a/src/core/iomgr/socket_windows.c b/src/core/iomgr/socket_windows.c index dbc64637b5..2cbe945ca3 100644 --- a/src/core/iomgr/socket_windows.c +++ b/src/core/iomgr/socket_windows.c @@ -63,11 +63,10 @@ grpc_winsocket *grpc_winsocket_create(SOCKET socket, const char *name) { various callsites of that function, which happens to be in various mutex hold states, and that'd be unsafe to call them directly. */ void grpc_winsocket_shutdown(grpc_winsocket *winsocket) { - shutdown(winsocket->socket, SD_BOTH); + closesocket(winsocket->socket); } void grpc_winsocket_destroy(grpc_winsocket *winsocket) { - closesocket(winsocket->socket); grpc_iomgr_unregister_object(&winsocket->iomgr_object); gpr_mu_destroy(&winsocket->state_mu); gpr_free(winsocket); diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c index 21f19f0ba2..b513d854aa 100644 --- a/src/core/iomgr/tcp_server_windows.c +++ b/src/core/iomgr/tcp_server_windows.c @@ -106,6 +106,22 @@ grpc_tcp_server *grpc_tcp_server_create(void) { static void dont_care_about_shutdown_completion(void *arg) {} +static void finish_shutdown(grpc_tcp_server *s) { + size_t i; + + s->shutdown_complete(s->shutdown_complete_arg); + + /* Now that the accepts have been aborted, we can destroy the sockets. + The IOCP won't get notified on these, so we can flag them as already + closed by the system. */ + for (i = 0; i < s->nports; i++) { + server_port *sp = &s->ports[i]; + grpc_winsocket_destroy(sp->socket); + } + gpr_free(s->ports); + gpr_free(s); +} + /* Public function. Stops and destroys a grpc_tcp_server. */ void grpc_tcp_server_destroy(grpc_tcp_server *s, void (*shutdown_complete)(void *shutdown_done_arg), @@ -131,18 +147,8 @@ void grpc_tcp_server_destroy(grpc_tcp_server *s, } gpr_mu_unlock(&s->mu); - /* Now that the accepts have been aborted, we can destroy the sockets. - The IOCP won't get notified on these, so we can flag them as already - closed by the system. */ - for (i = 0; i < s->nports; i++) { - server_port *sp = &s->ports[i]; - grpc_winsocket_destroy(sp->socket); - } - gpr_free(s->ports); - gpr_free(s); - if (immediately_done) { - s->shutdown_complete(s->shutdown_complete_arg); + finish_shutdown(s); } } @@ -195,18 +201,16 @@ error: } static void decrement_active_ports_and_notify(server_port *sp) { - void(*notify)(void *) = NULL; - void *notify_arg = NULL; + int notify = 0; sp->shutting_down = 0; gpr_mu_lock(&sp->server->mu); GPR_ASSERT(sp->server->active_ports > 0); - if (0 == --sp->server->active_ports) { - notify = sp->server->shutdown_complete; - notify_arg = sp->server->shutdown_complete_arg; + if (0 == --sp->server->active_ports && sp->server->shutdown_complete != NULL) { + notify = 1; } gpr_mu_unlock(&sp->server->mu); - if (notify != NULL) { - notify(notify_arg); + if (notify) { + finish_shutdown(sp->server); } } |