diff options
author | David Garcia Quintas <dgq@google.com> | 2015-10-13 11:19:49 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-10-13 14:18:06 -0700 |
commit | 706b70f4986df8b69a680d1feb8c6bb4d585bd03 (patch) | |
tree | 9fa98cc927637b3ae6c542151a1748602d8842cd /src | |
parent | 9e76e7aa3a0d6a8fe95b159177c839f32f3acabb (diff) |
Updated Windows resolver
Diffstat (limited to 'src')
-rw-r--r-- | src/core/iomgr/resolve_address_windows.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/core/iomgr/resolve_address_windows.c b/src/core/iomgr/resolve_address_windows.c index 82a5602996..6dc5de1660 100644 --- a/src/core/iomgr/resolve_address_windows.c +++ b/src/core/iomgr/resolve_address_windows.c @@ -40,6 +40,7 @@ #include <sys/types.h> #include <string.h> +#include "src/core/iomgr/executor.h" #include "src/core/iomgr/iomgr_internal.h" #include "src/core/iomgr/sockaddr_utils.h" #include "src/core/support/block_annotate.h" @@ -55,8 +56,8 @@ typedef struct { char *name; char *default_port; grpc_resolve_cb cb; + grpc_closure request_closure; void *arg; - grpc_iomgr_object iomgr_object; } request; grpc_resolved_addresses *grpc_blocking_resolve_address( @@ -129,9 +130,9 @@ done: return addrs; } -/* Thread function to asynch-ify grpc_blocking_resolve_address */ -static void do_request(void *rp) { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; +/* Callback to be passed to grpc_executor to asynch-ify + * grpc_blocking_resolve_address */ +static void do_request_thread(grpc_exec_ctx *exec_ctx, void *rp, int success) { request *r = rp; grpc_resolved_addresses *resolved = grpc_blocking_resolve_address(r->name, r->default_port); @@ -139,10 +140,8 @@ static void do_request(void *rp) { grpc_resolve_cb cb = r->cb; gpr_free(r->name); gpr_free(r->default_port); - grpc_iomgr_unregister_object(&r->iomgr_object); + cb(exec_ctx, arg, resolved); gpr_free(r); - cb(&exec_ctx, arg, resolved); - grpc_exec_ctx_finish(&exec_ctx); } void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) { @@ -153,16 +152,12 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addrs) { void grpc_resolve_address(const char *name, const char *default_port, grpc_resolve_cb cb, void *arg) { request *r = gpr_malloc(sizeof(request)); - gpr_thd_id id; - char *label; - gpr_asprintf(&label, "resolve:%s", name); - grpc_iomgr_register_object(&r->iomgr_object, label); - gpr_free(label); + grpc_closure_init(&r->request_closure, do_request_thread, r); r->name = gpr_strdup(name); r->default_port = gpr_strdup(default_port); r->cb = cb; r->arg = arg; - gpr_thd_new(&id, do_request, r, NULL); + grpc_executor_enqueue(&r->request_closure, 1); } #endif |