Windows fixes

pull/3423/head
Craig Tiller 9 years ago
parent 5c1ad056d2
commit 258f8de866
  1. 2
      src/core/iomgr/exec_ctx.c
  2. 6
      src/core/iomgr/iocp_windows.c
  3. 5
      src/core/iomgr/pollset_windows.c
  4. 6
      src/core/iomgr/tcp_server_windows.c
  5. 2
      src/core/iomgr/tcp_windows.c
  6. 2
      tools/run_tests/jobset.py

@ -33,6 +33,8 @@
#include "src/core/iomgr/exec_ctx.h" #include "src/core/iomgr/exec_ctx.h"
#include <grpc/support/log.h>
void grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) { void grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
while (!grpc_closure_list_empty(exec_ctx->closure_list)) { while (!grpc_closure_list_empty(exec_ctx->closure_list)) {
grpc_closure *c = exec_ctx->closure_list.head; grpc_closure *c = exec_ctx->closure_list.head;

@ -64,6 +64,7 @@ static void do_iocp_work(grpc_exec_ctx *exec_ctx) {
LPOVERLAPPED overlapped; LPOVERLAPPED overlapped;
grpc_winsocket *socket; grpc_winsocket *socket;
grpc_winsocket_callback_info *info; grpc_winsocket_callback_info *info;
grpc_closure *closure = NULL;
success = GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, success = GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key,
&overlapped, INFINITE); &overlapped, INFINITE);
/* success = 0 and overlapped = NULL means the deadline got attained. /* 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_ASSERT(!info->has_pending_iocp);
gpr_mu_lock(&socket->state_mu); gpr_mu_lock(&socket->state_mu);
if (info->closure) { if (info->closure) {
grpc_exec_ctx_enqueue(exec_ctx, info->closure, 1); closure = info->closure;
info->closure = NULL; info->closure = NULL;
} else { } else {
info->has_pending_iocp = 1; info->has_pending_iocp = 1;
} }
gpr_mu_unlock(&socket->state_mu); gpr_mu_unlock(&socket->state_mu);
if (closure) {
closure->cb(exec_ctx, closure->cb_arg, 1);
}
} }
static void iocp_loop(void *p) { static void iocp_loop(void *p) {

@ -115,6 +115,11 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
pollset->kicked_without_pollers = 0; pollset->kicked_without_pollers = 0;
} }
done: 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); gpr_cv_destroy(&worker->cv);
if (added_worker) { if (added_worker) {
remove_worker(pollset, worker); remove_worker(pollset, worker);

@ -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"); GPR_ASSERT(!s->on_accept_cb && "must add ports before starting server");
/* append it to the list under a lock */ /* append it to the list under a lock */
if (s->nports == s->port_capacity) { if (s->nports == s->port_capacity) {
s->port_capacity *= 2; /* too many ports, and we need to store their address in a closure */
s->ports = gpr_realloc(s->ports, sizeof(server_port) * s->port_capacity); /* TODO(ctiller): make server_port a linked list */
abort();
} }
sp = &s->ports[s->nports++]; sp = &s->ports[s->nports++];
sp->server = s; sp->server = s;
@ -389,6 +390,7 @@ static int add_socket_to_server(grpc_tcp_server *s, SOCKET sock,
sp->shutting_down = 0; sp->shutting_down = 0;
sp->AcceptEx = AcceptEx; sp->AcceptEx = AcceptEx;
sp->new_socket = INVALID_SOCKET; sp->new_socket = INVALID_SOCKET;
grpc_closure_init(&sp->on_accept, on_accept, sp);
GPR_ASSERT(sp->socket); GPR_ASSERT(sp->socket);
gpr_mu_unlock(&s->mu); gpr_mu_unlock(&s->mu);
} }

@ -394,7 +394,7 @@ grpc_endpoint *grpc_tcp_create(grpc_winsocket *socket, char *peer_string) {
gpr_mu_init(&tcp->mu); gpr_mu_init(&tcp->mu);
gpr_ref_init(&tcp->refcount, 1); gpr_ref_init(&tcp->refcount, 1);
grpc_closure_init(&tcp->on_read, on_read, tcp); 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); tcp->peer_string = gpr_strdup(peer_string);
return &tcp->base; return &tcp->base;
} }

@ -174,6 +174,7 @@ class Job(object):
for k, v in add_env.iteritems(): for k, v in add_env.iteritems():
env[k] = v env[k] = v
self._start = time.time() self._start = time.time()
message('START', spec.shortname, do_newline=travis)
self._process = subprocess.Popen(args=spec.cmdline, self._process = subprocess.Popen(args=spec.cmdline,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
stdout=self._tempfile, stdout=self._tempfile,
@ -185,7 +186,6 @@ class Job(object):
self._travis = travis self._travis = travis
self._xml_test = ET.SubElement(xml_report, 'testcase', self._xml_test = ET.SubElement(xml_report, 'testcase',
name=self._spec.shortname) if xml_report is not None else None name=self._spec.shortname) if xml_report is not None else None
message('START', spec.shortname, do_newline=self._travis)
def state(self, update_cache): def state(self, update_cache):
"""Poll current state of the job. Prints messages at completion.""" """Poll current state of the job. Prints messages at completion."""

Loading…
Cancel
Save