aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/grpc/impl/codegen/port_platform.h6
-rw-r--r--src/core/ext/resolver/dns/c_ares/dns_resolver.c29
-rw-r--r--src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h5
-rw-r--r--src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c4
-rw-r--r--src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c36
-rw-r--r--src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h17
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.c12
-rw-r--r--tools/run_tests/sources_and_headers.json1
-rw-r--r--vsprojects/vcxproj/ares/ares.vcxproj1
-rw-r--r--vsprojects/vcxproj/ares/ares.vcxproj.filters3
10 files changed, 69 insertions, 45 deletions
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h
index 7c67bad5ae..933c4c97ae 100644
--- a/include/grpc/impl/codegen/port_platform.h
+++ b/include/grpc/impl/codegen/port_platform.h
@@ -431,6 +431,12 @@ typedef unsigned __int64 uint64_t;
power of two */
#define GPR_MAX_ALIGNMENT 16
+#ifdef GPR_WINDOWS
+#ifndef GRPC_NATIVE_ADDRESS_RESOLVE
+#define GRPC_NATIVE_ADDRESS_RESOLVE
+#endif
+#endif
+
#ifndef GRPC_MUST_USE_RESULT
#ifdef __GNUC__
#define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
diff --git a/src/core/ext/resolver/dns/c_ares/dns_resolver.c b/src/core/ext/resolver/dns/c_ares/dns_resolver.c
index 67c094db16..9f7b15335f 100644
--- a/src/core/ext/resolver/dns/c_ares/dns_resolver.c
+++ b/src/core/ext/resolver/dns/c_ares/dns_resolver.c
@@ -88,8 +88,6 @@ typedef struct {
/** currently resolving addresses */
grpc_resolved_addresses *addresses;
- grpc_ares_request *request;
-
grpc_polling_entity *pollent;
} dns_resolver;
@@ -229,19 +227,25 @@ static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
gpr_log(GPR_ERROR, "dns_start_resolving_locked");
GRPC_RESOLVER_REF(&r->base, "dns-resolving");
GPR_ASSERT(!r->resolving);
+ r->resolving = 1;
+ r->addresses = NULL;
+ r->pollent = NULL;
+#ifdef GRPC_NATIVE_ADDRESS_RESOLVE
+ grpc_resolve_address(exec_ctx, r->name, r->default_port,
+ grpc_closure_create(dns_on_resolved, r),
+ &r->addresses);
+#else
if (pollent) {
r->pollent = pollent;
grpc_polling_entity_add_to_pollset_set(exec_ctx, pollent,
r->base.pollset_set);
} else {
gpr_log(GPR_ERROR, "pollent is NULL");
- r->pollent = NULL;
}
- r->resolving = 1;
- r->addresses = NULL;
- r->request = grpc_resolve_address_ares(
+ grpc_resolve_address_ares(
exec_ctx, r->name, r->default_port, r->base.pollset_set,
grpc_closure_create(dns_on_resolved, r), &r->addresses);
+#endif
} else {
dns_maybe_finish_next_locked(exec_ctx, r);
}
@@ -255,9 +259,14 @@ static void dns_start_resolving_locked(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(!r->resolving);
r->resolving = 1;
r->addresses = NULL;
- r->request = grpc_resolve_address_ares(
+#ifdef GRPC_NATIVE_ADDRESS_RESOLVE
+ grpc_resolve_address(exec_ctx, r->name, r->default_port,
+ grpc_closure_create(dns_on_resolved, r), &r->addresses);
+#else
+ grpc_resolve_address_ares(
exec_ctx, r->name, r->default_port, r->base.pollset_set,
grpc_closure_create(dns_on_resolved, r), &r->addresses);
+#endif
// grpc_resolve_address(exec_ctx, r->name, r->default_port,
// grpc_closure_create(dns_on_resolved, r), &r->addresses);
}
@@ -279,7 +288,9 @@ static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
dns_resolver *r = (dns_resolver *)gr;
gpr_mu_destroy(&r->mu);
+#ifndef GRPC_NATIVE_ADDRESS_RESOLVE
grpc_ares_cleanup();
+#endif
if (r->resolved_config) {
grpc_client_config_unref(exec_ctx, r->resolved_config);
}
@@ -294,7 +305,7 @@ static grpc_resolver *dns_create(grpc_resolver_args *args,
const char *default_port,
const char *lb_policy_name) {
dns_resolver *r;
- grpc_error *error;
+ grpc_error *error = GRPC_ERROR_NONE;
const char *path = args->uri->path;
if (0 != strcmp(args->uri->authority, "")) {
@@ -302,7 +313,9 @@ static grpc_resolver *dns_create(grpc_resolver_args *args,
return NULL;
}
+#ifndef GRPC_NATIVE_ADDRESS_RESOLVE
error = grpc_ares_init();
+#endif
if (error != GRPC_ERROR_NONE) {
GRPC_LOG_IF_ERROR("ares_library_init() failed", error);
return NULL;
diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h
index 813d5aa6d7..25ba5e59de 100644
--- a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h
+++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h
@@ -34,6 +34,9 @@
#ifndef GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H
#define GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H
+#include <grpc/support/port_platform.h>
+#ifndef GRPC_NATIVE_ADDRESS_RESOLVE
+
#include <ares.h>
#include "src/core/lib/iomgr/exec_ctx.h"
@@ -51,4 +54,6 @@ grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver,
grpc_pollset_set *pollset_set);
void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver *ev_driver);
+#endif /* GRPC_NATIVE_ADDRESS_RESOLVE */
+
#endif /* GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H */
diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
index eea346e575..f7d46407b0 100644
--- a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
+++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c
@@ -31,6 +31,7 @@
*
*/
#include <grpc/support/port_platform.h>
+#ifndef GRPC_NATIVE_ADDRESS_RESOLVE
#ifdef GPR_POSIX_SOCKET
#include "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h"
@@ -201,4 +202,5 @@ void grpc_ares_notify_on_event(grpc_exec_ctx *exec_ctx,
gpr_log(GPR_ERROR, "eof notify_on_event");
}
-#endif
+#endif /* GPR_POSIX_SOCKET */
+#endif /* GRPC_NATIVE_ADDRESS_RESOLVE */
diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c
index 203c98a50e..43dbde361f 100644
--- a/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c
+++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c
@@ -32,18 +32,10 @@
*/
#include <grpc/support/port_platform.h>
-
-#ifdef GPR_POSIX_SOCKET
-#include <arpa/inet.h>
-#endif
-
-#ifdef GPR_WINSOCK_SOCKET
-#include <winsock2.h>
-#endif
+#ifndef GRPC_NATIVE_ADDRESS_RESOLVE
#include "src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h"
-// #include "src/core/lib/iomgr/ev_posix.h"
-// #include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/iomgr/sockaddr.h"
#include <string.h>
#include <sys/types.h>
@@ -67,7 +59,7 @@
static gpr_once g_basic_init = GPR_ONCE_INIT;
static gpr_mu g_init_mu;
-struct grpc_ares_request {
+typedef struct grpc_ares_request {
char *name;
char *host;
char *port;
@@ -79,7 +71,7 @@ struct grpc_ares_request {
void *arg;
int pending_quries;
grpc_ares_ev_driver *ev_driver;
-};
+} grpc_ares_request;
static void do_basic_init(void) { gpr_mu_init(&g_init_mu); }
@@ -228,10 +220,11 @@ static int try_fake_resolve(const char *name, const char *port,
return 0;
}
-grpc_ares_request *grpc_resolve_address_ares_impl(
- grpc_exec_ctx *exec_ctx, const char *name, const char *default_port,
- grpc_pollset_set *pollset_set, grpc_closure *on_done,
- grpc_resolved_addresses **addrs) {
+void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx, const char *name,
+ const char *default_port,
+ grpc_pollset_set *pollset_set,
+ grpc_closure *on_done,
+ grpc_resolved_addresses **addrs) {
char *host;
char *port;
grpc_error *err;
@@ -241,7 +234,7 @@ grpc_ares_request *grpc_resolve_address_ares_impl(
if ((err = grpc_customized_resolve_address(name, default_port, addrs)) !=
GRPC_ERROR_CANCELLED) {
grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL);
- return NULL;
+ return;
}
if (name[0] == 'u' && name[1] == 'n' && name[2] == 'i' && name[3] == 'x' &&
@@ -249,7 +242,7 @@ grpc_ares_request *grpc_resolve_address_ares_impl(
grpc_exec_ctx_sched(exec_ctx, on_done,
grpc_resolve_unix_domain_address(name + 5, addrs),
NULL);
- return NULL;
+ return;
}
/* parse name, splitting it into host and port parts */
@@ -275,7 +268,7 @@ grpc_ares_request *grpc_resolve_address_ares_impl(
err = grpc_ares_ev_driver_create(&ev_driver, pollset_set);
if (err != GRPC_ERROR_NONE) {
grpc_exec_ctx_sched(exec_ctx, on_done, err, NULL);
- return NULL;
+ return;
}
r = gpr_malloc(sizeof(grpc_ares_request));
r->ev_driver = ev_driver;
@@ -293,10 +286,9 @@ grpc_ares_request *grpc_resolve_address_ares_impl(
done:
gpr_free(host);
gpr_free(port);
- return r;
}
-grpc_ares_request *(*grpc_resolve_address_ares)(
+void (*grpc_resolve_address_ares)(
grpc_exec_ctx *exec_ctx, const char *name, const char *default_port,
grpc_pollset_set *pollset_set, grpc_closure *on_done,
grpc_resolved_addresses **addrs) = grpc_resolve_address_ares_impl;
@@ -318,3 +310,5 @@ void grpc_ares_cleanup(void) {
ares_library_cleanup();
gpr_mu_unlock(&g_init_mu);
}
+
+#endif /* GRPC_NATIVE_ADDRESS_RESOLVE */
diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h
index 5ff324e2b9..753eb12b96 100644
--- a/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h
+++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.h
@@ -34,21 +34,28 @@
#ifndef GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
#define GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H
+#include <grpc/support/port_platform.h>
+#ifndef GRPC_NATIVE_ADDRESS_RESOLVE
+
#include <stddef.h>
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/iomgr/resolve_address.h"
-typedef struct grpc_ares_request grpc_ares_request;
+// typedef struct grpc_ares_request grpc_ares_request;
-extern grpc_ares_request *(*grpc_resolve_address_ares)(
- grpc_exec_ctx *exec_ctx, const char *addr, const char *default_port,
- grpc_pollset_set *pollset_set, grpc_closure *on_done,
- grpc_resolved_addresses **addresses);
+extern void (*grpc_resolve_address_ares)(grpc_exec_ctx *exec_ctx,
+ const char *addr,
+ const char *default_port,
+ grpc_pollset_set *pollset_set,
+ grpc_closure *on_done,
+ grpc_resolved_addresses **addresses);
grpc_error *grpc_ares_init(void);
void grpc_ares_cleanup(void);
+#endif /* GRPC_NATIVE_ADDRESS_RESOLVE */
+
#endif /* GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_WRAPPER_H */
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c
index 5231105c54..a7f4ca55b0 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.c
+++ b/test/core/end2end/fuzzers/api_fuzzer.c
@@ -226,12 +226,12 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
finish_resolve, r, gpr_now(GPR_CLOCK_MONOTONIC));
}
-grpc_ares_request *my_resolve_address_async(
- grpc_exec_ctx *exec_ctx, const char *addr, const char *default_port,
- grpc_pollset_set *pollset_set, grpc_closure *on_done,
- grpc_resolved_addresses **addresses) {
+void my_resolve_address_async(grpc_exec_ctx *exec_ctx, const char *addr,
+ const char *default_port,
+ grpc_pollset_set *pollset_set,
+ grpc_closure *on_done,
+ grpc_resolved_addresses **addresses) {
my_resolve_address(exec_ctx, addr, default_port, on_done, addresses);
- return NULL;
}
////////////////////////////////////////////////////////////////////////////////
@@ -516,7 +516,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
input_stream inp = {data, data + size};
grpc_resolve_address = my_resolve_address;
+#ifndef GRPC_NATIVE_ADDRESS_RESOLVE
grpc_resolve_address_ares = my_resolve_address_async;
+#endif
grpc_tcp_client_connect_impl = my_tcp_client_connect;
gpr_now_impl = now_impl;
grpc_init();
diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json
index a1ab743c69..a186f55b55 100644
--- a/tools/run_tests/sources_and_headers.json
+++ b/tools/run_tests/sources_and_headers.json
@@ -5409,7 +5409,6 @@
"third_party/c-ares/ares_strdup.h",
"third_party/c-ares/ares_version.h",
"third_party/c-ares/bitncmp.h",
- "third_party/c-ares/selectbridge.h",
"third_party/c-ares/setup_once.h"
],
"language": "c",
diff --git a/vsprojects/vcxproj/ares/ares.vcxproj b/vsprojects/vcxproj/ares/ares.vcxproj
index d6ad8edf28..eb2f369d83 100644
--- a/vsprojects/vcxproj/ares/ares.vcxproj
+++ b/vsprojects/vcxproj/ares/ares.vcxproj
@@ -166,7 +166,6 @@
<ClInclude Include="$(SolutionDir)\..\third_party\c-ares\ares_strdup.h" />
<ClInclude Include="$(SolutionDir)\..\third_party\c-ares\ares_version.h" />
<ClInclude Include="$(SolutionDir)\..\third_party\c-ares\bitncmp.h" />
- <ClInclude Include="$(SolutionDir)\..\third_party\c-ares\selectbridge.h" />
<ClInclude Include="$(SolutionDir)\..\third_party\c-ares\setup_once.h" />
<ClInclude Include="$(SolutionDir)\..\src\c-ares\ares_build.h" />
<ClInclude Include="$(SolutionDir)\..\src\c-ares\config_linux\ares_config.h" />
diff --git a/vsprojects/vcxproj/ares/ares.vcxproj.filters b/vsprojects/vcxproj/ares/ares.vcxproj.filters
index e935e211fe..b733289163 100644
--- a/vsprojects/vcxproj/ares/ares.vcxproj.filters
+++ b/vsprojects/vcxproj/ares/ares.vcxproj.filters
@@ -207,9 +207,6 @@
<ClInclude Include="$(SolutionDir)\..\third_party\c-ares\bitncmp.h">
<Filter>third_party\c-ares</Filter>
</ClInclude>
- <ClInclude Include="$(SolutionDir)\..\third_party\c-ares\selectbridge.h">
- <Filter>third_party\c-ares</Filter>
- </ClInclude>
<ClInclude Include="$(SolutionDir)\..\third_party\c-ares\setup_once.h">
<Filter>third_party\c-ares</Filter>
</ClInclude>