aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuchen Zeng <zyc@google.com>2016-08-24 18:28:19 -0700
committerGravatar Yuchen Zeng <zyc@google.com>2016-08-24 18:28:19 -0700
commitbbf2396a5aa179e53dffe77b4cfe0b2d8d3e5d04 (patch)
tree022374267a3b272c90627e5ecb810ca9a2082d7d /src
parent78cc066db2a2c8d65f63826f9f76f81c16d63b03 (diff)
parent0056531355a085be48418abc2ec1c5540ab3bfc0 (diff)
Merge branch 'cares_clean' into cares_buildin
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/client_config/client_channel.c2
-rw-r--r--src/core/ext/client_config/resolver.c6
-rw-r--r--src/core/ext/client_config/resolver.h7
-rw-r--r--src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c18
-rw-r--r--src/core/ext/resolver/dns/c_ares/grpc_ares_ev_dirver_windows.c5
-rw-r--r--src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h3
-rw-r--r--src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c25
-rw-r--r--src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c31
8 files changed, 16 insertions, 81 deletions
diff --git a/src/core/ext/client_config/client_channel.c b/src/core/ext/client_config/client_channel.c
index 2977639db7..2d5c995315 100644
--- a/src/core/ext/client_config/client_channel.c
+++ b/src/core/ext/client_config/client_channel.c
@@ -411,8 +411,6 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp,
if (chand->resolver != NULL && !chand->started_resolving) {
chand->started_resolving = 1;
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "resolver");
- // grpc_polling_entity_add_to_pollset_set(exec_ctx, calld->pollent,
- // chand->interested_parties);
grpc_resolver_next(exec_ctx, chand->resolver, calld->pollent,
&chand->incoming_configuration,
&chand->on_config_changed);
diff --git a/src/core/ext/client_config/resolver.c b/src/core/ext/client_config/resolver.c
index ad9d30b302..83646081b3 100644
--- a/src/core/ext/client_config/resolver.c
+++ b/src/core/ext/client_config/resolver.c
@@ -77,12 +77,6 @@ void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx,
resolver->vtable->channel_saw_error(exec_ctx, resolver);
}
-// void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
-// grpc_client_config **target_config,
-// grpc_closure *on_complete) {
-// resolver->vtable->next(exec_ctx, resolver, target_config, on_complete);
-// }
-
void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
grpc_polling_entity *pollent,
grpc_client_config **target_config,
diff --git a/src/core/ext/client_config/resolver.h b/src/core/ext/client_config/resolver.h
index fd907b2049..84182d16ac 100644
--- a/src/core/ext/client_config/resolver.h
+++ b/src/core/ext/client_config/resolver.h
@@ -53,9 +53,6 @@ struct grpc_resolver_vtable {
void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
void (*channel_saw_error)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver);
- // void (*next)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
- // grpc_client_config **target_config, grpc_closure
- // *on_complete);
void (*next)(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
grpc_polling_entity *pollent, grpc_client_config **target_config,
grpc_closure *on_complete);
@@ -92,10 +89,6 @@ void grpc_resolver_channel_saw_error(grpc_exec_ctx *exec_ctx,
If resolution is fatally broken, set *target_config to NULL and
schedule on_complete. */
-// void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
-// grpc_client_config **target_config,
-// grpc_closure *on_complete);
-
void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
grpc_polling_entity *pollent,
grpc_client_config **target_config,
diff --git a/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c b/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
index ae358149a0..dfc256c679 100644
--- a/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
+++ b/src/core/ext/resolver/dns/c_ares/dns_resolver_ares.c
@@ -152,18 +152,14 @@ static void dns_on_retry_timer(grpc_exec_ctx *exec_ctx, void *arg,
static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
- gpr_log(GPR_ERROR, "dns_on_resolved");
dns_resolver *r = arg;
grpc_client_config *config = NULL;
grpc_lb_policy *lb_policy;
- gpr_log(GPR_ERROR, "before mu");
gpr_mu_lock(&r->mu);
- gpr_log(GPR_ERROR, "after mu");
GPR_ASSERT(r->resolving);
r->resolving = 0;
grpc_resolved_addresses *addresses = r->addresses;
if (addresses != NULL) {
- gpr_log(GPR_ERROR, "addresses != NULL");
grpc_lb_policy_args lb_policy_args;
config = grpc_client_config_create();
memset(&lb_policy_args, 0, sizeof(lb_policy_args));
@@ -182,7 +178,6 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
}
grpc_resolved_addresses_destroy(addresses);
} else {
- gpr_log(GPR_ERROR, "addresses == NULL");
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
gpr_timespec timeout = gpr_time_sub(next_try, now);
@@ -208,9 +203,7 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
r->resolved_version++;
dns_maybe_finish_next_locked(exec_ctx, r);
gpr_mu_unlock(&r->mu);
- gpr_log(GPR_ERROR, "mu_unlock");
GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving");
- gpr_log(GPR_ERROR, "after GRPC_RESOLVER_UNREF");
}
static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
@@ -224,7 +217,6 @@ static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
r->target_config = target_config;
if (r->resolved_version == 0 && !r->resolving) {
gpr_backoff_reset(&r->backoff_state);
- gpr_log(GPR_ERROR, "dns_start_resolving_locked");
GRPC_RESOLVER_REF(&r->base, "dns-resolving");
GPR_ASSERT(!r->resolving);
r->resolving = 1;
@@ -235,7 +227,7 @@ static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
grpc_polling_entity_add_to_pollset_set(exec_ctx, pollent,
r->base.pollset_set);
} else {
- gpr_log(GPR_ERROR, "pollent is NULL");
+ gpr_log(GPR_DEBUG, "dns_next is called without giving a pollent");
}
grpc_resolve_address_ares(
exec_ctx, r->name, r->default_port, r->base.pollset_set,
@@ -248,21 +240,13 @@ static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
static void dns_start_resolving_locked(grpc_exec_ctx *exec_ctx,
dns_resolver *r) {
- 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;
-#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);
}
static void dns_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_dirver_windows.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_dirver_windows.c
index cd8dfbc326..4c055d90d9 100644
--- a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_dirver_windows.c
+++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_dirver_windows.c
@@ -30,5 +30,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-
+#include <grpc/support/port_platform.h>
+#ifdef GPR_WINSOCK_SOCKET
#include "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h"
+
+#endif /* GPR_WINSOCK_SOCKET */
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 25ba5e59de..8ec76f5a1b 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
@@ -46,8 +46,7 @@ typedef struct grpc_ares_ev_driver grpc_ares_ev_driver;
void grpc_ares_notify_on_event(grpc_exec_ctx *exec_ctx,
grpc_ares_ev_driver *ev_driver);
-void grpc_ares_gethostbyname(grpc_ares_ev_driver *ev_driver, const char *host,
- ares_host_callback on_done_cb, void *arg);
+
ares_channel *grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver *ev_driver);
grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver,
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 31fc7e1dfe..c918777cef 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
@@ -83,7 +83,6 @@ grpc_error *grpc_ares_ev_driver_create(grpc_ares_ev_driver **ev_driver,
}
void grpc_ares_ev_driver_destroy(grpc_ares_ev_driver *ev_driver) {
- // ev_driver->pollset_set = NULL;
ev_driver->closing = true;
}
@@ -107,9 +106,7 @@ static fd_pair *get_fd(fd_pair **head, int fd) {
static void driver_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
grpc_ares_ev_driver *d = arg;
size_t i;
- gpr_log(GPR_ERROR, "driver_cb");
if (error == GRPC_ERROR_NONE) {
- gpr_log(GPR_ERROR, "GRPC_ERROR_NONE");
for (i = 0; i < ARES_GETSOCK_MAXNUM; i++) {
ares_process_fd(
d->channel,
@@ -122,11 +119,6 @@ static void driver_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
grpc_ares_notify_on_event(exec_ctx, d);
}
-void grpc_ares_gethostbyname(grpc_ares_ev_driver *ev_driver, const char *host,
- ares_host_callback on_done_cb, void *arg) {
- ares_gethostbyname(ev_driver->channel, host, AF_UNSPEC, on_done_cb, arg);
-}
-
ares_channel *grpc_ares_ev_driver_get_channel(grpc_ares_ev_driver *ev_driver) {
return &ev_driver->channel;
}
@@ -135,7 +127,6 @@ void grpc_ares_notify_on_event(grpc_exec_ctx *exec_ctx,
grpc_ares_ev_driver *ev_driver) {
size_t i;
fd_pair *new_list = NULL;
- gpr_log(GPR_ERROR, "\n\n notify_on_event");
if (!ev_driver->closing) {
ev_driver->bitmask =
ares_getsock(ev_driver->channel, ev_driver->socks, ARES_GETSOCK_MAXNUM);
@@ -146,30 +137,22 @@ void grpc_ares_notify_on_event(grpc_exec_ctx *exec_ctx,
if (ARES_GETSOCK_READABLE(ev_driver->bitmask, i) ||
ARES_GETSOCK_WRITABLE(ev_driver->bitmask, i)) {
- gpr_log(GPR_ERROR, "%d", ev_driver->socks[i]);
fd_pair *fdp = get_fd(&ev_driver->fds, ev_driver->socks[i]);
if (!fdp) {
- gpr_log(GPR_ERROR, "new fd");
fdp = gpr_malloc(sizeof(fd_pair));
fdp->grpc_fd = grpc_fd_create(ev_driver->socks[i], final_name);
fdp->fd = ev_driver->socks[i];
grpc_pollset_set_add_fd(exec_ctx, ev_driver->pollset_set,
fdp->grpc_fd);
- // new_fd_pair->grpc_fd = fd;
- // new_fd_pair->next = ev_driver->fds;
}
fdp->next = new_list;
new_list = fdp;
if (ARES_GETSOCK_READABLE(ev_driver->bitmask, i)) {
- gpr_log(GPR_ERROR, "READABLE");
-
grpc_fd_notify_on_read(exec_ctx, fdp->grpc_fd,
&ev_driver->driver_closure);
}
if (ARES_GETSOCK_WRITABLE(ev_driver->bitmask, i)) {
- gpr_log(GPR_ERROR, "writable");
-
grpc_fd_notify_on_write(exec_ctx, fdp->grpc_fd,
&ev_driver->driver_closure);
}
@@ -183,13 +166,9 @@ void grpc_ares_notify_on_event(grpc_exec_ctx *exec_ctx,
// int fd;s
cur = ev_driver->fds;
ev_driver->fds = ev_driver->fds->next;
- gpr_log(GPR_ERROR, "fd in ev_driver: %d\n", cur->fd);
grpc_pollset_set_del_fd(exec_ctx, ev_driver->pollset_set, cur->grpc_fd);
- gpr_log(GPR_ERROR, "grpc_pollset_set_del_fd");
grpc_fd_shutdown(exec_ctx, cur->grpc_fd);
- gpr_log(GPR_ERROR, "grpc_fd_shutdown");
- grpc_fd_orphan(exec_ctx, cur->grpc_fd, NULL, NULL, "come on..");
- gpr_log(GPR_ERROR, "grpc_fd_orphan");
+ grpc_fd_orphan(exec_ctx, cur->grpc_fd, NULL, NULL, "c-ares query finished");
gpr_free(cur);
}
@@ -198,8 +177,6 @@ void grpc_ares_notify_on_event(grpc_exec_ctx *exec_ctx,
ares_destroy(ev_driver->channel);
gpr_free(ev_driver);
}
-
- gpr_log(GPR_ERROR, "eof notify_on_event");
}
#endif /* GPR_POSIX_SOCKET */
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 e1f0f34a65..7769b132bf 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
@@ -69,7 +69,6 @@ typedef struct grpc_ares_request {
grpc_closure *on_done;
grpc_resolved_addresses **addrs_out;
grpc_closure request_closure;
- void *arg;
int pending_quries;
int success;
grpc_error *error;
@@ -98,15 +97,12 @@ static uint16_t strhtons(const char *port) {
static void on_done_cb(void *arg, int status, int timeouts,
struct hostent *hostent) {
- gpr_log(GPR_ERROR, "status: %d", status);
grpc_ares_request *r = (grpc_ares_request *)arg;
- gpr_log(GPR_ERROR, "status: %s", r->name);
grpc_resolved_addresses **addresses = r->addrs_out;
size_t i;
size_t prev_naddr;
if (status == ARES_SUCCESS) {
- gpr_log(GPR_ERROR, "status ARES_SUCCESS");
GRPC_ERROR_UNREF(r->error);
r->error = GRPC_ERROR_NONE;
r->success = 1;
@@ -121,7 +117,6 @@ static void on_done_cb(void *arg, int status, int timeouts,
}
(*addresses)->naddrs += i;
- gpr_log(GPR_ERROR, "naddr: %" PRIuPTR, (*addresses)->naddrs);
(*addresses)->addrs =
gpr_realloc((*addresses)->addrs,
sizeof(grpc_resolved_address) * (*addresses)->naddrs);
@@ -130,7 +125,6 @@ static void on_done_cb(void *arg, int status, int timeouts,
memset(&(*addresses)->addrs[i], 0, sizeof(grpc_resolved_address));
if (hostent->h_addrtype == AF_INET6) {
char output[INET6_ADDRSTRLEN];
- gpr_log(GPR_ERROR, "AF_INET6");
struct sockaddr_in6 *addr;
(*addresses)->addrs[i].len = sizeof(struct sockaddr_in6);
@@ -139,13 +133,14 @@ static void on_done_cb(void *arg, int status, int timeouts,
memcpy(&addr->sin6_addr, hostent->h_addr_list[i - prev_naddr],
sizeof(struct in6_addr));
ares_inet_ntop(AF_INET6, &addr->sin6_addr, output, INET6_ADDRSTRLEN);
- gpr_log(GPR_ERROR, "addr: %s", output);
- gpr_log(GPR_ERROR, "port: %s", r->port);
+ gpr_log(GPR_DEBUG,
+ "c-ares resolver gets a AF_INET6 result: \n"
+ " addr: %s\n port: %s\n",
+ output, r->port);
addr->sin6_family = (sa_family_t)hostent->h_addrtype;
addr->sin6_port = strhtons(r->port);
} else {
char output[INET_ADDRSTRLEN];
- gpr_log(GPR_ERROR, "AF_INET");
struct sockaddr_in *addr;
(*addresses)->addrs[i].len = sizeof(struct sockaddr_in);
@@ -154,15 +149,17 @@ static void on_done_cb(void *arg, int status, int timeouts,
memcpy(&addr->sin_addr, hostent->h_addr_list[i - prev_naddr],
sizeof(struct in_addr));
ares_inet_ntop(AF_INET, &addr->sin_addr, output, INET_ADDRSTRLEN);
- gpr_log(GPR_ERROR, "addr: %s", output);
- gpr_log(GPR_ERROR, "port: %s", r->port);
+ gpr_log(GPR_DEBUG,
+ "c-ares resolver gets a AF_INET result: \n"
+ " addr: %s\n port: %s\n",
+ output, r->port);
addr->sin_family = (sa_family_t)hostent->h_addrtype;
addr->sin_port = strhtons(r->port);
}
}
// ares_destroy(r->channel);
} else if (!r->success) {
- gpr_log(GPR_ERROR, "status not ARES_SUCCESS");
+ gpr_log(GPR_DEBUG, "c-ares status not ARES_SUCCESS");
// TODO(zyc): add more error detail
if (r->error == GRPC_ERROR_NONE) {
r->error = GRPC_ERROR_CREATE("C-ares query error");
@@ -184,7 +181,6 @@ static void request_resolving_address(grpc_exec_ctx *exec_ctx, void *arg,
grpc_ares_request *r = (grpc_ares_request *)arg;
grpc_ares_ev_driver *ev_driver = r->ev_driver;
ares_channel *channel = grpc_ares_ev_driver_get_channel(ev_driver);
- gpr_log(GPR_ERROR, "before ares_gethostbyname %s", r->host);
r->pending_quries = 1;
if (grpc_ipv6_loopback_available()) {
r->pending_quries += 1;
@@ -192,9 +188,7 @@ static void request_resolving_address(grpc_exec_ctx *exec_ctx, void *arg,
}
ares_gethostbyname(*channel, r->host, AF_INET, on_done_cb, r);
// grpc_ares_gethostbyname(r->ev_driver, r->host, on_dones_cb, r);
- gpr_log(GPR_ERROR, "before ares_getsock");
grpc_ares_notify_on_event(exec_ctx, ev_driver);
- gpr_log(GPR_ERROR, "eof resolve_address_impl");
}
static int try_fake_resolve(const char *name, const char *port,
@@ -204,7 +198,6 @@ static int try_fake_resolve(const char *name, const char *port,
memset(&sa, 0, sizeof(struct sockaddr_in));
memset(&sa6, 0, sizeof(struct sockaddr_in6));
if (0 != ares_inet_pton(AF_INET, name, &(sa.sin_addr))) {
- gpr_log(GPR_ERROR, "AF_INET");
*addresses = gpr_malloc(sizeof(grpc_resolved_addresses));
(*addresses)->naddrs = 1;
(*addresses)->addrs =
@@ -216,8 +209,6 @@ static int try_fake_resolve(const char *name, const char *port,
return 1;
}
if (0 != ares_inet_pton(AF_INET6, name, &(sa6.sin6_addr))) {
- char output[INET6_ADDRSTRLEN];
- gpr_log(GPR_ERROR, "AF_INET6");
*addresses = gpr_malloc(sizeof(grpc_resolved_addresses));
(*addresses)->naddrs = 1;
(*addresses)->addrs =
@@ -226,10 +217,6 @@ static int try_fake_resolve(const char *name, const char *port,
sa6.sin6_family = AF_INET6;
sa6.sin6_port = strhtons(port);
memcpy(&(*addresses)->addrs[0].addr, &sa6, sizeof(struct sockaddr_in6));
- ares_inet_ntop(AF_INET6, &sa6.sin6_addr, output, INET6_ADDRSTRLEN);
- gpr_log(GPR_ERROR, "addr: %s", output);
- gpr_log(GPR_ERROR, "port: %s", port);
-
return 1;
}
return 0;