diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-09-23 12:32:40 -0700 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-09-23 12:32:40 -0700 |
commit | 258f8de866958599b454bbc73b9deaa78235acad (patch) | |
tree | 02b7aef5c3bf33d3bb8e0efe45ec617da781f0ee /src/core | |
parent | 5c1ad056d2498fe719118f0bff2484c2f25469dc (diff) |
Windows fixes
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/iomgr/exec_ctx.c | 2 | ||||
-rw-r--r-- | src/core/iomgr/iocp_windows.c | 6 | ||||
-rw-r--r-- | src/core/iomgr/pollset_windows.c | 5 | ||||
-rw-r--r-- | src/core/iomgr/tcp_server_windows.c | 6 | ||||
-rw-r--r-- | src/core/iomgr/tcp_windows.c | 2 |
5 files changed, 17 insertions, 4 deletions
diff --git a/src/core/iomgr/exec_ctx.c b/src/core/iomgr/exec_ctx.c index 74aad6cea3..a830a27b0b 100644 --- a/src/core/iomgr/exec_ctx.c +++ b/src/core/iomgr/exec_ctx.c @@ -33,6 +33,8 @@ #include "src/core/iomgr/exec_ctx.h" +#include <grpc/support/log.h> + void grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) { while (!grpc_closure_list_empty(exec_ctx->closure_list)) { grpc_closure *c = exec_ctx->closure_list.head; diff --git a/src/core/iomgr/iocp_windows.c b/src/core/iomgr/iocp_windows.c index 3556b2c301..c2f62a41b8 100644 --- a/src/core/iomgr/iocp_windows.c +++ b/src/core/iomgr/iocp_windows.c @@ -64,6 +64,7 @@ static void do_iocp_work(grpc_exec_ctx *exec_ctx) { LPOVERLAPPED overlapped; grpc_winsocket *socket; grpc_winsocket_callback_info *info; + grpc_closure *closure = NULL; success = GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped, INFINITE); /* success = 0 and overlapped = NULL means the deadline got attained. @@ -97,12 +98,15 @@ static void do_iocp_work(grpc_exec_ctx *exec_ctx) { GPR_ASSERT(!info->has_pending_iocp); gpr_mu_lock(&socket->state_mu); if (info->closure) { - grpc_exec_ctx_enqueue(exec_ctx, info->closure, 1); + closure = info->closure; info->closure = NULL; } else { info->has_pending_iocp = 1; } gpr_mu_unlock(&socket->state_mu); + if (closure) { + closure->cb(exec_ctx, closure->cb_arg, 1); + } } static void iocp_loop(void *p) { diff --git a/src/core/iomgr/pollset_windows.c b/src/core/iomgr/pollset_windows.c index 5e835743af..6182eb3532 100644 --- a/src/core/iomgr/pollset_windows.c +++ b/src/core/iomgr/pollset_windows.c @@ -115,6 +115,11 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, pollset->kicked_without_pollers = 0; } done: + if (!grpc_closure_list_empty(exec_ctx->closure_list)) { + gpr_mu_unlock(&pollset->mu); + grpc_exec_ctx_flush(exec_ctx); + gpr_mu_lock(&pollset->mu); + } gpr_cv_destroy(&worker->cv); if (added_worker) { remove_worker(pollset, worker); diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c index 7244606e98..4b11ab0f06 100644 --- a/src/core/iomgr/tcp_server_windows.c +++ b/src/core/iomgr/tcp_server_windows.c @@ -380,8 +380,9 @@ static int add_socket_to_server(grpc_tcp_server *s, SOCKET sock, GPR_ASSERT(!s->on_accept_cb && "must add ports before starting server"); /* append it to the list under a lock */ if (s->nports == s->port_capacity) { - s->port_capacity *= 2; - s->ports = gpr_realloc(s->ports, sizeof(server_port) * s->port_capacity); + /* too many ports, and we need to store their address in a closure */ + /* TODO(ctiller): make server_port a linked list */ + abort(); } sp = &s->ports[s->nports++]; sp->server = s; @@ -389,6 +390,7 @@ static int add_socket_to_server(grpc_tcp_server *s, SOCKET sock, sp->shutting_down = 0; sp->AcceptEx = AcceptEx; sp->new_socket = INVALID_SOCKET; + grpc_closure_init(&sp->on_accept, on_accept, sp); GPR_ASSERT(sp->socket); gpr_mu_unlock(&s->mu); } diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c index 2962762679..9cae07316a 100644 --- a/src/core/iomgr/tcp_windows.c +++ b/src/core/iomgr/tcp_windows.c @@ -394,7 +394,7 @@ grpc_endpoint *grpc_tcp_create(grpc_winsocket *socket, char *peer_string) { gpr_mu_init(&tcp->mu); gpr_ref_init(&tcp->refcount, 1); grpc_closure_init(&tcp->on_read, on_read, tcp); - grpc_closure_init(&tcp->on_read, on_write, tcp); + grpc_closure_init(&tcp->on_write, on_write, tcp); tcp->peer_string = gpr_strdup(peer_string); return &tcp->base; } |