From b49736829a3e9bf4140b17465ff6c208462e783f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 30 Jun 2015 08:15:08 -0700 Subject: [PATCH] Fix pollset_set handling in tcp_client_posix --- src/core/iomgr/tcp_client_posix.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/iomgr/tcp_client_posix.c b/src/core/iomgr/tcp_client_posix.c index bbf7711588f..20f833e28b9 100644 --- a/src/core/iomgr/tcp_client_posix.c +++ b/src/core/iomgr/tcp_client_posix.c @@ -63,6 +63,7 @@ typedef struct { grpc_alarm alarm; int refs; grpc_iomgr_closure write_closure; + grpc_pollset_set *interested_parties; } async_connect; static int prepare_socket(const struct sockaddr *addr, int fd) { @@ -152,6 +153,7 @@ static void on_writable(void *acp, int success) { goto finish; } } else { + grpc_pollset_set_del_fd(ac->interested_parties, ac->fd); ep = grpc_tcp_create(ac->fd, GRPC_TCP_DEFAULT_READ_SLICE_SIZE); goto finish; } @@ -164,10 +166,13 @@ static void on_writable(void *acp, int success) { finish: gpr_mu_lock(&ac->mu); + gpr_log(GPR_DEBUG, "ep=%p", ep); if (!ep) { + grpc_pollset_set_del_fd(ac->interested_parties, ac->fd); grpc_fd_orphan(ac->fd, NULL, "tcp_client_orphan"); } done = (--ac->refs == 0); + gpr_log(GPR_DEBUG, "refs=%d", ac->refs); gpr_mu_unlock(&ac->mu); if (done) { gpr_mu_destroy(&ac->mu); @@ -240,6 +245,7 @@ void grpc_tcp_client_connect(void (*cb)(void *arg, grpc_endpoint *ep), ac->cb = cb; ac->cb_arg = arg; ac->fd = fdobj; + ac->interested_parties = interested_parties; gpr_mu_init(&ac->mu); ac->refs = 2; ac->write_closure.cb = on_writable;