|
|
@ -54,6 +54,8 @@ |
|
|
|
#include <grpc/support/string_util.h> |
|
|
|
#include <grpc/support/string_util.h> |
|
|
|
#include <grpc/support/time.h> |
|
|
|
#include <grpc/support/time.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern int grpc_tcp_trace; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
typedef struct { |
|
|
|
void (*cb)(void *arg, grpc_endpoint *tcp); |
|
|
|
void (*cb)(void *arg, grpc_endpoint *tcp); |
|
|
|
void *cb_arg; |
|
|
|
void *cb_arg; |
|
|
@ -92,6 +94,10 @@ error: |
|
|
|
static void tc_on_alarm(void *acp, int success) { |
|
|
|
static void tc_on_alarm(void *acp, int success) { |
|
|
|
int done; |
|
|
|
int done; |
|
|
|
async_connect *ac = acp; |
|
|
|
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); |
|
|
|
gpr_mu_lock(&ac->mu); |
|
|
|
if (ac->fd != NULL) { |
|
|
|
if (ac->fd != NULL) { |
|
|
|
grpc_fd_shutdown(ac->fd); |
|
|
|
grpc_fd_shutdown(ac->fd); |
|
|
@ -116,6 +122,11 @@ static void on_writable(void *acp, int success) { |
|
|
|
void *cb_arg = ac->cb_arg; |
|
|
|
void *cb_arg = ac->cb_arg; |
|
|
|
grpc_fd *fd; |
|
|
|
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_mu_lock(&ac->mu); |
|
|
|
GPR_ASSERT(ac->fd); |
|
|
|
GPR_ASSERT(ac->fd); |
|
|
|
fd = ac->fd; |
|
|
|
fd = ac->fd; |
|
|
@ -265,6 +276,11 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep), |
|
|
|
ac->write_closure.cb = on_writable; |
|
|
|
ac->write_closure.cb = on_writable; |
|
|
|
ac->write_closure.cb_arg = ac; |
|
|
|
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); |
|
|
|
gpr_mu_lock(&ac->mu); |
|
|
|
grpc_alarm_init(&ac->alarm, |
|
|
|
grpc_alarm_init(&ac->alarm, |
|
|
|
gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), |
|
|
|
gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), |
|
|
|