Print debug info

pull/9454/head
Yuchen Zeng 8 years ago
parent d10749251c
commit dc6b569d97
  1. 32
      src/core/ext/resolver/dns/c_ares/grpc_ares_wrapper.c
  2. 1
      src/core/lib/iomgr/exec_ctx.c
  3. 21
      src/core/lib/iomgr/tcp_client_posix.c

@ -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);
gpr_log(GPR_DEBUG,
"c-ares resolver gets a AF_INET6 result: \n"
" addr: %s\n port: %s\n",
output, r->port);
" addr: %s\n port: %s\n sin6_scope_id: %d\n",
output, r->port, addr->sin6_scope_id);
} else {
(*addresses)->addrs[i].len = sizeof(struct sockaddr_in);
struct sockaddr_in *addr =
@ -191,22 +191,6 @@ static void on_done_cb(void *arg, int status, int timeouts,
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,
const char *default_port,
grpc_pollset_set *interested_parties,
@ -249,9 +233,15 @@ void grpc_resolve_address_ares_impl(grpc_exec_ctx *exec_ctx, const char *name,
r->host = host;
r->success = false;
r->error = GRPC_ERROR_NONE;
grpc_closure_sched(exec_ctx, grpc_closure_create(start_resolving, r,
grpc_schedule_on_exec_ctx),
GRPC_ERROR_NONE);
ares_channel *channel = grpc_ares_ev_driver_get_channel(r->ev_driver);
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);
return;
error_cleanup:

@ -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 did_something = 0;
gpr_log(GPR_DEBUG, "grpc_exec_ctx_flush");
GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0);
for (;;) {
if (!grpc_closure_list_empty(exec_ctx->closure_list)) {

@ -35,6 +35,9 @@
#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 <errno.h>
@ -287,6 +290,24 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
*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. */
if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
addr = &addr6_v4mapped;

Loading…
Cancel
Save