diff options
author | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2015-09-16 11:01:14 -0700 |
---|---|---|
committer | Nicolas Noble <nicolasnoble@users.noreply.github.com> | 2015-09-16 11:01:14 -0700 |
commit | 34619572cbe159e4eeddfd6800b2d313e6b3583b (patch) | |
tree | 615d60725f02cae4ea067b935dc39dbc3e45d7a7 | |
parent | 9ed4be48955e3b65b0540f70060b7191d8c1eef1 (diff) | |
parent | 6728038086ca83bc161ea5f5ca01edd4a6eb2c19 (diff) |
Merge pull request #3350 from ctiller/cowabunga
Add tracing for connect latency
-rw-r--r-- | src/core/iomgr/tcp_client_posix.c | 16 | ||||
-rw-r--r-- | src/core/iomgr/tcp_server_posix.c | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/core/iomgr/tcp_client_posix.c b/src/core/iomgr/tcp_client_posix.c index c3668f6a92..07fa44ad37 100644 --- a/src/core/iomgr/tcp_client_posix.c +++ b/src/core/iomgr/tcp_client_posix.c @@ -54,6 +54,8 @@ #include <grpc/support/string_util.h> #include <grpc/support/time.h> +extern int grpc_tcp_trace; + typedef struct { void (*cb)(void *arg, grpc_endpoint *tcp); void *cb_arg; @@ -92,6 +94,10 @@ error: static void tc_on_alarm(void *acp, int success) { int done; async_connect *ac = acp; + if (grpc_tcp_trace) { + gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_alarm: success=%d", ac->addr_str, + success); + } gpr_mu_lock(&ac->mu); if (ac->fd != NULL) { grpc_fd_shutdown(ac->fd); @@ -116,6 +122,11 @@ static void on_writable(void *acp, int success) { void *cb_arg = ac->cb_arg; grpc_fd *fd; + if (grpc_tcp_trace) { + gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: on_writable: success=%d", + ac->addr_str, success); + } + gpr_mu_lock(&ac->mu); GPR_ASSERT(ac->fd); fd = ac->fd; @@ -264,6 +275,11 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep), ac->write_closure.cb = on_writable; ac->write_closure.cb_arg = ac; + if (grpc_tcp_trace) { + gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting", + ac->addr_str); + } + gpr_mu_lock(&ac->mu); grpc_alarm_init(&ac->alarm, gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c index bcbd0afe6b..a3cd3bbda2 100644 --- a/src/core/iomgr/tcp_server_posix.c +++ b/src/core/iomgr/tcp_server_posix.c @@ -339,6 +339,10 @@ static void on_read(void *arg, int success) { addr_str = grpc_sockaddr_to_uri((struct sockaddr *)&addr); gpr_asprintf(&name, "tcp-server-connection:%s", addr_str); + if (grpc_tcp_trace) { + gpr_log(GPR_DEBUG, "SERVER_CONNECT: incoming connection: %s", addr_str); + } + fdobj = grpc_fd_create(fd, name); /* TODO(ctiller): revise this when we have server-side sharding of channels -- we certainly should not be automatically adding every |