Skip to content
Snippets Groups Projects
Commit 258f8de8 authored by Craig Tiller's avatar Craig Tiller
Browse files

Windows fixes

parent 5c1ad056
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,8 @@ ...@@ -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) { ...@@ -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) { ...@@ -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, ...@@ -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, ...@@ -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, ...@@ -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) { ...@@ -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): ...@@ -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): ...@@ -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."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment