aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr/tcp_client_windows.cc
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-10-13 16:07:13 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-10-18 17:12:19 -0700
commit0ee7574732a06e8cace4e099a678f4bd5dbff679 (patch)
treee43d5de442fdcc3d39cd5af687f319fa39612d3f /src/core/lib/iomgr/tcp_client_windows.cc
parent6bf5f833efe2cb9e2ecc14358dd9699cd5d05263 (diff)
Removing instances of exec_ctx being passed around in functions in
src/core. exec_ctx is now a thread_local pointer of type ExecCtx instead of grpc_exec_ctx which is initialized whenever ExecCtx is instantiated. ExecCtx also keeps track of the previous exec_ctx so that nesting of exec_ctx is allowed. This means that there is only one exec_ctx being used at any time. Also, grpc_exec_ctx_finish is called in the destructor of the object, and the previous exec_ctx is restored to avoid breaking current functionality. The code still explicitly calls grpc_exec_ctx_finish because removing all such instances causes the code to break.
Diffstat (limited to 'src/core/lib/iomgr/tcp_client_windows.cc')
-rw-r--r--src/core/lib/iomgr/tcp_client_windows.cc45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/core/lib/iomgr/tcp_client_windows.cc b/src/core/lib/iomgr/tcp_client_windows.cc
index 9adf7ee4e9..94ae9365f0 100644
--- a/src/core/lib/iomgr/tcp_client_windows.cc
+++ b/src/core/lib/iomgr/tcp_client_windows.cc
@@ -52,13 +52,12 @@ typedef struct {
grpc_channel_args *channel_args;
} async_connect;
-static void async_connect_unlock_and_cleanup(grpc_exec_ctx *exec_ctx,
- async_connect *ac,
+static void async_connect_unlock_and_cleanup(async_connect *ac,
grpc_winsocket *socket) {
int done = (--ac->refs == 0);
gpr_mu_unlock(&ac->mu);
if (done) {
- grpc_channel_args_destroy(exec_ctx, ac->channel_args);
+ grpc_channel_args_destroy(ac->channel_args);
gpr_mu_destroy(&ac->mu);
gpr_free(ac->addr_name);
gpr_free(ac);
@@ -66,7 +65,7 @@ static void async_connect_unlock_and_cleanup(grpc_exec_ctx *exec_ctx,
if (socket != NULL) grpc_winsocket_destroy(socket);
}
-static void on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
+static void on_alarm(void *acp, grpc_error *error) {
async_connect *ac = (async_connect *)acp;
gpr_mu_lock(&ac->mu);
grpc_winsocket *socket = ac->socket;
@@ -74,10 +73,10 @@ static void on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
if (socket != NULL) {
grpc_winsocket_shutdown(socket);
}
- async_connect_unlock_and_cleanup(exec_ctx, ac, socket);
+ async_connect_unlock_and_cleanup(ac, socket);
}
-static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
+static void on_connect(void *acp, grpc_error *error) {
async_connect *ac = (async_connect *)acp;
grpc_endpoint **ep = ac->endpoint;
GPR_ASSERT(*ep == NULL);
@@ -90,7 +89,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
ac->socket = NULL;
gpr_mu_unlock(&ac->mu);
- grpc_timer_cancel(exec_ctx, &ac->alarm);
+ grpc_timer_cancel(&ac->alarm);
gpr_mu_lock(&ac->mu);
@@ -105,8 +104,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
if (!wsa_success) {
error = GRPC_WSA_ERROR(WSAGetLastError(), "ConnectEx");
} else {
- *ep =
- grpc_tcp_create(exec_ctx, socket, ac->channel_args, ac->addr_name);
+ *ep = grpc_tcp_create(socket, ac->channel_args, ac->addr_name);
socket = NULL;
}
} else {
@@ -114,18 +112,20 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
}
}
- async_connect_unlock_and_cleanup(exec_ctx, ac, socket);
+ async_connect_unlock_and_cleanup(ac, socket);
/* If the connection was aborted, the callback was already called when
the deadline was met. */
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, error);
+ GRPC_CLOSURE_SCHED(on_done, error);
}
/* Tries to issue one async connection, then schedules both an IOCP
notification request for the connection, and one timeout alert. */
-static void tcp_client_connect_impl(
- grpc_exec_ctx *exec_ctx, grpc_closure *on_done, grpc_endpoint **endpoint,
- grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
- const grpc_resolved_address *addr, grpc_millis deadline) {
+static void tcp_client_connect_impl(grpc_closure *on_done,
+ grpc_endpoint **endpoint,
+ grpc_pollset_set *interested_parties,
+ const grpc_channel_args *channel_args,
+ const grpc_resolved_address *addr,
+ grpc_millis deadline) {
SOCKET sock = INVALID_SOCKET;
BOOL success;
int status;
@@ -205,8 +205,8 @@ static void tcp_client_connect_impl(
GRPC_CLOSURE_INIT(&ac->on_connect, on_connect, ac, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&ac->on_alarm, on_alarm, ac, grpc_schedule_on_exec_ctx);
- grpc_timer_init(exec_ctx, &ac->alarm, deadline, &ac->on_alarm);
- grpc_socket_notify_on_write(exec_ctx, socket, &ac->on_connect);
+ grpc_timer_init(&ac->alarm, deadline, &ac->on_alarm);
+ grpc_socket_notify_on_write(socket, &ac->on_connect);
return;
failure:
@@ -222,26 +222,25 @@ failure:
} else if (sock != INVALID_SOCKET) {
closesocket(sock);
}
- GRPC_CLOSURE_SCHED(exec_ctx, on_done, final_error);
+ GRPC_CLOSURE_SCHED(on_done, final_error);
}
// overridden by api_fuzzer.c
extern "C" {
void (*grpc_tcp_client_connect_impl)(
- grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
+ grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
const grpc_resolved_address *addr,
grpc_millis deadline) = tcp_client_connect_impl;
}
-void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
- grpc_endpoint **ep,
+void grpc_tcp_client_connect(grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties,
const grpc_channel_args *channel_args,
const grpc_resolved_address *addr,
grpc_millis deadline) {
- grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
- channel_args, addr, deadline);
+ grpc_tcp_client_connect_impl(closure, ep, interested_parties, channel_args,
+ addr, deadline);
}
#endif /* GRPC_WINSOCK_SOCKET */