aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/security/credentials/iam
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/security/credentials/iam
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/security/credentials/iam')
-rw-r--r--src/core/lib/security/credentials/iam/iam_credentials.cc22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc
index e9cf208c16..3b91e739f1 100644
--- a/src/core/lib/security/credentials/iam/iam_credentials.cc
+++ b/src/core/lib/security/credentials/iam/iam_credentials.cc
@@ -27,14 +27,12 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
-static void iam_destruct(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds) {
+static void iam_destruct(grpc_call_credentials *creds) {
grpc_google_iam_credentials *c = (grpc_google_iam_credentials *)creds;
- grpc_credentials_mdelem_array_destroy(exec_ctx, &c->md_array);
+ grpc_credentials_mdelem_array_destroy(&c->md_array);
}
-static bool iam_get_request_metadata(grpc_exec_ctx *exec_ctx,
- grpc_call_credentials *creds,
+static bool iam_get_request_metadata(grpc_call_credentials *creds,
grpc_polling_entity *pollent,
grpc_auth_metadata_context context,
grpc_credentials_mdelem_array *md_array,
@@ -46,8 +44,8 @@ static bool iam_get_request_metadata(grpc_exec_ctx *exec_ctx,
}
static void iam_cancel_get_request_metadata(
- grpc_exec_ctx *exec_ctx, grpc_call_credentials *c,
- grpc_credentials_mdelem_array *md_array, grpc_error *error) {
+ grpc_call_credentials *c, grpc_credentials_mdelem_array *md_array,
+ grpc_error *error) {
GRPC_ERROR_UNREF(error);
}
@@ -56,7 +54,7 @@ static grpc_call_credentials_vtable iam_vtable = {
grpc_call_credentials *grpc_google_iam_credentials_create(
const char *token, const char *authority_selector, void *reserved) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ ExecCtx _local_exec_ctx;
GRPC_API_TRACE(
"grpc_iam_credentials_create(token=%s, authority_selector=%s, "
"reserved=%p)",
@@ -70,17 +68,15 @@ grpc_call_credentials *grpc_google_iam_credentials_create(
c->base.vtable = &iam_vtable;
gpr_ref_init(&c->base.refcount, 1);
grpc_mdelem md = grpc_mdelem_from_slices(
- &exec_ctx,
grpc_slice_from_static_string(GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY),
grpc_slice_from_copied_string(token));
grpc_credentials_mdelem_array_add(&c->md_array, md);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
+ GRPC_MDELEM_UNREF(md);
md = grpc_mdelem_from_slices(
- &exec_ctx,
grpc_slice_from_static_string(GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY),
grpc_slice_from_copied_string(authority_selector));
grpc_credentials_mdelem_array_add(&c->md_array, md);
- GRPC_MDELEM_UNREF(&exec_ctx, md);
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_MDELEM_UNREF(md);
+ grpc_exec_ctx_finish();
return &c->base;
}