Skip to content
Snippets Groups Projects
Commit dc6b569d authored by Yuchen Zeng's avatar Yuchen Zeng
Browse files

Print debug info

parent d1074925
No related branches found
No related tags found
No related merge requests found
...@@ -156,8 +156,8 @@ static void on_done_cb(void *arg, int status, int timeouts, ...@@ -156,8 +156,8 @@ static void on_done_cb(void *arg, int status, int timeouts,
ares_inet_ntop(AF_INET6, &addr->sin6_addr, output, INET6_ADDRSTRLEN); ares_inet_ntop(AF_INET6, &addr->sin6_addr, output, INET6_ADDRSTRLEN);
gpr_log(GPR_DEBUG, gpr_log(GPR_DEBUG,
"c-ares resolver gets a AF_INET6 result: \n" "c-ares resolver gets a AF_INET6 result: \n"
" addr: %s\n port: %s\n", " addr: %s\n port: %s\n sin6_scope_id: %d\n",
output, r->port); output, r->port, addr->sin6_scope_id);
} else { } else {
(*addresses)->addrs[i].len = sizeof(struct sockaddr_in); (*addresses)->addrs[i].len = sizeof(struct sockaddr_in);
struct sockaddr_in *addr = struct sockaddr_in *addr =
...@@ -191,22 +191,6 @@ static void on_done_cb(void *arg, int status, int timeouts, ...@@ -191,22 +191,6 @@ static void on_done_cb(void *arg, int status, int timeouts,
grpc_ares_request_unref(NULL, r); grpc_ares_request_unref(NULL, r);
} }
static void start_resolving(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_ares_request *r = (grpc_ares_request *)arg;
ares_channel *channel = grpc_ares_ev_driver_get_channel(r->ev_driver);
// An extra reference is put here to avoid destroying the request in
// on_done_cb before calling grpc_ares_ev_driver_start.
gpr_ref_init(&r->pending_queries, 2);
if (grpc_ipv6_loopback_available()) {
gpr_ref(&r->pending_queries);
ares_gethostbyname(*channel, r->host, AF_INET6, on_done_cb, r);
}
ares_gethostbyname(*channel, r->host, AF_INET, on_done_cb, r);
grpc_ares_ev_driver_start(exec_ctx, r->ev_driver);
grpc_ares_request_unref(exec_ctx, r);
}
void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx, const char *name, void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx, const char *name,
const char *default_port, const char *default_port,
grpc_pollset_set *interested_parties, grpc_pollset_set *interested_parties,
...@@ -249,9 +233,15 @@ void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx, const char *name, ...@@ -249,9 +233,15 @@ void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx, const char *name,
r->host = host; r->host = host;
r->success = false; r->success = false;
r->error = GRPC_ERROR_NONE; r->error = GRPC_ERROR_NONE;
grpc_closure_sched(exec_ctx, grpc_closure_create(start_resolving, r, ares_channel *channel = grpc_ares_ev_driver_get_channel(r->ev_driver);
grpc_schedule_on_exec_ctx), gpr_ref_init(&r->pending_queries, 2);
GRPC_ERROR_NONE); if (grpc_ipv6_loopback_available()) {
gpr_ref(&r->pending_queries);
ares_gethostbyname(*channel, r->host, AF_INET6, on_done_cb, r);
}
ares_gethostbyname(*channel, r->host, AF_INET, on_done_cb, r);
grpc_ares_ev_driver_start(exec_ctx, r->ev_driver);
grpc_ares_request_unref(exec_ctx, r);
return; return;
error_cleanup: error_cleanup:
......
...@@ -64,6 +64,7 @@ bool grpc_always_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored) { ...@@ -64,6 +64,7 @@ bool grpc_always_ready_to_finish(grpc_exec_ctx *exec_ctx, void *arg_ignored) {
bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) { bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) {
bool did_something = 0; bool did_something = 0;
gpr_log(GPR_DEBUG, "grpc_exec_ctx_flush");
GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0); GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
for (;;) { for (;;) {
if (!grpc_closure_list_empty(exec_ctx->closure_list)) { if (!grpc_closure_list_empty(exec_ctx->closure_list)) {
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
#ifdef GRPC_POSIX_SOCKET #ifdef GRPC_POSIX_SOCKET
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include "src/core/lib/iomgr/tcp_client_posix.h" #include "src/core/lib/iomgr/tcp_client_posix.h"
#include <errno.h> #include <errno.h>
...@@ -287,6 +290,24 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, ...@@ -287,6 +290,24 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
*ep = NULL; *ep = NULL;
struct sockaddr_in *addr4 = (struct sockaddr_in *)addr->addr;
if (addr4->sin_family == AF_INET) {
char output[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &addr4->sin_addr, output, INET_ADDRSTRLEN);
gpr_log(GPR_DEBUG,
"native resolver gets a AF_INET result: \n"
" addr: %s\n",
output);
} else {
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr->addr;
char output[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &addr6->sin6_addr, output, INET6_ADDRSTRLEN);
gpr_log(GPR_DEBUG,
"native resolver gets a AF_INET6 result: \n"
" addr: %s\n, sin6_scope_id: %d\n",
output, addr6->sin6_scope_id);
}
/* Use dualstack sockets where available. */ /* Use dualstack sockets where available. */
if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) { if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
addr = &addr6_v4mapped; addr = &addr6_v4mapped;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment