aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/security
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lib/security')
-rw-r--r--src/core/lib/security/context/security_context.cc17
-rw-r--r--src/core/lib/security/credentials/composite/composite_credentials.cc51
-rw-r--r--src/core/lib/security/credentials/credentials.cc73
-rw-r--r--src/core/lib/security/credentials/credentials.h59
-rw-r--r--src/core/lib/security/credentials/credentials_metadata.cc4
-rw-r--r--src/core/lib/security/credentials/fake/fake_credentials.cc36
-rw-r--r--src/core/lib/security/credentials/google_default/google_default_credentials.cc58
-rw-r--r--src/core/lib/security/credentials/iam/iam_credentials.cc22
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.cc34
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_credentials.h3
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.cc126
-rw-r--r--src/core/lib/security/credentials/jwt/jwt_verifier.h14
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.cc102
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.h7
-rw-r--r--src/core/lib/security/credentials/plugin/plugin_credentials.cc51
-rw-r--r--src/core/lib/security/credentials/ssl/ssl_credentials.cc21
-rw-r--r--src/core/lib/security/transport/client_auth_filter.cc85
-rw-r--r--src/core/lib/security/transport/lb_targets_info.cc4
-rw-r--r--src/core/lib/security/transport/secure_endpoint.cc120
-rw-r--r--src/core/lib/security/transport/security_connector.cc144
-rw-r--r--src/core/lib/security/transport/security_connector.h53
-rw-r--r--src/core/lib/security/transport/security_handshaker.cc189
-rw-r--r--src/core/lib/security/transport/security_handshaker.h3
-rw-r--r--src/core/lib/security/transport/server_auth_filter.cc55
24 files changed, 576 insertions, 755 deletions
diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc
index 19c6148e43..0371027994 100644
--- a/src/core/lib/security/context/security_context.cc
+++ b/src/core/lib/security/context/security_context.cc
@@ -36,7 +36,7 @@ grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount(
grpc_call_error grpc_call_set_credentials(grpc_call* call,
grpc_call_credentials* creds) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_client_security_context* ctx = nullptr;
GRPC_API_TRACE("grpc_call_set_credentials(call=%p, creds=%p)", 2,
(call, creds));
@@ -52,10 +52,10 @@ grpc_call_error grpc_call_set_credentials(grpc_call* call,
grpc_call_context_set(call, GRPC_CONTEXT_SECURITY, ctx,
grpc_client_security_context_destroy);
} else {
- grpc_call_credentials_unref(&exec_ctx, ctx->creds);
+ grpc_call_credentials_unref(ctx->creds);
ctx->creds = grpc_call_credentials_ref(creds);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return GRPC_CALL_OK;
}
@@ -85,15 +85,14 @@ grpc_client_security_context* grpc_client_security_context_create(void) {
}
void grpc_client_security_context_destroy(void* ctx) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_client_security_context* c = (grpc_client_security_context*)ctx;
- grpc_call_credentials_unref(&exec_ctx, c->creds);
+ grpc_call_credentials_unref(c->creds);
GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "client_security_context");
if (c->extension.instance != nullptr && c->extension.destroy != nullptr) {
c->extension.destroy(c->extension.instance);
}
gpr_free(ctx);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* --- grpc_server_security_context --- */
@@ -141,7 +140,7 @@ grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* ctx,
}
#else
grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* ctx) {
- if (ctx == NULL) return NULL;
+ if (ctx == nullptr) return nullptr;
#endif
gpr_ref(&ctx->refcount);
return ctx;
@@ -159,7 +158,7 @@ void grpc_auth_context_unref(grpc_auth_context* ctx, const char* file, int line,
}
#else
void grpc_auth_context_unref(grpc_auth_context* ctx) {
- if (ctx == NULL) return;
+ if (ctx == nullptr) return;
#endif
if (gpr_unref(&ctx->refcount)) {
size_t i;
@@ -303,7 +302,7 @@ void grpc_auth_property_reset(grpc_auth_property* property) {
memset(property, 0, sizeof(grpc_auth_property));
}
-static void auth_context_pointer_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
+static void auth_context_pointer_arg_destroy(void* p) {
GRPC_AUTH_CONTEXT_UNREF((grpc_auth_context*)p, "auth_context_pointer_arg");
}
diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc
index 93dd721240..e4c1604795 100644
--- a/src/core/lib/security/credentials/composite/composite_credentials.cc
+++ b/src/core/lib/security/credentials/composite/composite_credentials.cc
@@ -39,17 +39,15 @@ typedef struct {
grpc_closure internal_on_request_metadata;
} grpc_composite_call_credentials_metadata_context;
-static void composite_call_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void composite_call_destruct(grpc_call_credentials* creds) {
grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
for (size_t i = 0; i < c->inner.num_creds; i++) {
- grpc_call_credentials_unref(exec_ctx, c->inner.creds_array[i]);
+ grpc_call_credentials_unref(c->inner.creds_array[i]);
}
gpr_free(c->inner.creds_array);
}
-static void composite_call_metadata_cb(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void composite_call_metadata_cb(void* arg, grpc_error* error) {
grpc_composite_call_credentials_metadata_context* ctx =
(grpc_composite_call_credentials_metadata_context*)arg;
if (error == GRPC_ERROR_NONE) {
@@ -58,23 +56,23 @@ static void composite_call_metadata_cb(grpc_exec_ctx* exec_ctx, void* arg,
grpc_call_credentials* inner_creds =
ctx->composite_creds->inner.creds_array[ctx->creds_index++];
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, inner_creds, ctx->pollent, ctx->auth_md_context,
- ctx->md_array, &ctx->internal_on_request_metadata, &error)) {
+ inner_creds, ctx->pollent, ctx->auth_md_context, ctx->md_array,
+ &ctx->internal_on_request_metadata, &error)) {
// Synchronous response, so call ourselves recursively.
- composite_call_metadata_cb(exec_ctx, arg, error);
+ composite_call_metadata_cb(arg, error);
GRPC_ERROR_UNREF(error);
}
return;
}
// We're done!
}
- GRPC_CLOSURE_SCHED(exec_ctx, ctx->on_request_metadata, GRPC_ERROR_REF(error));
+ GRPC_CLOSURE_SCHED(ctx->on_request_metadata, GRPC_ERROR_REF(error));
gpr_free(ctx);
}
static bool composite_call_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context auth_md_context,
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context auth_md_context,
grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
grpc_error** error) {
grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
@@ -93,8 +91,8 @@ static bool composite_call_get_request_metadata(
grpc_call_credentials* inner_creds =
ctx->composite_creds->inner.creds_array[ctx->creds_index++];
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, inner_creds, ctx->pollent, ctx->auth_md_context,
- ctx->md_array, &ctx->internal_on_request_metadata, error)) {
+ inner_creds, ctx->pollent, ctx->auth_md_context, ctx->md_array,
+ &ctx->internal_on_request_metadata, error)) {
if (*error != GRPC_ERROR_NONE) break;
} else {
synchronous = false; // Async return.
@@ -106,12 +104,12 @@ static bool composite_call_get_request_metadata(
}
static void composite_call_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
grpc_composite_call_credentials* c = (grpc_composite_call_credentials*)creds;
for (size_t i = 0; i < c->inner.num_creds; ++i) {
grpc_call_credentials_cancel_get_request_metadata(
- exec_ctx, c->inner.creds_array[i], md_array, GRPC_ERROR_REF(error));
+ c->inner.creds_array[i], md_array, GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
}
@@ -200,19 +198,17 @@ grpc_call_credentials* grpc_credentials_contains_type(
/* -- Composite channel credentials. -- */
-static void composite_channel_destruct(grpc_exec_ctx* exec_ctx,
- grpc_channel_credentials* creds) {
+static void composite_channel_destruct(grpc_channel_credentials* creds) {
grpc_composite_channel_credentials* c =
(grpc_composite_channel_credentials*)creds;
- grpc_channel_credentials_unref(exec_ctx, c->inner_creds);
- grpc_call_credentials_unref(exec_ctx, c->call_creds);
+ grpc_channel_credentials_unref(c->inner_creds);
+ grpc_call_credentials_unref(c->call_creds);
}
static grpc_security_status composite_channel_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* creds,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* creds, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
grpc_composite_channel_credentials* c =
(grpc_composite_channel_credentials*)creds;
grpc_security_status status = GRPC_SECURITY_ERROR;
@@ -227,12 +223,11 @@ static grpc_security_status composite_channel_create_security_connector(
grpc_composite_call_credentials_create(c->call_creds, call_creds,
nullptr);
status = c->inner_creds->vtable->create_security_connector(
- exec_ctx, c->inner_creds, composite_call_creds, target, args, sc,
- new_args);
- grpc_call_credentials_unref(exec_ctx, composite_call_creds);
+ c->inner_creds, composite_call_creds, target, args, sc, new_args);
+ grpc_call_credentials_unref(composite_call_creds);
} else {
status = c->inner_creds->vtable->create_security_connector(
- exec_ctx, c->inner_creds, c->call_creds, target, args, sc, new_args);
+ c->inner_creds, c->call_creds, target, args, sc, new_args);
}
return status;
}
diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc
index 90576e69b9..48b459e1be 100644
--- a/src/core/lib/security/credentials/credentials.cc
+++ b/src/core/lib/security/credentials/credentials.cc
@@ -47,8 +47,8 @@ grpc_credentials_metadata_request* grpc_credentials_metadata_request_create(
}
void grpc_credentials_metadata_request_destroy(
- grpc_exec_ctx* exec_ctx, grpc_credentials_metadata_request* r) {
- grpc_call_credentials_unref(exec_ctx, r->creds);
+ grpc_credentials_metadata_request* r) {
+ grpc_call_credentials_unref(r->creds);
grpc_http_response_destroy(&r->response);
gpr_free(r);
}
@@ -60,12 +60,11 @@ grpc_channel_credentials* grpc_channel_credentials_ref(
return creds;
}
-void grpc_channel_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_channel_credentials* creds) {
+void grpc_channel_credentials_unref(grpc_channel_credentials* creds) {
if (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
if (creds->vtable->destruct != nullptr) {
- creds->vtable->destruct(exec_ctx, creds);
+ creds->vtable->destruct(creds);
}
gpr_free(creds);
}
@@ -73,9 +72,8 @@ void grpc_channel_credentials_unref(grpc_exec_ctx* exec_ctx,
void grpc_channel_credentials_release(grpc_channel_credentials* creds) {
GRPC_API_TRACE("grpc_channel_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_channel_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_channel_credentials_unref(creds);
}
grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds) {
@@ -84,12 +82,11 @@ grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds) {
return creds;
}
-void grpc_call_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+void grpc_call_credentials_unref(grpc_call_credentials* creds) {
if (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
if (creds->vtable->destruct != nullptr) {
- creds->vtable->destruct(exec_ctx, creds);
+ creds->vtable->destruct(creds);
}
gpr_free(creds);
}
@@ -97,44 +94,42 @@ void grpc_call_credentials_unref(grpc_exec_ctx* exec_ctx,
void grpc_call_credentials_release(grpc_call_credentials* creds) {
GRPC_API_TRACE("grpc_call_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_call_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_call_credentials_unref(creds);
}
bool grpc_call_credentials_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error) {
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
if (creds == nullptr || creds->vtable->get_request_metadata == nullptr) {
return true;
}
- return creds->vtable->get_request_metadata(
- exec_ctx, creds, pollent, context, md_array, on_request_metadata, error);
+ return creds->vtable->get_request_metadata(creds, pollent, context, md_array,
+ on_request_metadata, error);
}
void grpc_call_credentials_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
if (creds == nullptr ||
creds->vtable->cancel_get_request_metadata == nullptr) {
return;
}
- creds->vtable->cancel_get_request_metadata(exec_ctx, creds, md_array, error);
+ creds->vtable->cancel_get_request_metadata(creds, md_array, error);
}
grpc_security_status grpc_channel_credentials_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* channel_creds,
- const char* target, const grpc_channel_args* args,
- grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
+ grpc_channel_credentials* channel_creds, const char* target,
+ const grpc_channel_args* args, grpc_channel_security_connector** sc,
+ grpc_channel_args** new_args) {
*new_args = nullptr;
if (channel_creds == nullptr) {
return GRPC_SECURITY_ERROR;
}
GPR_ASSERT(channel_creds->vtable->create_security_connector != nullptr);
return channel_creds->vtable->create_security_connector(
- exec_ctx, channel_creds, nullptr, target, args, sc, new_args);
+ channel_creds, nullptr, target, args, sc, new_args);
}
grpc_channel_credentials*
@@ -149,8 +144,8 @@ grpc_channel_credentials_duplicate_without_call_credentials(
}
}
-static void credentials_pointer_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
- grpc_channel_credentials_unref(exec_ctx, (grpc_channel_credentials*)p);
+static void credentials_pointer_arg_destroy(void* p) {
+ grpc_channel_credentials_unref((grpc_channel_credentials*)p);
}
static void* credentials_pointer_arg_copy(void* p) {
@@ -200,12 +195,11 @@ grpc_server_credentials* grpc_server_credentials_ref(
return creds;
}
-void grpc_server_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_server_credentials* creds) {
+void grpc_server_credentials_unref(grpc_server_credentials* creds) {
if (creds == nullptr) return;
if (gpr_unref(&creds->refcount)) {
if (creds->vtable->destruct != nullptr) {
- creds->vtable->destruct(exec_ctx, creds);
+ creds->vtable->destruct(creds);
}
if (creds->processor.destroy != nullptr &&
creds->processor.state != nullptr) {
@@ -217,19 +211,17 @@ void grpc_server_credentials_unref(grpc_exec_ctx* exec_ctx,
void grpc_server_credentials_release(grpc_server_credentials* creds) {
GRPC_API_TRACE("grpc_server_credentials_release(creds=%p)", 1, (creds));
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_server_credentials_unref(&exec_ctx, creds);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_core::ExecCtx exec_ctx;
+ grpc_server_credentials_unref(creds);
}
grpc_security_status grpc_server_credentials_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* creds,
- grpc_server_security_connector** sc) {
+ grpc_server_credentials* creds, grpc_server_security_connector** sc) {
if (creds == nullptr || creds->vtable->create_security_connector == nullptr) {
gpr_log(GPR_ERROR, "Server credentials cannot create security context.");
return GRPC_SECURITY_ERROR;
}
- return creds->vtable->create_security_connector(exec_ctx, creds, sc);
+ return creds->vtable->create_security_connector(creds, sc);
}
void grpc_server_credentials_set_auth_metadata_processor(
@@ -247,9 +239,8 @@ void grpc_server_credentials_set_auth_metadata_processor(
creds->processor = processor;
}
-static void server_credentials_pointer_arg_destroy(grpc_exec_ctx* exec_ctx,
- void* p) {
- grpc_server_credentials_unref(exec_ctx, (grpc_server_credentials*)p);
+static void server_credentials_pointer_arg_destroy(void* p) {
+ grpc_server_credentials_unref((grpc_server_credentials*)p);
}
static void* server_credentials_pointer_arg_copy(void* p) {
diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h
index bc1bd11c77..4825b65720 100644
--- a/src/core/lib/security/credentials/credentials.h
+++ b/src/core/lib/security/credentials/credentials.h
@@ -88,13 +88,12 @@ void grpc_override_well_known_credentials_path_getter(
#define GRPC_ARG_CHANNEL_CREDENTIALS "grpc.channel_credentials"
typedef struct {
- void (*destruct)(grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c);
+ void (*destruct)(grpc_channel_credentials* c);
grpc_security_status (*create_security_connector)(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args);
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args);
grpc_channel_credentials* (*duplicate_without_call_credentials)(
grpc_channel_credentials* c);
@@ -108,17 +107,16 @@ struct grpc_channel_credentials {
grpc_channel_credentials* grpc_channel_credentials_ref(
grpc_channel_credentials* creds);
-void grpc_channel_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_channel_credentials* creds);
+void grpc_channel_credentials_unref(grpc_channel_credentials* creds);
/* Creates a security connector for the channel. May also create new channel
args for the channel to be used in place of the passed in const args if
returned non NULL. In that case the caller is responsible for destroying
new_args after channel creation. */
grpc_security_status grpc_channel_credentials_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* creds,
- const char* target, const grpc_channel_args* args,
- grpc_channel_security_connector** sc, grpc_channel_args** new_args);
+ grpc_channel_credentials* creds, const char* target,
+ const grpc_channel_args* args, grpc_channel_security_connector** sc,
+ grpc_channel_args** new_args);
/* Creates a version of the channel credentials without any attached call
credentials. This can be used in order to open a channel to a non-trusted
@@ -153,22 +151,19 @@ void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array* list,
void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array* dst,
grpc_credentials_mdelem_array* src);
-void grpc_credentials_mdelem_array_destroy(grpc_exec_ctx* exec_ctx,
- grpc_credentials_mdelem_array* list);
+void grpc_credentials_mdelem_array_destroy(grpc_credentials_mdelem_array* list);
/* --- grpc_call_credentials. --- */
typedef struct {
- void (*destruct)(grpc_exec_ctx* exec_ctx, grpc_call_credentials* c);
- bool (*get_request_metadata)(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* c,
+ void (*destruct)(grpc_call_credentials* c);
+ bool (*get_request_metadata)(grpc_call_credentials* c,
grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
grpc_credentials_mdelem_array* md_array,
grpc_closure* on_request_metadata,
grpc_error** error);
- void (*cancel_get_request_metadata)(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* c,
+ void (*cancel_get_request_metadata)(grpc_call_credentials* c,
grpc_credentials_mdelem_array* md_array,
grpc_error* error);
} grpc_call_credentials_vtable;
@@ -180,39 +175,35 @@ struct grpc_call_credentials {
};
grpc_call_credentials* grpc_call_credentials_ref(grpc_call_credentials* creds);
-void grpc_call_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds);
+void grpc_call_credentials_unref(grpc_call_credentials* creds);
/// Returns true if completed synchronously, in which case \a error will
/// be set to indicate the result. Otherwise, \a on_request_metadata will
/// be invoked asynchronously when complete. \a md_array will be populated
/// with the resulting metadata once complete.
bool grpc_call_credentials_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error);
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error);
/// Cancels a pending asynchronous operation started by
/// grpc_call_credentials_get_request_metadata() with the corresponding
/// value of \a md_array.
void grpc_call_credentials_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);
/* Metadata-only credentials with the specified key and value where
asynchronicity can be simulated for testing. */
grpc_call_credentials* grpc_md_only_test_credentials_create(
- grpc_exec_ctx* exec_ctx, const char* md_key, const char* md_value,
- bool is_async);
+ const char* md_key, const char* md_value, bool is_async);
/* --- grpc_server_credentials. --- */
typedef struct {
- void (*destruct)(grpc_exec_ctx* exec_ctx, grpc_server_credentials* c);
+ void (*destruct)(grpc_server_credentials* c);
grpc_security_status (*create_security_connector)(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* c,
- grpc_server_security_connector** sc);
+ grpc_server_credentials* c, grpc_server_security_connector** sc);
} grpc_server_credentials_vtable;
struct grpc_server_credentials {
@@ -223,14 +214,12 @@ struct grpc_server_credentials {
};
grpc_security_status grpc_server_credentials_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* creds,
- grpc_server_security_connector** sc);
+ grpc_server_credentials* creds, grpc_server_security_connector** sc);
grpc_server_credentials* grpc_server_credentials_ref(
grpc_server_credentials* creds);
-void grpc_server_credentials_unref(grpc_exec_ctx* exec_ctx,
- grpc_server_credentials* creds);
+void grpc_server_credentials_unref(grpc_server_credentials* creds);
#define GRPC_SERVER_CREDENTIALS_ARG "grpc.server_credentials"
@@ -250,6 +239,6 @@ grpc_credentials_metadata_request* grpc_credentials_metadata_request_create(
grpc_call_credentials* creds);
void grpc_credentials_metadata_request_destroy(
- grpc_exec_ctx* exec_ctx, grpc_credentials_metadata_request* r);
+ grpc_credentials_metadata_request* r);
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/credentials_metadata.cc b/src/core/lib/security/credentials/credentials_metadata.cc
index a3623fa1d6..9ceaf21139 100644
--- a/src/core/lib/security/credentials/credentials_metadata.cc
+++ b/src/core/lib/security/credentials/credentials_metadata.cc
@@ -52,9 +52,9 @@ void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array* dst,
}
void grpc_credentials_mdelem_array_destroy(
- grpc_exec_ctx* exec_ctx, grpc_credentials_mdelem_array* list) {
+ grpc_credentials_mdelem_array* list) {
for (size_t i = 0; i < list->size; ++i) {
- GRPC_MDELEM_UNREF(exec_ctx, list->md[i]);
+ GRPC_MDELEM_UNREF(list->md[i]);
}
gpr_free(list->md);
}
diff --git a/src/core/lib/security/credentials/fake/fake_credentials.cc b/src/core/lib/security/credentials/fake/fake_credentials.cc
index a535a317ee..99b1214951 100644
--- a/src/core/lib/security/credentials/fake/fake_credentials.cc
+++ b/src/core/lib/security/credentials/fake/fake_credentials.cc
@@ -34,10 +34,9 @@
"grpc.fake_security.expected_targets"
static grpc_security_status fake_transport_security_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* c,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* c, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
*sc =
grpc_fake_channel_security_connector_create(c, call_creds, target, args);
return GRPC_SECURITY_OK;
@@ -45,8 +44,7 @@ static grpc_security_status fake_transport_security_create_security_connector(
static grpc_security_status
fake_transport_security_server_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* c,
- grpc_server_security_connector** sc) {
+ grpc_server_credentials* c, grpc_server_security_connector** sc) {
*sc = grpc_fake_server_security_connector_create(c);
return GRPC_SECURITY_OK;
}
@@ -98,29 +96,27 @@ const char* grpc_fake_transport_get_expected_targets(
/* -- Metadata-only test credentials. -- */
-static void md_only_test_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void md_only_test_destruct(grpc_call_credentials* creds) {
grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->md);
+ GRPC_MDELEM_UNREF(c->md);
}
static bool md_only_test_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error) {
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)creds;
grpc_credentials_mdelem_array_add(md_array, c->md);
if (c->is_async) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_request_metadata, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(on_request_metadata, GRPC_ERROR_NONE);
return false;
}
return true;
}
static void md_only_test_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);
}
@@ -129,16 +125,14 @@ static grpc_call_credentials_vtable md_only_test_vtable = {
md_only_test_cancel_get_request_metadata};
grpc_call_credentials* grpc_md_only_test_credentials_create(
- grpc_exec_ctx* exec_ctx, const char* md_key, const char* md_value,
- bool is_async) {
+ const char* md_key, const char* md_value, bool is_async) {
grpc_md_only_test_credentials* c = (grpc_md_only_test_credentials*)gpr_zalloc(
sizeof(grpc_md_only_test_credentials));
c->base.type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2;
c->base.vtable = &md_only_test_vtable;
gpr_ref_init(&c->base.refcount, 1);
- c->md =
- grpc_mdelem_from_slices(exec_ctx, grpc_slice_from_copied_string(md_key),
- grpc_slice_from_copied_string(md_value));
+ c->md = grpc_mdelem_from_slices(grpc_slice_from_copied_string(md_key),
+ grpc_slice_from_copied_string(md_value));
c->is_async = is_async;
return &c->base;
}
diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
index f586c7b604..03d52850d9 100644
--- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc
+++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc
@@ -58,8 +58,7 @@ typedef struct {
grpc_http_response response;
} compute_engine_detector;
-static void on_compute_engine_detection_http_response(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void on_compute_engine_detection_http_response(void* user_data,
grpc_error* error) {
compute_engine_detector* detector = (compute_engine_detector*)user_data;
if (error == GRPC_ERROR_NONE && detector->response.status == 200 &&
@@ -80,16 +79,16 @@ static void on_compute_engine_detection_http_response(grpc_exec_ctx* exec_ctx,
detector->is_done = 1;
GRPC_LOG_IF_ERROR(
"Pollset kick",
- grpc_pollset_kick(
- exec_ctx, grpc_polling_entity_pollset(&detector->pollent), nullptr));
+ grpc_pollset_kick(grpc_polling_entity_pollset(&detector->pollent),
+ nullptr));
gpr_mu_unlock(g_polling_mu);
}
-static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* e) {
- grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p);
+static void destroy_pollset(void* p, grpc_error* e) {
+ grpc_pollset_destroy((grpc_pollset*)p);
}
-static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
+static int is_stack_running_on_compute_engine() {
compute_engine_detector detector;
grpc_httpcli_request request;
grpc_httpcli_context context;
@@ -115,14 +114,14 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("google_default_credentials");
grpc_httpcli_get(
- exec_ctx, &context, &detector.pollent, resource_quota, &request,
- grpc_exec_ctx_now(exec_ctx) + max_detection_delay,
+ &context, &detector.pollent, resource_quota, &request,
+ grpc_core::ExecCtx::Get()->Now() + max_detection_delay,
GRPC_CLOSURE_CREATE(on_compute_engine_detection_http_response, &detector,
grpc_schedule_on_exec_ctx),
&detector.response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
/* Block until we get the response. This is not ideal but this should only be
called once for the lifetime of the process by the default credentials. */
@@ -131,8 +130,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
grpc_pollset_worker* worker = nullptr;
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
- grpc_pollset_work(exec_ctx,
- grpc_polling_entity_pollset(&detector.pollent),
+ grpc_pollset_work(grpc_polling_entity_pollset(&detector.pollent),
&worker, GRPC_MILLIS_INF_FUTURE))) {
detector.is_done = 1;
detector.success = 0;
@@ -140,15 +138,14 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
}
gpr_mu_unlock(g_polling_mu);
- grpc_httpcli_context_destroy(exec_ctx, &context);
+ grpc_httpcli_context_destroy(&context);
GRPC_CLOSURE_INIT(&destroy_closure, destroy_pollset,
grpc_polling_entity_pollset(&detector.pollent),
grpc_schedule_on_exec_ctx);
- grpc_pollset_shutdown(exec_ctx,
- grpc_polling_entity_pollset(&detector.pollent),
+ grpc_pollset_shutdown(grpc_polling_entity_pollset(&detector.pollent),
&destroy_closure);
g_polling_mu = nullptr;
- grpc_exec_ctx_flush(exec_ctx);
+ grpc_core::ExecCtx::Get()->Flush();
gpr_free(grpc_polling_entity_pollset(&detector.pollent));
grpc_http_response_destroy(&detector.response);
@@ -158,7 +155,7 @@ static int is_stack_running_on_compute_engine(grpc_exec_ctx* exec_ctx) {
/* Takes ownership of creds_path if not NULL. */
static grpc_error* create_default_creds_from_path(
- grpc_exec_ctx* exec_ctx, char* creds_path, grpc_call_credentials** creds) {
+ char* creds_path, grpc_call_credentials** creds) {
grpc_json* json = nullptr;
grpc_auth_json_key key;
grpc_auth_refresh_token token;
@@ -187,7 +184,7 @@ static grpc_error* create_default_creds_from_path(
if (grpc_auth_json_key_is_valid(&key)) {
result =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- exec_ctx, key, grpc_max_auth_token_lifetime());
+ key, grpc_max_auth_token_lifetime());
if (result == nullptr) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"grpc_service_account_jwt_access_credentials_create_from_auth_json_"
@@ -212,7 +209,7 @@ static grpc_error* create_default_creds_from_path(
end:
GPR_ASSERT((result == nullptr) + (error == GRPC_ERROR_NONE) == 1);
if (creds_path != nullptr) gpr_free(creds_path);
- grpc_slice_unref_internal(exec_ctx, creds_data);
+ grpc_slice_unref_internal(creds_data);
if (json != nullptr) grpc_json_destroy(json);
*creds = result;
return error;
@@ -224,7 +221,7 @@ grpc_channel_credentials* grpc_google_default_credentials_create(void) {
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to create Google credentials");
grpc_error* err;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_google_default_credentials_create(void)", 0, ());
@@ -239,22 +236,20 @@ grpc_channel_credentials* grpc_google_default_credentials_create(void) {
/* First, try the environment variable. */
err = create_default_creds_from_path(
- &exec_ctx, gpr_getenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR), &call_creds);
+ gpr_getenv(GRPC_GOOGLE_CREDENTIALS_ENV_VAR), &call_creds);
if (err == GRPC_ERROR_NONE) goto end;
error = grpc_error_add_child(error, err);
/* Then the well-known file. */
err = create_default_creds_from_path(
- &exec_ctx, grpc_get_well_known_google_credentials_file_path(),
- &call_creds);
+ grpc_get_well_known_google_credentials_file_path(), &call_creds);
if (err == GRPC_ERROR_NONE) goto end;
error = grpc_error_add_child(error, err);
/* At last try to see if we're on compute engine (do the detection only once
since it requires a network test). */
if (!compute_engine_detection_done) {
- int need_compute_engine_creds =
- is_stack_running_on_compute_engine(&exec_ctx);
+ int need_compute_engine_creds = is_stack_running_on_compute_engine();
compute_engine_detection_done = 1;
if (need_compute_engine_creds) {
call_creds = grpc_google_compute_engine_credentials_create(nullptr);
@@ -278,8 +273,8 @@ end:
grpc_composite_channel_credentials_create(ssl_creds, call_creds,
nullptr));
GPR_ASSERT(default_credentials != nullptr);
- grpc_channel_credentials_unref(&exec_ctx, ssl_creds);
- grpc_call_credentials_unref(&exec_ctx, call_creds);
+ grpc_channel_credentials_unref(ssl_creds);
+ grpc_call_credentials_unref(call_creds);
result = default_credentials;
} else {
gpr_log(GPR_ERROR, "Could not create google default credentials.");
@@ -291,21 +286,20 @@ end:
} else {
GRPC_ERROR_UNREF(error);
}
- grpc_exec_ctx_finish(&exec_ctx);
+
return result;
}
void grpc_flush_cached_google_default_credentials(void) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_once_init(&g_once, init_default_credentials);
gpr_mu_lock(&g_state_mu);
if (default_credentials != nullptr) {
- grpc_channel_credentials_unref(&exec_ctx, default_credentials);
+ grpc_channel_credentials_unref(default_credentials);
default_credentials = nullptr;
}
compute_engine_detection_done = 0;
gpr_mu_unlock(&g_state_mu);
- grpc_exec_ctx_finish(&exec_ctx);
}
/* -- Well known credentials path. -- */
diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc
index 1741bf3068..75acb2a58e 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;
+ grpc_core::ExecCtx 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);
+
return &c->base;
}
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
index 77163c0cc1..2404e860e4 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc
@@ -30,9 +30,8 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
-static void jwt_reset_cache(grpc_exec_ctx* exec_ctx,
- grpc_service_account_jwt_access_credentials* c) {
- GRPC_MDELEM_UNREF(exec_ctx, c->cached.jwt_md);
+static void jwt_reset_cache(grpc_service_account_jwt_access_credentials* c) {
+ GRPC_MDELEM_UNREF(c->cached.jwt_md);
c->cached.jwt_md = GRPC_MDNULL;
if (c->cached.service_url != nullptr) {
gpr_free(c->cached.service_url);
@@ -41,17 +40,15 @@ static void jwt_reset_cache(grpc_exec_ctx* exec_ctx,
c->cached.jwt_expiration = gpr_inf_past(GPR_CLOCK_REALTIME);
}
-static void jwt_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void jwt_destruct(grpc_call_credentials* creds) {
grpc_service_account_jwt_access_credentials* c =
(grpc_service_account_jwt_access_credentials*)creds;
grpc_auth_json_key_destruct(&c->key);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
gpr_mu_destroy(&c->cache_mu);
}
-static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds,
+static bool jwt_get_request_metadata(grpc_call_credentials* creds,
grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
grpc_credentials_mdelem_array* md_array,
@@ -81,7 +78,7 @@ static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
char* jwt = nullptr;
/* Generate a new jwt. */
gpr_mu_lock(&c->cache_mu);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
jwt = grpc_jwt_encode_and_sign(&c->key, context.service_url,
c->jwt_lifetime, nullptr);
if (jwt != nullptr) {
@@ -92,7 +89,6 @@ static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c->jwt_lifetime);
c->cached.service_url = gpr_strdup(context.service_url);
c->cached.jwt_md = grpc_mdelem_from_slices(
- exec_ctx,
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(md_value));
gpr_free(md_value);
@@ -103,7 +99,7 @@ static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
if (!GRPC_MDISNULL(jwt_md)) {
grpc_credentials_mdelem_array_add(md_array, jwt_md);
- GRPC_MDELEM_UNREF(exec_ctx, jwt_md);
+ GRPC_MDELEM_UNREF(jwt_md);
} else {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Could not generate JWT.");
}
@@ -111,8 +107,8 @@ static bool jwt_get_request_metadata(grpc_exec_ctx* exec_ctx,
}
static void jwt_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);
}
@@ -121,8 +117,7 @@ static grpc_call_credentials_vtable jwt_vtable = {
grpc_call_credentials*
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- grpc_exec_ctx* exec_ctx, grpc_auth_json_key key,
- gpr_timespec token_lifetime) {
+ grpc_auth_json_key key, gpr_timespec token_lifetime) {
grpc_service_account_jwt_access_credentials* c;
if (!grpc_auth_json_key_is_valid(&key)) {
gpr_log(GPR_ERROR, "Invalid input for jwt credentials creation");
@@ -143,7 +138,7 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
}
c->jwt_lifetime = token_lifetime;
gpr_mu_init(&c->cache_mu);
- jwt_reset_cache(exec_ctx, c);
+ jwt_reset_cache(c);
return &c->base;
}
@@ -186,11 +181,10 @@ grpc_call_credentials* grpc_service_account_jwt_access_credentials_create(
gpr_free(clean_json);
}
GPR_ASSERT(reserved == nullptr);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
grpc_call_credentials* creds =
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- &exec_ctx, grpc_auth_json_key_create_from_string(json_key),
- token_lifetime);
- grpc_exec_ctx_finish(&exec_ctx);
+ grpc_auth_json_key_create_from_string(json_key), token_lifetime);
+
return creds;
}
diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h
index 85f068aac8..f58a8b67ba 100644
--- a/src/core/lib/security/credentials/jwt/jwt_credentials.h
+++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h
@@ -42,7 +42,6 @@ typedef struct {
// Takes ownership of the key.
grpc_call_credentials*
grpc_service_account_jwt_access_credentials_create_from_auth_json_key(
- grpc_exec_ctx* exec_ctx, grpc_auth_json_key key,
- gpr_timespec token_lifetime);
+ grpc_auth_json_key key, gpr_timespec token_lifetime);
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
index 3709b83c4e..39339f07d7 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.cc
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc
@@ -74,12 +74,11 @@ static const EVP_MD* evp_md_from_alg(const char* alg) {
}
}
-static grpc_json* parse_json_part_from_jwt(grpc_exec_ctx* exec_ctx,
- const char* str, size_t len,
+static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
grpc_slice* buffer) {
grpc_json* json;
- *buffer = grpc_base64_decode_with_len(exec_ctx, str, len, 1);
+ *buffer = grpc_base64_decode_with_len(str, len, 1);
if (GRPC_SLICE_IS_EMPTY(*buffer)) {
gpr_log(GPR_ERROR, "Invalid base64.");
return nullptr;
@@ -87,7 +86,7 @@ static grpc_json* parse_json_part_from_jwt(grpc_exec_ctx* exec_ctx,
json = grpc_json_parse_string_with_len((char*)GRPC_SLICE_START_PTR(*buffer),
GRPC_SLICE_LENGTH(*buffer));
if (json == nullptr) {
- grpc_slice_unref_internal(exec_ctx, *buffer);
+ grpc_slice_unref_internal(*buffer);
gpr_log(GPR_ERROR, "JSON parsing error.");
}
return json;
@@ -123,14 +122,13 @@ typedef struct {
grpc_slice buffer;
} jose_header;
-static void jose_header_destroy(grpc_exec_ctx* exec_ctx, jose_header* h) {
- grpc_slice_unref_internal(exec_ctx, h->buffer);
+static void jose_header_destroy(jose_header* h) {
+ grpc_slice_unref_internal(h->buffer);
gpr_free(h);
}
/* Takes ownership of json and buffer. */
-static jose_header* jose_header_from_json(grpc_exec_ctx* exec_ctx,
- grpc_json* json, grpc_slice buffer) {
+static jose_header* jose_header_from_json(grpc_json* json, grpc_slice buffer) {
grpc_json* cur;
jose_header* h = (jose_header*)gpr_zalloc(sizeof(jose_header));
h->buffer = buffer;
@@ -164,7 +162,7 @@ static jose_header* jose_header_from_json(grpc_exec_ctx* exec_ctx,
error:
grpc_json_destroy(json);
- jose_header_destroy(exec_ctx, h);
+ jose_header_destroy(h);
return nullptr;
}
@@ -184,9 +182,9 @@ struct grpc_jwt_claims {
grpc_slice buffer;
};
-void grpc_jwt_claims_destroy(grpc_exec_ctx* exec_ctx, grpc_jwt_claims* claims) {
+void grpc_jwt_claims_destroy(grpc_jwt_claims* claims) {
grpc_json_destroy(claims->json);
- grpc_slice_unref_internal(exec_ctx, claims->buffer);
+ grpc_slice_unref_internal(claims->buffer);
gpr_free(claims);
}
@@ -231,8 +229,7 @@ gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims* claims) {
}
/* Takes ownership of json and buffer even in case of failure. */
-grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_exec_ctx* exec_ctx,
- grpc_json* json, grpc_slice buffer) {
+grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json, grpc_slice buffer) {
grpc_json* cur;
grpc_jwt_claims* claims =
(grpc_jwt_claims*)gpr_malloc(sizeof(grpc_jwt_claims));
@@ -274,7 +271,7 @@ grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_exec_ctx* exec_ctx,
return claims;
error:
- grpc_jwt_claims_destroy(exec_ctx, claims);
+ grpc_jwt_claims_destroy(claims);
return nullptr;
}
@@ -350,7 +347,7 @@ static verifier_cb_ctx* verifier_cb_ctx_create(
grpc_jwt_claims* claims, const char* audience, grpc_slice signature,
const char* signed_jwt, size_t signed_jwt_len, void* user_data,
grpc_jwt_verification_done_cb cb) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
verifier_cb_ctx* ctx = (verifier_cb_ctx*)gpr_zalloc(sizeof(verifier_cb_ctx));
ctx->verifier = verifier;
ctx->pollent = grpc_polling_entity_create_from_pollset(pollset);
@@ -361,16 +358,16 @@ static verifier_cb_ctx* verifier_cb_ctx_create(
ctx->signed_data = grpc_slice_from_copied_buffer(signed_jwt, signed_jwt_len);
ctx->user_data = user_data;
ctx->user_cb = cb;
- grpc_exec_ctx_finish(&exec_ctx);
+
return ctx;
}
-void verifier_cb_ctx_destroy(grpc_exec_ctx* exec_ctx, verifier_cb_ctx* ctx) {
+void verifier_cb_ctx_destroy(verifier_cb_ctx* ctx) {
if (ctx->audience != nullptr) gpr_free(ctx->audience);
- if (ctx->claims != nullptr) grpc_jwt_claims_destroy(exec_ctx, ctx->claims);
- grpc_slice_unref_internal(exec_ctx, ctx->signature);
- grpc_slice_unref_internal(exec_ctx, ctx->signed_data);
- jose_header_destroy(exec_ctx, ctx->header);
+ if (ctx->claims != nullptr) grpc_jwt_claims_destroy(ctx->claims);
+ grpc_slice_unref_internal(ctx->signature);
+ grpc_slice_unref_internal(ctx->signed_data);
+ jose_header_destroy(ctx->header);
for (size_t i = 0; i < HTTP_RESPONSE_COUNT; i++) {
grpc_http_response_destroy(&ctx->responses[i]);
}
@@ -450,19 +447,19 @@ end:
return result;
}
-static BIGNUM* bignum_from_base64(grpc_exec_ctx* exec_ctx, const char* b64) {
+static BIGNUM* bignum_from_base64(const char* b64) {
BIGNUM* result = nullptr;
grpc_slice bin;
if (b64 == nullptr) return nullptr;
- bin = grpc_base64_decode(exec_ctx, b64, 1);
+ bin = grpc_base64_decode(b64, 1);
if (GRPC_SLICE_IS_EMPTY(bin)) {
gpr_log(GPR_ERROR, "Invalid base64 for big num.");
return nullptr;
}
result = BN_bin2bn(GRPC_SLICE_START_PTR(bin),
TSI_SIZE_AS_SIZE(GRPC_SLICE_LENGTH(bin)), nullptr);
- grpc_slice_unref_internal(exec_ctx, bin);
+ grpc_slice_unref_internal(bin);
return result;
}
@@ -495,8 +492,7 @@ static int RSA_set0_key(RSA* r, BIGNUM* n, BIGNUM* e, BIGNUM* d) {
}
#endif // OPENSSL_VERSION_NUMBER < 0x10100000L
-static EVP_PKEY* pkey_from_jwk(grpc_exec_ctx* exec_ctx, const grpc_json* json,
- const char* kty) {
+static EVP_PKEY* pkey_from_jwk(const grpc_json* json, const char* kty) {
const grpc_json* key_prop;
RSA* rsa = nullptr;
EVP_PKEY* result = nullptr;
@@ -515,12 +511,10 @@ static EVP_PKEY* pkey_from_jwk(grpc_exec_ctx* exec_ctx, const grpc_json* json,
}
for (key_prop = json->child; key_prop != nullptr; key_prop = key_prop->next) {
if (strcmp(key_prop->key, "n") == 0) {
- tmp_n =
- bignum_from_base64(exec_ctx, validate_string_field(key_prop, "n"));
+ tmp_n = bignum_from_base64(validate_string_field(key_prop, "n"));
if (tmp_n == nullptr) goto end;
} else if (strcmp(key_prop->key, "e") == 0) {
- tmp_e =
- bignum_from_base64(exec_ctx, validate_string_field(key_prop, "e"));
+ tmp_e = bignum_from_base64(validate_string_field(key_prop, "e"));
if (tmp_e == nullptr) goto end;
}
}
@@ -545,8 +539,7 @@ end:
return result;
}
-static EVP_PKEY* find_verification_key(grpc_exec_ctx* exec_ctx,
- const grpc_json* json,
+static EVP_PKEY* find_verification_key(const grpc_json* json,
const char* header_alg,
const char* header_kid) {
const grpc_json* jkey;
@@ -591,7 +584,7 @@ static EVP_PKEY* find_verification_key(grpc_exec_ctx* exec_ctx,
}
if (alg != nullptr && kid != nullptr && kty != nullptr &&
strcmp(kid, header_kid) == 0 && strcmp(alg, header_alg) == 0) {
- return pkey_from_jwk(exec_ctx, jkey, kty);
+ return pkey_from_jwk(jkey, kty);
}
}
gpr_log(GPR_ERROR,
@@ -632,8 +625,7 @@ end:
return result;
}
-static void on_keys_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void on_keys_retrieved(void* user_data, grpc_error* error) {
verifier_cb_ctx* ctx = (verifier_cb_ctx*)user_data;
grpc_json* json = json_from_http(&ctx->responses[HTTP_RESPONSE_KEYS]);
EVP_PKEY* verification_key = nullptr;
@@ -645,7 +637,7 @@ static void on_keys_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
goto end;
}
verification_key =
- find_verification_key(exec_ctx, json, ctx->header->alg, ctx->header->kid);
+ find_verification_key(json, ctx->header->alg, ctx->header->kid);
if (verification_key == nullptr) {
gpr_log(GPR_ERROR, "Could not find verification key with kid %s.",
ctx->header->kid);
@@ -669,12 +661,11 @@ static void on_keys_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
end:
if (json != nullptr) grpc_json_destroy(json);
EVP_PKEY_free(verification_key);
- ctx->user_cb(exec_ctx, ctx->user_data, status, claims);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ ctx->user_cb(ctx->user_data, status, claims);
+ verifier_cb_ctx_destroy(ctx);
}
-static void on_openid_config_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void on_openid_config_retrieved(void* user_data, grpc_error* error) {
const grpc_json* cur;
verifier_cb_ctx* ctx = (verifier_cb_ctx*)user_data;
const grpc_http_response* response = &ctx->responses[HTTP_RESPONSE_OPENID];
@@ -711,20 +702,19 @@ static void on_openid_config_retrieved(grpc_exec_ctx* exec_ctx, void* user_data,
extreme memory pressure. */
resource_quota = grpc_resource_quota_create("jwt_verifier");
grpc_httpcli_get(
- exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
- grpc_exec_ctx_now(exec_ctx) + grpc_jwt_verifier_max_delay,
+ &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay,
GRPC_CLOSURE_CREATE(on_keys_retrieved, ctx, grpc_schedule_on_exec_ctx),
&ctx->responses[HTTP_RESPONSE_KEYS]);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
grpc_json_destroy(json);
gpr_free(req.host);
return;
error:
if (json != nullptr) grpc_json_destroy(json);
- ctx->user_cb(exec_ctx, ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR,
- nullptr);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ ctx->user_cb(ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR, nullptr);
+ verifier_cb_ctx_destroy(ctx);
}
static email_key_mapping* verifier_get_mapping(grpc_jwt_verifier* v,
@@ -772,8 +762,7 @@ const char* grpc_jwt_issuer_email_domain(const char* issuer) {
}
/* Takes ownership of ctx. */
-static void retrieve_key_and_verify(grpc_exec_ctx* exec_ctx,
- verifier_cb_ctx* ctx) {
+static void retrieve_key_and_verify(verifier_cb_ctx* ctx) {
const char* email_domain;
grpc_closure* http_cb;
char* path_prefix = nullptr;
@@ -840,23 +829,21 @@ static void retrieve_key_and_verify(grpc_exec_ctx* exec_ctx,
channel. This would allow us to cancel an authentication query when under
extreme memory pressure. */
resource_quota = grpc_resource_quota_create("jwt_verifier");
- grpc_httpcli_get(exec_ctx, &ctx->verifier->http_ctx, &ctx->pollent,
- resource_quota, &req,
- grpc_exec_ctx_now(exec_ctx) + grpc_jwt_verifier_max_delay,
- http_cb, &ctx->responses[rsp_idx]);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_httpcli_get(
+ &ctx->verifier->http_ctx, &ctx->pollent, resource_quota, &req,
+ grpc_core::ExecCtx::Get()->Now() + grpc_jwt_verifier_max_delay, http_cb,
+ &ctx->responses[rsp_idx]);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_free(req.host);
gpr_free(req.http.path);
return;
error:
- ctx->user_cb(exec_ctx, ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR,
- nullptr);
- verifier_cb_ctx_destroy(exec_ctx, ctx);
+ ctx->user_cb(ctx->user_data, GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR, nullptr);
+ verifier_cb_ctx_destroy(ctx);
}
-void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
- grpc_jwt_verifier* verifier,
+void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
grpc_pollset* pollset, const char* jwt,
const char* audience,
grpc_jwt_verification_done_cb cb,
@@ -875,35 +862,32 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
cb != nullptr);
dot = strchr(cur, '.');
if (dot == nullptr) goto error;
- json = parse_json_part_from_jwt(exec_ctx, cur, (size_t)(dot - cur),
- &header_buffer);
+ json = parse_json_part_from_jwt(cur, (size_t)(dot - cur), &header_buffer);
if (json == nullptr) goto error;
- header = jose_header_from_json(exec_ctx, json, header_buffer);
+ header = jose_header_from_json(json, header_buffer);
if (header == nullptr) goto error;
cur = dot + 1;
dot = strchr(cur, '.');
if (dot == nullptr) goto error;
- json = parse_json_part_from_jwt(exec_ctx, cur, (size_t)(dot - cur),
- &claims_buffer);
+ json = parse_json_part_from_jwt(cur, (size_t)(dot - cur), &claims_buffer);
if (json == nullptr) goto error;
- claims = grpc_jwt_claims_from_json(exec_ctx, json, claims_buffer);
+ claims = grpc_jwt_claims_from_json(json, claims_buffer);
if (claims == nullptr) goto error;
signed_jwt_len = (size_t)(dot - jwt);
cur = dot + 1;
- signature = grpc_base64_decode(exec_ctx, cur, 1);
+ signature = grpc_base64_decode(cur, 1);
if (GRPC_SLICE_IS_EMPTY(signature)) goto error;
retrieve_key_and_verify(
- exec_ctx,
verifier_cb_ctx_create(verifier, pollset, header, claims, audience,
signature, jwt, signed_jwt_len, user_data, cb));
return;
error:
- if (header != nullptr) jose_header_destroy(exec_ctx, header);
- if (claims != nullptr) grpc_jwt_claims_destroy(exec_ctx, claims);
- cb(exec_ctx, user_data, GRPC_JWT_VERIFIER_BAD_FORMAT, nullptr);
+ if (header != nullptr) jose_header_destroy(header);
+ if (claims != nullptr) grpc_jwt_claims_destroy(claims);
+ cb(user_data, GRPC_JWT_VERIFIER_BAD_FORMAT, nullptr);
}
grpc_jwt_verifier* grpc_jwt_verifier_create(
@@ -930,10 +914,10 @@ grpc_jwt_verifier* grpc_jwt_verifier_create(
return v;
}
-void grpc_jwt_verifier_destroy(grpc_exec_ctx* exec_ctx, grpc_jwt_verifier* v) {
+void grpc_jwt_verifier_destroy(grpc_jwt_verifier* v) {
size_t i;
if (v == nullptr) return;
- grpc_httpcli_context_destroy(exec_ctx, &v->http_ctx);
+ grpc_httpcli_context_destroy(&v->http_ctx);
if (v->mappings != nullptr) {
for (i = 0; i < v->num_mappings; i++) {
gpr_free(v->mappings[i].email_domain);
diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.h b/src/core/lib/security/credentials/jwt/jwt_verifier.h
index 2aacd497c7..b3805e75cd 100644
--- a/src/core/lib/security/credentials/jwt/jwt_verifier.h
+++ b/src/core/lib/security/credentials/jwt/jwt_verifier.h
@@ -51,7 +51,7 @@ const char* grpc_jwt_verifier_status_to_string(grpc_jwt_verifier_status status);
typedef struct grpc_jwt_claims grpc_jwt_claims;
-void grpc_jwt_claims_destroy(grpc_exec_ctx* exec_ctx, grpc_jwt_claims* claims);
+void grpc_jwt_claims_destroy(grpc_jwt_claims* claims);
/* Returns the whole JSON tree of the claims. */
const grpc_json* grpc_jwt_claims_json(const grpc_jwt_claims* claims);
@@ -94,21 +94,18 @@ grpc_jwt_verifier* grpc_jwt_verifier_create(
size_t num_mappings);
/*The verifier must not be destroyed if there are still outstanding callbacks.*/
-void grpc_jwt_verifier_destroy(grpc_exec_ctx* exec_ctx,
- grpc_jwt_verifier* verifier);
+void grpc_jwt_verifier_destroy(grpc_jwt_verifier* verifier);
/* User provided callback that will be called when the verification of the JWT
is done (maybe in another thread).
It is the responsibility of the callee to call grpc_jwt_claims_destroy on
the claims. */
-typedef void (*grpc_jwt_verification_done_cb)(grpc_exec_ctx* exec_ctx,
- void* user_data,
+typedef void (*grpc_jwt_verification_done_cb)(void* user_data,
grpc_jwt_verifier_status status,
grpc_jwt_claims* claims);
/* Verifies for the JWT for the given expected audience. */
-void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
- grpc_jwt_verifier* verifier,
+void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier,
grpc_pollset* pollset, const char* jwt,
const char* audience,
grpc_jwt_verification_done_cb cb,
@@ -116,8 +113,7 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx* exec_ctx,
/* --- TESTING ONLY exposed functions. --- */
-grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_exec_ctx* exec_ctx,
- grpc_json* json, grpc_slice buffer);
+grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_json* json, grpc_slice buffer);
grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims,
const char* audience);
const char* grpc_jwt_issuer_email_domain(const char* issuer);
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
index ccefb4db9c..e243ea52c6 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
@@ -103,21 +103,19 @@ void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token) {
// Oauth2 Token Fetcher credentials.
//
-static void oauth2_token_fetcher_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void oauth2_token_fetcher_destruct(grpc_call_credentials* creds) {
grpc_oauth2_token_fetcher_credentials* c =
(grpc_oauth2_token_fetcher_credentials*)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->access_token_md);
+ GRPC_MDELEM_UNREF(c->access_token_md);
gpr_mu_destroy(&c->mu);
- grpc_pollset_set_destroy(exec_ctx,
- grpc_polling_entity_pollset_set(&c->pollent));
- grpc_httpcli_context_destroy(exec_ctx, &c->httpcli_context);
+ grpc_pollset_set_destroy(grpc_polling_entity_pollset_set(&c->pollent));
+ grpc_httpcli_context_destroy(&c->httpcli_context);
}
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- grpc_exec_ctx* exec_ctx, const grpc_http_response* response,
- grpc_mdelem* token_md, grpc_millis* token_lifetime) {
+ const grpc_http_response* response, grpc_mdelem* token_md,
+ grpc_millis* token_lifetime) {
char* null_terminated_body = nullptr;
char* new_access_token = nullptr;
grpc_credentials_status status = GRPC_CREDENTIALS_OK;
@@ -184,9 +182,8 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
gpr_asprintf(&new_access_token, "%s %s", token_type->value,
access_token->value);
*token_lifetime = strtol(expires_in->value, nullptr, 10) * GPR_MS_PER_SEC;
- if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(exec_ctx, *token_md);
+ if (!GRPC_MDISNULL(*token_md)) GRPC_MDELEM_UNREF(*token_md);
*token_md = grpc_mdelem_from_slices(
- exec_ctx,
grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(new_access_token));
status = GRPC_CREDENTIALS_OK;
@@ -194,7 +191,7 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response(
end:
if (status != GRPC_CREDENTIALS_OK && !GRPC_MDISNULL(*token_md)) {
- GRPC_MDELEM_UNREF(exec_ctx, *token_md);
+ GRPC_MDELEM_UNREF(*token_md);
*token_md = GRPC_MDNULL;
}
if (null_terminated_body != nullptr) gpr_free(null_terminated_body);
@@ -203,8 +200,7 @@ end:
return status;
}
-static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static void on_oauth2_token_fetcher_http_response(void* user_data,
grpc_error* error) {
GRPC_LOG_IF_ERROR("oauth_fetch", GRPC_ERROR_REF(error));
grpc_credentials_metadata_request* r =
@@ -215,13 +211,13 @@ static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx* exec_ctx,
grpc_millis token_lifetime;
grpc_credentials_status status =
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- exec_ctx, &r->response, &access_token_md, &token_lifetime);
+ &r->response, &access_token_md, &token_lifetime);
// Update cache and grab list of pending requests.
gpr_mu_lock(&c->mu);
c->token_fetch_pending = false;
c->access_token_md = GRPC_MDELEM_REF(access_token_md);
c->token_expiration = status == GRPC_CREDENTIALS_OK
- ? grpc_exec_ctx_now(exec_ctx) + token_lifetime
+ ? grpc_core::ExecCtx::Get()->Now() + token_lifetime
: 0;
grpc_oauth2_pending_get_request_metadata* pending_request =
c->pending_requests;
@@ -236,24 +232,22 @@ static void on_oauth2_token_fetcher_http_response(grpc_exec_ctx* exec_ctx,
error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Error occured when fetching oauth2 token.", &error, 1);
}
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata, error);
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata, error);
grpc_polling_entity_del_from_pollset_set(
- exec_ctx, pending_request->pollent,
- grpc_polling_entity_pollset_set(&c->pollent));
+ pending_request->pollent, grpc_polling_entity_pollset_set(&c->pollent));
grpc_oauth2_pending_get_request_metadata* prev = pending_request;
pending_request = pending_request->next;
gpr_free(prev);
}
- GRPC_MDELEM_UNREF(exec_ctx, access_token_md);
- grpc_call_credentials_unref(exec_ctx, r->creds);
- grpc_credentials_metadata_request_destroy(exec_ctx, r);
+ GRPC_MDELEM_UNREF(access_token_md);
+ grpc_call_credentials_unref(r->creds);
+ grpc_credentials_metadata_request_destroy(r);
}
static bool oauth2_token_fetcher_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error) {
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
grpc_oauth2_token_fetcher_credentials* c =
(grpc_oauth2_token_fetcher_credentials*)creds;
// Check if we can use the cached token.
@@ -262,13 +256,14 @@ static bool oauth2_token_fetcher_get_request_metadata(
grpc_mdelem cached_access_token_md = GRPC_MDNULL;
gpr_mu_lock(&c->mu);
if (!GRPC_MDISNULL(c->access_token_md) &&
- (c->token_expiration - grpc_exec_ctx_now(exec_ctx) > refresh_threshold)) {
+ (c->token_expiration - grpc_core::ExecCtx::Get()->Now() >
+ refresh_threshold)) {
cached_access_token_md = GRPC_MDELEM_REF(c->access_token_md);
}
if (!GRPC_MDISNULL(cached_access_token_md)) {
gpr_mu_unlock(&c->mu);
grpc_credentials_mdelem_array_add(md_array, cached_access_token_md);
- GRPC_MDELEM_UNREF(exec_ctx, cached_access_token_md);
+ GRPC_MDELEM_UNREF(cached_access_token_md);
return true;
}
// Couldn't get the token from the cache.
@@ -280,7 +275,7 @@ static bool oauth2_token_fetcher_get_request_metadata(
pending_request->on_request_metadata = on_request_metadata;
pending_request->pollent = pollent;
grpc_polling_entity_add_to_pollset_set(
- exec_ctx, pollent, grpc_polling_entity_pollset_set(&c->pollent));
+ pollent, grpc_polling_entity_pollset_set(&c->pollent));
pending_request->next = c->pending_requests;
c->pending_requests = pending_request;
bool start_fetch = false;
@@ -291,17 +286,17 @@ static bool oauth2_token_fetcher_get_request_metadata(
gpr_mu_unlock(&c->mu);
if (start_fetch) {
grpc_call_credentials_ref(creds);
- c->fetch_func(exec_ctx, grpc_credentials_metadata_request_create(creds),
+ c->fetch_func(grpc_credentials_metadata_request_create(creds),
&c->httpcli_context, &c->pollent,
on_oauth2_token_fetcher_http_response,
- grpc_exec_ctx_now(exec_ctx) + refresh_threshold);
+ grpc_core::ExecCtx::Get()->Now() + refresh_threshold);
}
return false;
}
static void oauth2_token_fetcher_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
grpc_oauth2_token_fetcher_credentials* c =
(grpc_oauth2_token_fetcher_credentials*)creds;
gpr_mu_lock(&c->mu);
@@ -317,7 +312,7 @@ static void oauth2_token_fetcher_cancel_get_request_metadata(
c->pending_requests = pending_request->next;
}
// Invoke the callback immediately with an error.
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata,
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata,
GRPC_ERROR_REF(error));
gpr_free(pending_request);
break;
@@ -351,7 +346,7 @@ static grpc_call_credentials_vtable compute_engine_vtable = {
oauth2_token_fetcher_cancel_get_request_metadata};
static void compute_engine_fetch_oauth2(
- grpc_exec_ctx* exec_ctx, grpc_credentials_metadata_request* metadata_req,
+ grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent,
grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
grpc_http_header header = {(char*)"Metadata-Flavor", (char*)"Google"};
@@ -367,10 +362,10 @@ static void compute_engine_fetch_oauth2(
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("oauth2_credentials");
grpc_httpcli_get(
- exec_ctx, httpcli_context, pollent, resource_quota, &request, deadline,
+ httpcli_context, pollent, resource_quota, &request, deadline,
GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
}
grpc_call_credentials* grpc_google_compute_engine_credentials_create(
@@ -390,12 +385,11 @@ grpc_call_credentials* grpc_google_compute_engine_credentials_create(
// Google Refresh Token credentials.
//
-static void refresh_token_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void refresh_token_destruct(grpc_call_credentials* creds) {
grpc_google_refresh_token_credentials* c =
(grpc_google_refresh_token_credentials*)creds;
grpc_auth_refresh_token_destruct(&c->refresh_token);
- oauth2_token_fetcher_destruct(exec_ctx, &c->base.base);
+ oauth2_token_fetcher_destruct(&c->base.base);
}
static grpc_call_credentials_vtable refresh_token_vtable = {
@@ -403,7 +397,7 @@ static grpc_call_credentials_vtable refresh_token_vtable = {
oauth2_token_fetcher_cancel_get_request_metadata};
static void refresh_token_fetch_oauth2(
- grpc_exec_ctx* exec_ctx, grpc_credentials_metadata_request* metadata_req,
+ grpc_credentials_metadata_request* metadata_req,
grpc_httpcli_context* httpcli_context, grpc_polling_entity* pollent,
grpc_iomgr_cb_func response_cb, grpc_millis deadline) {
grpc_google_refresh_token_credentials* c =
@@ -427,11 +421,11 @@ static void refresh_token_fetch_oauth2(
grpc_resource_quota* resource_quota =
grpc_resource_quota_create("oauth2_credentials_refresh");
grpc_httpcli_post(
- exec_ctx, httpcli_context, pollent, resource_quota, &request, body,
- strlen(body), deadline,
+ httpcli_context, pollent, resource_quota, &request, body, strlen(body),
+ deadline,
GRPC_CLOSURE_CREATE(response_cb, metadata_req, grpc_schedule_on_exec_ctx),
&metadata_req->response);
- grpc_resource_quota_unref_internal(exec_ctx, resource_quota);
+ grpc_resource_quota_unref_internal(resource_quota);
gpr_free(body);
}
@@ -483,25 +477,23 @@ grpc_call_credentials* grpc_google_refresh_token_credentials_create(
// Oauth2 Access Token credentials.
//
-static void access_token_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void access_token_destruct(grpc_call_credentials* creds) {
grpc_access_token_credentials* c = (grpc_access_token_credentials*)creds;
- GRPC_MDELEM_UNREF(exec_ctx, c->access_token_md);
+ GRPC_MDELEM_UNREF(c->access_token_md);
}
static bool access_token_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_polling_entity* pollent, grpc_auth_metadata_context context,
- grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata,
- grpc_error** error) {
+ grpc_call_credentials* creds, grpc_polling_entity* pollent,
+ grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array,
+ grpc_closure* on_request_metadata, grpc_error** error) {
grpc_access_token_credentials* c = (grpc_access_token_credentials*)creds;
grpc_credentials_mdelem_array_add(md_array, c->access_token_md);
return true;
}
static void access_token_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);
}
@@ -523,11 +515,11 @@ grpc_call_credentials* grpc_access_token_credentials_create(
gpr_ref_init(&c->base.refcount, 1);
char* token_md_value;
gpr_asprintf(&token_md_value, "Bearer %s", access_token);
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
c->access_token_md = grpc_mdelem_from_slices(
- &exec_ctx, grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
+ grpc_slice_from_static_string(GRPC_AUTHORIZATION_METADATA_KEY),
grpc_slice_from_copied_string(token_md_value));
- grpc_exec_ctx_finish(&exec_ctx);
+
gpr_free(token_md_value);
return &c->base;
}
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
index 627783d648..e5b8df8eb9 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h
@@ -52,8 +52,7 @@ void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token);
// This object is a base for credentials that need to acquire an oauth2 token
// from an http service.
-typedef void (*grpc_fetch_oauth2_func)(grpc_exec_ctx* exec_ctx,
- grpc_credentials_metadata_request* req,
+typedef void (*grpc_fetch_oauth2_func)(grpc_credentials_metadata_request* req,
grpc_httpcli_context* http_context,
grpc_polling_entity* pollent,
grpc_iomgr_cb_func cb,
@@ -99,7 +98,7 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token(
// Exposed for testing only.
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
- grpc_exec_ctx* exec_ctx, const struct grpc_http_response* response,
- grpc_mdelem* token_md, grpc_millis* token_lifetime);
+ const struct grpc_http_response* response, grpc_mdelem* token_md,
+ grpc_millis* token_lifetime);
#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */
diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
index 1f1efd078d..203ba58c67 100644
--- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc
+++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc
@@ -33,8 +33,7 @@
grpc_core::TraceFlag grpc_plugin_credentials_trace(false, "plugin_credentials");
-static void plugin_destruct(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds) {
+static void plugin_destruct(grpc_call_credentials* creds) {
grpc_plugin_credentials* c = (grpc_plugin_credentials*)creds;
gpr_mu_destroy(&c->mu);
if (c->plugin.state != nullptr && c->plugin.destroy != nullptr) {
@@ -61,18 +60,17 @@ static void pending_request_remove_locked(
// When this returns, r->cancelled indicates whether the request was
// cancelled before completion.
static void pending_request_complete(
- grpc_exec_ctx* exec_ctx, grpc_plugin_credentials_pending_request* r) {
+ grpc_plugin_credentials_pending_request* r) {
gpr_mu_lock(&r->creds->mu);
if (!r->cancelled) pending_request_remove_locked(r->creds, r);
gpr_mu_unlock(&r->creds->mu);
// Ref to credentials not needed anymore.
- grpc_call_credentials_unref(exec_ctx, &r->creds->base);
+ grpc_call_credentials_unref(&r->creds->base);
}
static grpc_error* process_plugin_result(
- grpc_exec_ctx* exec_ctx, grpc_plugin_credentials_pending_request* r,
- const grpc_metadata* md, size_t num_md, grpc_status_code status,
- const char* error_details) {
+ grpc_plugin_credentials_pending_request* r, const grpc_metadata* md,
+ size_t num_md, grpc_status_code status, const char* error_details) {
grpc_error* error = GRPC_ERROR_NONE;
if (status != GRPC_STATUS_OK) {
char* msg;
@@ -100,11 +98,11 @@ static grpc_error* process_plugin_result(
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Illegal metadata");
} else {
for (size_t i = 0; i < num_md; ++i) {
- grpc_mdelem mdelem = grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_ref_internal(md[i].key),
- grpc_slice_ref_internal(md[i].value));
+ grpc_mdelem mdelem =
+ grpc_mdelem_from_slices(grpc_slice_ref_internal(md[i].key),
+ grpc_slice_ref_internal(md[i].value));
grpc_credentials_mdelem_array_add(r->md_array, mdelem);
- GRPC_MDELEM_UNREF(exec_ctx, mdelem);
+ GRPC_MDELEM_UNREF(mdelem);
}
}
}
@@ -117,9 +115,8 @@ static void plugin_md_request_metadata_ready(void* request,
grpc_status_code status,
const char* error_details) {
/* called from application code */
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INITIALIZER(
- GRPC_EXEC_CTX_FLAG_IS_FINISHED | GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP,
- nullptr, nullptr);
+ grpc_core::ExecCtx exec_ctx(GRPC_EXEC_CTX_FLAG_IS_FINISHED |
+ GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP);
grpc_plugin_credentials_pending_request* r =
(grpc_plugin_credentials_pending_request*)request;
if (grpc_plugin_credentials_trace.enabled()) {
@@ -129,12 +126,12 @@ static void plugin_md_request_metadata_ready(void* request,
r->creds, r);
}
// Remove request from pending list if not previously cancelled.
- pending_request_complete(&exec_ctx, r);
+ pending_request_complete(r);
// If it has not been cancelled, process it.
if (!r->cancelled) {
grpc_error* error =
- process_plugin_result(&exec_ctx, r, md, num_md, status, error_details);
- GRPC_CLOSURE_SCHED(&exec_ctx, r->on_request_metadata, error);
+ process_plugin_result(r, md, num_md, status, error_details);
+ GRPC_CLOSURE_SCHED(r->on_request_metadata, error);
} else if (grpc_plugin_credentials_trace.enabled()) {
gpr_log(GPR_INFO,
"plugin_credentials[%p]: request %p: plugin was previously "
@@ -142,11 +139,9 @@ static void plugin_md_request_metadata_ready(void* request,
r->creds, r);
}
gpr_free(r);
- grpc_exec_ctx_finish(&exec_ctx);
}
-static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_credentials* creds,
+static bool plugin_get_request_metadata(grpc_call_credentials* creds,
grpc_polling_entity* pollent,
grpc_auth_metadata_context context,
grpc_credentials_mdelem_array* md_array,
@@ -194,7 +189,7 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
}
// Returned synchronously.
// Remove request from pending list if not previously cancelled.
- pending_request_complete(exec_ctx, pending_request);
+ pending_request_complete(pending_request);
// If the request was cancelled, the error will have been returned
// asynchronously by plugin_cancel_get_request_metadata(), so return
// false. Otherwise, process the result.
@@ -213,13 +208,13 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
"synchronously",
c, pending_request);
}
- *error = process_plugin_result(exec_ctx, pending_request, creds_md,
- num_creds_md, status, error_details);
+ *error = process_plugin_result(pending_request, creds_md, num_creds_md,
+ status, error_details);
}
// Clean up.
for (size_t i = 0; i < num_creds_md; ++i) {
- grpc_slice_unref_internal(exec_ctx, creds_md[i].key);
- grpc_slice_unref_internal(exec_ctx, creds_md[i].value);
+ grpc_slice_unref_internal(creds_md[i].key);
+ grpc_slice_unref_internal(creds_md[i].value);
}
gpr_free((void*)error_details);
gpr_free(pending_request);
@@ -228,8 +223,8 @@ static bool plugin_get_request_metadata(grpc_exec_ctx* exec_ctx,
}
static void plugin_cancel_get_request_metadata(
- grpc_exec_ctx* exec_ctx, grpc_call_credentials* creds,
- grpc_credentials_mdelem_array* md_array, grpc_error* error) {
+ grpc_call_credentials* creds, grpc_credentials_mdelem_array* md_array,
+ grpc_error* error) {
grpc_plugin_credentials* c = (grpc_plugin_credentials*)creds;
gpr_mu_lock(&c->mu);
for (grpc_plugin_credentials_pending_request* pending_request =
@@ -241,7 +236,7 @@ static void plugin_cancel_get_request_metadata(
pending_request);
}
pending_request->cancelled = true;
- GRPC_CLOSURE_SCHED(exec_ctx, pending_request->on_request_metadata,
+ GRPC_CLOSURE_SCHED(pending_request->on_request_metadata,
GRPC_ERROR_REF(error));
pending_request_remove_locked(c, pending_request);
break;
diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc
index 39dd38cf88..d8546441c9 100644
--- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc
+++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc
@@ -41,18 +41,16 @@ void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp,
gpr_free(kp);
}
-static void ssl_destruct(grpc_exec_ctx* exec_ctx,
- grpc_channel_credentials* creds) {
+static void ssl_destruct(grpc_channel_credentials* creds) {
grpc_ssl_credentials* c = (grpc_ssl_credentials*)creds;
gpr_free(c->config.pem_root_certs);
grpc_tsi_ssl_pem_key_cert_pairs_destroy(c->config.pem_key_cert_pair, 1);
}
static grpc_security_status ssl_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* creds,
- grpc_call_credentials* call_creds, const char* target,
- const grpc_channel_args* args, grpc_channel_security_connector** sc,
- grpc_channel_args** new_args) {
+ grpc_channel_credentials* creds, grpc_call_credentials* call_creds,
+ const char* target, const grpc_channel_args* args,
+ grpc_channel_security_connector** sc, grpc_channel_args** new_args) {
grpc_ssl_credentials* c = (grpc_ssl_credentials*)creds;
grpc_security_status status = GRPC_SECURITY_OK;
const char* overridden_target_name = nullptr;
@@ -65,8 +63,7 @@ static grpc_security_status ssl_create_security_connector(
}
}
status = grpc_ssl_channel_security_connector_create(
- exec_ctx, creds, call_creds, &c->config, target, overridden_target_name,
- sc);
+ creds, call_creds, &c->config, target, overridden_target_name, sc);
if (status != GRPC_SECURITY_OK) {
return status;
}
@@ -125,8 +122,7 @@ struct grpc_ssl_server_credentials_options {
grpc_ssl_server_certificate_config_fetcher* certificate_config_fetcher;
};
-static void ssl_server_destruct(grpc_exec_ctx* exec_ctx,
- grpc_server_credentials* creds) {
+static void ssl_server_destruct(grpc_server_credentials* creds) {
grpc_ssl_server_credentials* c = (grpc_ssl_server_credentials*)creds;
grpc_tsi_ssl_pem_key_cert_pairs_destroy(c->config.pem_key_cert_pairs,
c->config.num_key_cert_pairs);
@@ -134,9 +130,8 @@ static void ssl_server_destruct(grpc_exec_ctx* exec_ctx,
}
static grpc_security_status ssl_server_create_security_connector(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* creds,
- grpc_server_security_connector** sc) {
- return grpc_ssl_server_security_connector_create(exec_ctx, creds, sc);
+ grpc_server_credentials* creds, grpc_server_security_connector** sc) {
+ return grpc_ssl_server_security_connector_create(creds, sc);
}
static grpc_server_credentials_vtable ssl_server_vtable = {
diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc
index 326f4d7773..cd3c2e3f19 100644
--- a/src/core/lib/security/transport/client_auth_filter.cc
+++ b/src/core/lib/security/transport/client_auth_filter.cc
@@ -90,8 +90,7 @@ static void add_error(grpc_error** combined, grpc_error* error) {
*combined = grpc_error_add_child(*combined, error);
}
-static void on_credentials_metadata(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* input_error) {
+static void on_credentials_metadata(void* arg, grpc_error* input_error) {
grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
grpc_call_element* elem =
(grpc_call_element*)batch->handler_private.extra_arg;
@@ -105,16 +104,16 @@ static void on_credentials_metadata(grpc_exec_ctx* exec_ctx, void* arg,
batch->payload->send_initial_metadata.send_initial_metadata;
for (size_t i = 0; i < calld->md_array.size; ++i) {
add_error(&error, grpc_metadata_batch_add_tail(
- exec_ctx, mdb, &calld->md_links[i],
+ mdb, &calld->md_links[i],
GRPC_MDELEM_REF(calld->md_array.md[i])));
}
}
if (error == GRPC_ERROR_NONE) {
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
} else {
error = grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAUTHENTICATED);
- grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, batch, error,
+ grpc_transport_stream_op_batch_finish_with_failure(batch, error,
calld->call_combiner);
}
}
@@ -156,20 +155,17 @@ void grpc_auth_metadata_context_build(
gpr_free(host_and_port);
}
-static void cancel_get_request_metadata(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void cancel_get_request_metadata(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
if (error != GRPC_ERROR_NONE) {
grpc_call_credentials_cancel_get_request_metadata(
- exec_ctx, calld->creds, &calld->md_array, GRPC_ERROR_REF(error));
+ calld->creds, &calld->md_array, GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call,
- "cancel_get_request_metadata");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_get_request_metadata");
}
-static void send_security_metadata(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void send_security_metadata(grpc_call_element* elem,
grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
@@ -183,7 +179,7 @@ static void send_security_metadata(grpc_exec_ctx* exec_ctx,
if (channel_call_creds == nullptr && !call_creds_has_md) {
/* Skip sending metadata altogether. */
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
return;
}
@@ -192,7 +188,7 @@ static void send_security_metadata(grpc_exec_ctx* exec_ctx,
ctx->creds, nullptr);
if (calld->creds == nullptr) {
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch,
+ batch,
grpc_error_set_int(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Incompatible credentials set on channel and call."),
@@ -215,30 +211,29 @@ static void send_security_metadata(grpc_exec_ctx* exec_ctx,
batch, grpc_schedule_on_exec_ctx);
grpc_error* error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- exec_ctx, calld->creds, calld->pollent, calld->auth_md_context,
+ calld->creds, calld->pollent, calld->auth_md_context,
&calld->md_array, &calld->async_result_closure, &error)) {
// Synchronous return; invoke on_credentials_metadata() directly.
- on_credentials_metadata(exec_ctx, batch, error);
+ on_credentials_metadata(batch, error);
GRPC_ERROR_UNREF(error);
} else {
// Async return; register cancellation closure with call combiner.
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_get_request_metadata");
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&calld->get_request_metadata_cancel_closure,
cancel_get_request_metadata, elem,
grpc_schedule_on_exec_ctx));
}
}
-static void on_host_checked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_host_checked(void* arg, grpc_error* error) {
grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
grpc_call_element* elem =
(grpc_call_element*)batch->handler_private.extra_arg;
call_data* calld = (call_data*)elem->call_data;
if (error == GRPC_ERROR_NONE) {
- send_security_metadata(exec_ctx, elem, batch);
+ send_security_metadata(elem, batch);
} else {
char* error_msg;
char* host = grpc_slice_to_c_string(calld->host);
@@ -246,7 +241,7 @@ static void on_host_checked(grpc_exec_ctx* exec_ctx, void* arg,
host);
gpr_free(host);
grpc_transport_stream_op_batch_finish_with_failure(
- exec_ctx, batch,
+ batch,
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_msg),
GRPC_ERROR_INT_GRPC_STATUS,
GRPC_STATUS_UNAUTHENTICATED),
@@ -255,22 +250,20 @@ static void on_host_checked(grpc_exec_ctx* exec_ctx, void* arg,
}
}
-static void cancel_check_call_host(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void cancel_check_call_host(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
if (error != GRPC_ERROR_NONE) {
grpc_channel_security_connector_cancel_check_call_host(
- exec_ctx, chand->security_connector, &calld->async_result_closure,
+ chand->security_connector, &calld->async_result_closure,
GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_check_call_host");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_check_call_host");
}
static void auth_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
GPR_TIMER_BEGIN("auth_start_transport_stream_op_batch", 0);
/* grab pointers to our data from the call element */
@@ -303,13 +296,13 @@ static void auth_start_transport_stream_op_batch(
*/
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_AUTHORITY)) {
if (calld->have_host) {
- grpc_slice_unref_internal(exec_ctx, calld->host);
+ grpc_slice_unref_internal(calld->host);
}
calld->host = grpc_slice_ref_internal(GRPC_MDVALUE(md));
calld->have_host = true;
} else if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_PATH)) {
if (calld->have_method) {
- grpc_slice_unref_internal(exec_ctx, calld->method);
+ grpc_slice_unref_internal(calld->method);
}
calld->method = grpc_slice_ref_internal(GRPC_MDVALUE(md));
calld->have_method = true;
@@ -322,16 +315,16 @@ static void auth_start_transport_stream_op_batch(
char* call_host = grpc_slice_to_c_string(calld->host);
grpc_error* error = GRPC_ERROR_NONE;
if (grpc_channel_security_connector_check_call_host(
- exec_ctx, chand->security_connector, call_host,
- chand->auth_context, &calld->async_result_closure, &error)) {
+ chand->security_connector, call_host, chand->auth_context,
+ &calld->async_result_closure, &error)) {
// Synchronous return; invoke on_host_checked() directly.
- on_host_checked(exec_ctx, batch, error);
+ on_host_checked(batch, error);
GRPC_ERROR_UNREF(error);
} else {
// Async return; register cancellation closure with call combiner.
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_check_call_host");
grpc_call_combiner_set_notify_on_cancel(
- exec_ctx, calld->call_combiner,
+ calld->call_combiner,
GRPC_CLOSURE_INIT(&calld->check_call_host_cancel_closure,
cancel_check_call_host, elem,
grpc_schedule_on_exec_ctx));
@@ -343,13 +336,12 @@ static void auth_start_transport_stream_op_batch(
}
/* pass control down the stack */
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
GPR_TIMER_END("auth_start_transport_stream_op_batch", 0);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
calld->owning_call = args->call_stack;
@@ -357,32 +349,30 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE;
}
-static void set_pollset_or_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void set_pollset_or_pollset_set(grpc_call_element* elem,
grpc_polling_entity* pollent) {
call_data* calld = (call_data*)elem->call_data;
calld->pollent = pollent;
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
call_data* calld = (call_data*)elem->call_data;
- grpc_credentials_mdelem_array_destroy(exec_ctx, &calld->md_array);
- grpc_call_credentials_unref(exec_ctx, calld->creds);
+ grpc_credentials_mdelem_array_destroy(&calld->md_array);
+ grpc_call_credentials_unref(calld->creds);
if (calld->have_host) {
- grpc_slice_unref_internal(exec_ctx, calld->host);
+ grpc_slice_unref_internal(calld->host);
}
if (calld->have_method) {
- grpc_slice_unref_internal(exec_ctx, calld->method);
+ grpc_slice_unref_internal(calld->method);
}
grpc_auth_metadata_context_reset(&calld->auth_md_context);
}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
grpc_security_connector* sc =
grpc_security_connector_find_in_args(args->channel_args);
@@ -415,13 +405,12 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
/* grab pointers to our data from the channel element */
channel_data* chand = (channel_data*)elem->channel_data;
grpc_channel_security_connector* sc = chand->security_connector;
if (sc != nullptr) {
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, &sc->base, "client_auth_filter");
+ GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "client_auth_filter");
}
GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "client_auth_filter");
}
diff --git a/src/core/lib/security/transport/lb_targets_info.cc b/src/core/lib/security/transport/lb_targets_info.cc
index c07be35840..183b1ebf35 100644
--- a/src/core/lib/security/transport/lb_targets_info.cc
+++ b/src/core/lib/security/transport/lb_targets_info.cc
@@ -28,8 +28,8 @@
static void* targets_info_copy(void* p) {
return grpc_slice_hash_table_ref((grpc_slice_hash_table*)p);
}
-static void targets_info_destroy(grpc_exec_ctx* exec_ctx, void* p) {
- grpc_slice_hash_table_unref(exec_ctx, (grpc_slice_hash_table*)p);
+static void targets_info_destroy(void* p) {
+ grpc_slice_hash_table_unref((grpc_slice_hash_table*)p);
}
static int targets_info_cmp(void* a, void* b) {
return grpc_slice_hash_table_cmp((const grpc_slice_hash_table*)a,
diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc
index 4cd317a06d..e5c089de9c 100644
--- a/src/core/lib/security/transport/secure_endpoint.cc
+++ b/src/core/lib/security/transport/secure_endpoint.cc
@@ -63,28 +63,27 @@ typedef struct {
grpc_core::TraceFlag grpc_trace_secure_endpoint(false, "secure_endpoint");
-static void destroy(grpc_exec_ctx* exec_ctx, secure_endpoint* secure_ep) {
+static void destroy(secure_endpoint* secure_ep) {
secure_endpoint* ep = secure_ep;
- grpc_endpoint_destroy(exec_ctx, ep->wrapped_ep);
+ grpc_endpoint_destroy(ep->wrapped_ep);
tsi_frame_protector_destroy(ep->protector);
- tsi_zero_copy_grpc_protector_destroy(exec_ctx, ep->zero_copy_protector);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->leftover_bytes);
- grpc_slice_unref_internal(exec_ctx, ep->read_staging_buffer);
- grpc_slice_unref_internal(exec_ctx, ep->write_staging_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->output_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &ep->source_buffer);
+ tsi_zero_copy_grpc_protector_destroy(ep->zero_copy_protector);
+ grpc_slice_buffer_destroy_internal(&ep->leftover_bytes);
+ grpc_slice_unref_internal(ep->read_staging_buffer);
+ grpc_slice_unref_internal(ep->write_staging_buffer);
+ grpc_slice_buffer_destroy_internal(&ep->output_buffer);
+ grpc_slice_buffer_destroy_internal(&ep->source_buffer);
gpr_mu_destroy(&ep->protector_mu);
gpr_free(ep);
}
#ifndef NDEBUG
-#define SECURE_ENDPOINT_UNREF(exec_ctx, ep, reason) \
- secure_endpoint_unref((exec_ctx), (ep), (reason), __FILE__, __LINE__)
+#define SECURE_ENDPOINT_UNREF(ep, reason) \
+ secure_endpoint_unref((ep), (reason), __FILE__, __LINE__)
#define SECURE_ENDPOINT_REF(ep, reason) \
secure_endpoint_ref((ep), (reason), __FILE__, __LINE__)
-static void secure_endpoint_unref(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
- const char* reason, const char* file,
- int line) {
+static void secure_endpoint_unref(secure_endpoint* ep, const char* reason,
+ const char* file, int line) {
if (grpc_trace_secure_endpoint.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&ep->ref.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@@ -92,7 +91,7 @@ static void secure_endpoint_unref(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
val - 1);
}
if (gpr_unref(&ep->ref)) {
- destroy(exec_ctx, ep);
+ destroy(ep);
}
}
@@ -107,13 +106,11 @@ static void secure_endpoint_ref(secure_endpoint* ep, const char* reason,
gpr_ref(&ep->ref);
}
#else
-#define SECURE_ENDPOINT_UNREF(exec_ctx, ep, reason) \
- secure_endpoint_unref((exec_ctx), (ep))
+#define SECURE_ENDPOINT_UNREF(ep, reason) secure_endpoint_unref((ep))
#define SECURE_ENDPOINT_REF(ep, reason) secure_endpoint_ref((ep))
-static void secure_endpoint_unref(grpc_exec_ctx* exec_ctx,
- secure_endpoint* ep) {
+static void secure_endpoint_unref(secure_endpoint* ep) {
if (gpr_unref(&ep->ref)) {
- destroy(exec_ctx, ep);
+ destroy(ep);
}
}
@@ -128,8 +125,7 @@ static void flush_read_staging_buffer(secure_endpoint* ep, uint8_t** cur,
*end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
}
-static void call_read_cb(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
- grpc_error* error) {
+static void call_read_cb(secure_endpoint* ep, grpc_error* error) {
if (grpc_trace_secure_endpoint.enabled()) {
size_t i;
for (i = 0; i < ep->read_buffer->count; i++) {
@@ -140,12 +136,11 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, secure_endpoint* ep,
}
}
ep->read_buffer = nullptr;
- GRPC_CLOSURE_SCHED(exec_ctx, ep->read_cb, error);
- SECURE_ENDPOINT_UNREF(exec_ctx, ep, "read");
+ GRPC_CLOSURE_SCHED(ep->read_cb, error);
+ SECURE_ENDPOINT_UNREF(ep, "read");
}
-static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
- grpc_error* error) {
+static void on_read(void* user_data, grpc_error* error) {
unsigned i;
uint8_t keep_looping = 0;
tsi_result result = TSI_OK;
@@ -154,17 +149,16 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
uint8_t* end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
if (error != GRPC_ERROR_NONE) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
- call_read_cb(exec_ctx, ep,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Secure read failed", &error, 1));
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
+ call_read_cb(ep, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Secure read failed", &error, 1));
return;
}
if (ep->zero_copy_protector != nullptr) {
// Use zero-copy grpc protector to unprotect.
result = tsi_zero_copy_grpc_protector_unprotect(
- exec_ctx, ep->zero_copy_protector, &ep->source_buffer, ep->read_buffer);
+ ep->zero_copy_protector, &ep->source_buffer, ep->read_buffer);
} else {
// Use frame protector to unprotect.
/* TODO(yangg) check error, maybe bail out early */
@@ -217,37 +211,35 @@ static void on_read(grpc_exec_ctx* exec_ctx, void* user_data,
/* TODO(yangg) experiment with moving this block after read_cb to see if it
helps latency */
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->source_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->source_buffer);
if (result != TSI_OK) {
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
call_read_cb(
- exec_ctx, ep,
- grpc_set_tsi_error_result(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result));
+ ep, grpc_set_tsi_error_result(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unwrap failed"), result));
return;
}
- call_read_cb(exec_ctx, ep, GRPC_ERROR_NONE);
+ call_read_cb(ep, GRPC_ERROR_NONE);
}
-static void endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void endpoint_read(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
ep->read_cb = cb;
ep->read_buffer = slices;
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, ep->read_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(ep->read_buffer);
SECURE_ENDPOINT_REF(ep, "read");
if (ep->leftover_bytes.count) {
grpc_slice_buffer_swap(&ep->leftover_bytes, &ep->source_buffer);
GPR_ASSERT(ep->leftover_bytes.count == 0);
- on_read(exec_ctx, ep, GRPC_ERROR_NONE);
+ on_read(ep, GRPC_ERROR_NONE);
return;
}
- grpc_endpoint_read(exec_ctx, ep->wrapped_ep, &ep->source_buffer,
- &ep->on_read);
+ grpc_endpoint_read(ep->wrapped_ep, &ep->source_buffer, &ep->on_read);
}
static void flush_write_staging_buffer(secure_endpoint* ep, uint8_t** cur,
@@ -258,8 +250,8 @@ static void flush_write_staging_buffer(secure_endpoint* ep, uint8_t** cur,
*end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
}
-static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
- grpc_slice_buffer* slices, grpc_closure* cb) {
+static void endpoint_write(grpc_endpoint* secure_ep, grpc_slice_buffer* slices,
+ grpc_closure* cb) {
GPR_TIMER_BEGIN("secure_endpoint.endpoint_write", 0);
unsigned i;
@@ -268,7 +260,7 @@ static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
uint8_t* cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer);
uint8_t* end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer);
if (grpc_trace_secure_endpoint.enabled()) {
for (i = 0; i < slices->count; i++) {
@@ -281,8 +273,8 @@ static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
if (ep->zero_copy_protector != nullptr) {
// Use zero-copy grpc protector to protect.
- result = tsi_zero_copy_grpc_protector_protect(
- exec_ctx, ep->zero_copy_protector, slices, &ep->output_buffer);
+ result = tsi_zero_copy_grpc_protector_protect(ep->zero_copy_protector,
+ slices, &ep->output_buffer);
} else {
// Use frame protector to protect.
for (i = 0; i < slices->count; i++) {
@@ -340,50 +332,44 @@ static void endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
if (result != TSI_OK) {
/* TODO(yangg) do different things according to the error type? */
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &ep->output_buffer);
+ grpc_slice_buffer_reset_and_unref_internal(&ep->output_buffer);
GRPC_CLOSURE_SCHED(
- exec_ctx, cb,
- grpc_set_tsi_error_result(
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result));
+ cb, grpc_set_tsi_error_result(
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Wrap failed"), result));
GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
return;
}
- grpc_endpoint_write(exec_ctx, ep->wrapped_ep, &ep->output_buffer, cb);
+ grpc_endpoint_write(ep->wrapped_ep, &ep->output_buffer, cb);
GPR_TIMER_END("secure_endpoint.endpoint_write", 0);
}
-static void endpoint_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* secure_ep,
- grpc_error* why) {
+static void endpoint_shutdown(grpc_endpoint* secure_ep, grpc_error* why) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- grpc_endpoint_shutdown(exec_ctx, ep->wrapped_ep, why);
+ grpc_endpoint_shutdown(ep->wrapped_ep, why);
}
-static void endpoint_destroy(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* secure_ep) {
+static void endpoint_destroy(grpc_endpoint* secure_ep) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- SECURE_ENDPOINT_UNREF(exec_ctx, ep, "destroy");
+ SECURE_ENDPOINT_UNREF(ep, "destroy");
}
-static void endpoint_add_to_pollset(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* secure_ep,
+static void endpoint_add_to_pollset(grpc_endpoint* secure_ep,
grpc_pollset* pollset) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- grpc_endpoint_add_to_pollset(exec_ctx, ep->wrapped_ep, pollset);
+ grpc_endpoint_add_to_pollset(ep->wrapped_ep, pollset);
}
-static void endpoint_add_to_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* secure_ep,
+static void endpoint_add_to_pollset_set(grpc_endpoint* secure_ep,
grpc_pollset_set* pollset_set) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- grpc_endpoint_add_to_pollset_set(exec_ctx, ep->wrapped_ep, pollset_set);
+ grpc_endpoint_add_to_pollset_set(ep->wrapped_ep, pollset_set);
}
-static void endpoint_delete_from_pollset_set(grpc_exec_ctx* exec_ctx,
- grpc_endpoint* secure_ep,
+static void endpoint_delete_from_pollset_set(grpc_endpoint* secure_ep,
grpc_pollset_set* pollset_set) {
secure_endpoint* ep = (secure_endpoint*)secure_ep;
- grpc_endpoint_delete_from_pollset_set(exec_ctx, ep->wrapped_ep, pollset_set);
+ grpc_endpoint_delete_from_pollset_set(ep->wrapped_ep, pollset_set);
}
static char* endpoint_get_peer(grpc_endpoint* secure_ep) {
diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc
index c56e459aeb..fd139714da 100644
--- a/src/core/lib/security/transport/security_connector.cc
+++ b/src/core/lib/security/transport/security_connector.cc
@@ -105,33 +105,32 @@ const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* peer,
}
void grpc_channel_security_connector_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* connector,
+ grpc_channel_security_connector* connector,
grpc_handshake_manager* handshake_mgr) {
if (connector != nullptr) {
- connector->add_handshakers(exec_ctx, connector, handshake_mgr);
+ connector->add_handshakers(connector, handshake_mgr);
}
}
void grpc_server_security_connector_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_server_security_connector* connector,
+ grpc_server_security_connector* connector,
grpc_handshake_manager* handshake_mgr) {
if (connector != nullptr) {
- connector->add_handshakers(exec_ctx, connector, handshake_mgr);
+ connector->add_handshakers(connector, handshake_mgr);
}
}
-void grpc_security_connector_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc,
+void grpc_security_connector_check_peer(grpc_security_connector* sc,
tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
if (sc == nullptr) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked,
+ GRPC_CLOSURE_SCHED(on_peer_checked,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"cannot check peer -- no security connector"));
tsi_peer_destruct(&peer);
} else {
- sc->vtable->check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
+ sc->vtable->check_peer(sc, peer, auth_context, on_peer_checked);
}
}
@@ -169,26 +168,26 @@ int grpc_server_security_connector_cmp(grpc_server_security_connector* sc1,
}
bool grpc_channel_security_connector_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- const char* host, grpc_auth_context* auth_context,
- grpc_closure* on_call_host_checked, grpc_error** error) {
+ grpc_channel_security_connector* sc, const char* host,
+ grpc_auth_context* auth_context, grpc_closure* on_call_host_checked,
+ grpc_error** error) {
if (sc == nullptr || sc->check_call_host == nullptr) {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"cannot check call host -- no security connector");
return true;
}
- return sc->check_call_host(exec_ctx, sc, host, auth_context,
- on_call_host_checked, error);
+ return sc->check_call_host(sc, host, auth_context, on_call_host_checked,
+ error);
}
void grpc_channel_security_connector_cancel_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- grpc_closure* on_call_host_checked, grpc_error* error) {
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
if (sc == nullptr || sc->cancel_check_call_host == nullptr) {
GRPC_ERROR_UNREF(error);
return;
}
- sc->cancel_check_call_host(exec_ctx, sc, on_call_host_checked, error);
+ sc->cancel_check_call_host(sc, on_call_host_checked, error);
}
#ifndef NDEBUG
@@ -205,15 +204,14 @@ grpc_security_connector* grpc_security_connector_ref(
#else
grpc_security_connector* grpc_security_connector_ref(
grpc_security_connector* sc) {
- if (sc == NULL) return NULL;
+ if (sc == nullptr) return nullptr;
#endif
gpr_ref(&sc->refcount);
return sc;
}
#ifndef NDEBUG
-void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc,
+void grpc_security_connector_unref(grpc_security_connector* sc,
const char* file, int line,
const char* reason) {
if (sc == nullptr) return;
@@ -224,15 +222,14 @@ void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
val, val - 1, reason);
}
#else
-void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
- if (sc == NULL) return;
+void grpc_security_connector_unref(grpc_security_connector* sc) {
+ if (sc == nullptr) return;
#endif
- if (gpr_unref(&sc->refcount)) sc->vtable->destroy(exec_ctx, sc);
+ if (gpr_unref(&sc->refcount)) sc->vtable->destroy(sc);
}
-static void connector_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) {
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, (grpc_security_connector*)p,
+static void connector_arg_destroy(void* p) {
+ GRPC_SECURITY_CONNECTOR_UNREF((grpc_security_connector*)p,
"connector_arg_destroy");
}
@@ -309,20 +306,16 @@ typedef struct {
bool is_lb_channel;
} grpc_fake_channel_security_connector;
-static void fake_channel_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
+static void fake_channel_destroy(grpc_security_connector* sc) {
grpc_fake_channel_security_connector* c =
(grpc_fake_channel_security_connector*)sc;
- grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
+ grpc_call_credentials_unref(c->base.request_metadata_creds);
gpr_free(c->target);
gpr_free(c->expected_targets);
gpr_free(c);
}
-static void fake_server_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
- gpr_free(sc);
-}
+static void fake_server_destroy(grpc_security_connector* sc) { gpr_free(sc); }
static bool fake_check_target(const char* target_type, const char* target,
const char* set_str) {
@@ -386,8 +379,7 @@ done:
if (!success) abort();
}
-static void fake_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void fake_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
const char* prop_name;
@@ -419,25 +411,23 @@ static void fake_check_peer(grpc_exec_ctx* exec_ctx,
*auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
end:
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
tsi_peer_destruct(&peer);
}
-static void fake_channel_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void fake_channel_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
- fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
+ fake_check_peer(sc, peer, auth_context, on_peer_checked);
grpc_fake_channel_security_connector* c =
(grpc_fake_channel_security_connector*)sc;
fake_secure_name_check(c->target, c->expected_targets, c->is_lb_channel);
}
-static void fake_server_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void fake_server_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
- fake_check_peer(exec_ctx, sc, peer, auth_context, on_peer_checked);
+ fake_check_peer(sc, peer, auth_context, on_peer_checked);
}
static int fake_channel_cmp(grpc_security_connector* sc1,
@@ -466,8 +456,7 @@ static int fake_server_cmp(grpc_security_connector* sc1,
(grpc_server_security_connector*)sc2);
}
-static bool fake_channel_check_call_host(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+static bool fake_channel_check_call_host(grpc_channel_security_connector* sc,
const char* host,
grpc_auth_context* auth_context,
grpc_closure* on_call_host_checked,
@@ -476,29 +465,26 @@ static bool fake_channel_check_call_host(grpc_exec_ctx* exec_ctx,
}
static void fake_channel_cancel_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- grpc_closure* on_call_host_checked, grpc_error* error) {
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
static void fake_channel_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
+ grpc_channel_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(
handshake_mgr,
grpc_security_handshaker_create(
- exec_ctx, tsi_create_fake_handshaker(true /* is_client */),
- &sc->base));
+ tsi_create_fake_handshaker(true /* is_client */), &sc->base));
}
-static void fake_server_add_handshakers(grpc_exec_ctx* exec_ctx,
- grpc_server_security_connector* sc,
+static void fake_server_add_handshakers(grpc_server_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(
handshake_mgr,
grpc_security_handshaker_create(
- exec_ctx, tsi_create_fake_handshaker(false /* is_client */),
- &sc->base));
+ tsi_create_fake_handshaker(false /* is_client */), &sc->base));
}
static grpc_security_connector_vtable fake_channel_vtable = {
@@ -565,12 +551,11 @@ static bool server_connector_has_cert_config_fetcher(
return server_creds->certificate_config_fetcher.cb != nullptr;
}
-static void ssl_channel_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
+static void ssl_channel_destroy(grpc_security_connector* sc) {
grpc_ssl_channel_security_connector* c =
(grpc_ssl_channel_security_connector*)sc;
- grpc_channel_credentials_unref(exec_ctx, c->base.channel_creds);
- grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
+ grpc_channel_credentials_unref(c->base.channel_creds);
+ grpc_call_credentials_unref(c->base.request_metadata_creds);
tsi_ssl_client_handshaker_factory_unref(c->client_handshaker_factory);
c->client_handshaker_factory = nullptr;
if (c->target_name != nullptr) gpr_free(c->target_name);
@@ -578,18 +563,16 @@ static void ssl_channel_destroy(grpc_exec_ctx* exec_ctx,
gpr_free(sc);
}
-static void ssl_server_destroy(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc) {
+static void ssl_server_destroy(grpc_security_connector* sc) {
grpc_ssl_server_security_connector* c =
(grpc_ssl_server_security_connector*)sc;
- grpc_server_credentials_unref(exec_ctx, c->base.server_creds);
+ grpc_server_credentials_unref(c->base.server_creds);
tsi_ssl_server_handshaker_factory_unref(c->server_handshaker_factory);
c->server_handshaker_factory = nullptr;
gpr_free(sc);
}
-static void ssl_channel_add_handshakers(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+static void ssl_channel_add_handshakers(grpc_channel_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_ssl_channel_security_connector* c =
(grpc_ssl_channel_security_connector*)sc;
@@ -607,9 +590,8 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx* exec_ctx,
}
// Create handshakers.
grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base));
+ handshake_mgr, grpc_security_handshaker_create(
+ tsi_create_adapter_handshaker(tsi_hs), &sc->base));
}
static const char** fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
@@ -701,8 +683,7 @@ static bool try_fetch_ssl_server_credentials(
return status;
}
-static void ssl_server_add_handshakers(grpc_exec_ctx* exec_ctx,
- grpc_server_security_connector* sc,
+static void ssl_server_add_handshakers(grpc_server_security_connector* sc,
grpc_handshake_manager* handshake_mgr) {
grpc_ssl_server_security_connector* c =
(grpc_ssl_server_security_connector*)sc;
@@ -718,9 +699,8 @@ static void ssl_server_add_handshakers(grpc_exec_ctx* exec_ctx,
}
// Create handshakers.
grpc_handshake_manager_add(
- handshake_mgr,
- grpc_security_handshaker_create(
- exec_ctx, tsi_create_adapter_handshaker(tsi_hs), &sc->base));
+ handshake_mgr, grpc_security_handshaker_create(
+ tsi_create_adapter_handshaker(tsi_hs), &sc->base));
}
static int ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) {
@@ -804,8 +784,7 @@ static grpc_error* ssl_check_peer(grpc_security_connector* sc,
return GRPC_ERROR_NONE;
}
-static void ssl_channel_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void ssl_channel_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
grpc_ssl_channel_security_connector* c =
@@ -815,17 +794,16 @@ static void ssl_channel_check_peer(grpc_exec_ctx* exec_ctx,
? c->overridden_target_name
: c->target_name,
&peer, auth_context);
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
tsi_peer_destruct(&peer);
}
-static void ssl_server_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc, tsi_peer peer,
+static void ssl_server_check_peer(grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
grpc_error* error = ssl_check_peer(sc, nullptr, &peer, auth_context);
tsi_peer_destruct(&peer);
- GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
+ GRPC_CLOSURE_SCHED(on_peer_checked, error);
}
static int ssl_channel_cmp(grpc_security_connector* sc1,
@@ -895,8 +873,7 @@ void tsi_shallow_peer_destruct(tsi_peer* peer) {
if (peer->properties != nullptr) gpr_free(peer->properties);
}
-static bool ssl_channel_check_call_host(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+static bool ssl_channel_check_call_host(grpc_channel_security_connector* sc,
const char* host,
grpc_auth_context* auth_context,
grpc_closure* on_call_host_checked,
@@ -922,8 +899,8 @@ static bool ssl_channel_check_call_host(grpc_exec_ctx* exec_ctx,
}
static void ssl_channel_cancel_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- grpc_closure* on_call_host_checked, grpc_error* error) {
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error) {
GRPC_ERROR_UNREF(error);
}
@@ -990,7 +967,7 @@ const char* grpc_get_default_ssl_roots(void) {
}
grpc_security_status grpc_ssl_channel_security_connector_create(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* channel_creds,
+ grpc_channel_credentials* channel_creds,
grpc_call_credentials* request_metadata_creds,
const grpc_ssl_config* config, const char* target_name,
const char* overridden_target_name, grpc_channel_security_connector** sc) {
@@ -1045,7 +1022,7 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
tsi_result_to_string(result));
- ssl_channel_destroy(exec_ctx, &c->base.base);
+ ssl_channel_destroy(&c->base.base);
*sc = nullptr;
goto error;
}
@@ -1073,8 +1050,7 @@ grpc_ssl_server_security_connector_initialize(
}
grpc_security_status grpc_ssl_server_security_connector_create(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* gsc,
- grpc_server_security_connector** sc) {
+ grpc_server_credentials* gsc, grpc_server_security_connector** sc) {
tsi_result result = TSI_OK;
grpc_ssl_server_credentials* server_credentials =
(grpc_ssl_server_credentials*)gsc;
@@ -1114,7 +1090,7 @@ grpc_security_status grpc_ssl_server_security_connector_create(
if (retval == GRPC_SECURITY_OK) {
*sc = &c->base;
} else {
- if (c != nullptr) ssl_server_destroy(exec_ctx, &c->base.base);
+ if (c != nullptr) ssl_server_destroy(&c->base.base);
if (sc != nullptr) *sc = nullptr;
}
return retval;
diff --git a/src/core/lib/security/transport/security_connector.h b/src/core/lib/security/transport/security_connector.h
index 03daba3a18..495821d247 100644
--- a/src/core/lib/security/transport/security_connector.h
+++ b/src/core/lib/security/transport/security_connector.h
@@ -50,9 +50,9 @@ typedef struct grpc_security_connector grpc_security_connector;
#define GRPC_ARG_SECURITY_CONNECTOR "grpc.security_connector"
typedef struct {
- void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_security_connector* sc);
- void (*check_peer)(grpc_exec_ctx* exec_ctx, grpc_security_connector* sc,
- tsi_peer peer, grpc_auth_context** auth_context,
+ void (*destroy)(grpc_security_connector* sc);
+ void (*check_peer)(grpc_security_connector* sc, tsi_peer peer,
+ grpc_auth_context** auth_context,
grpc_closure* on_peer_checked);
int (*cmp)(grpc_security_connector* sc, grpc_security_connector* other);
} grpc_security_connector_vtable;
@@ -67,29 +67,25 @@ struct grpc_security_connector {
#ifndef NDEBUG
#define GRPC_SECURITY_CONNECTOR_REF(p, r) \
grpc_security_connector_ref((p), __FILE__, __LINE__, (r))
-#define GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, r) \
- grpc_security_connector_unref((exec_ctx), (p), __FILE__, __LINE__, (r))
+#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) \
+ grpc_security_connector_unref((p), __FILE__, __LINE__, (r))
grpc_security_connector* grpc_security_connector_ref(
grpc_security_connector* policy, const char* file, int line,
const char* reason);
-void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* policy,
+void grpc_security_connector_unref(grpc_security_connector* policy,
const char* file, int line,
const char* reason);
#else
#define GRPC_SECURITY_CONNECTOR_REF(p, r) grpc_security_connector_ref((p))
-#define GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, p, r) \
- grpc_security_connector_unref((exec_ctx), (p))
+#define GRPC_SECURITY_CONNECTOR_UNREF(p, r) grpc_security_connector_unref((p))
grpc_security_connector* grpc_security_connector_ref(
grpc_security_connector* policy);
-void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* policy);
+void grpc_security_connector_unref(grpc_security_connector* policy);
#endif
/* Check the peer. Callee takes ownership of the peer object.
When done, sets *auth_context and invokes on_peer_checked. */
-void grpc_security_connector_check_peer(grpc_exec_ctx* exec_ctx,
- grpc_security_connector* sc,
+void grpc_security_connector_check_peer(grpc_security_connector* sc,
tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked);
@@ -119,17 +115,14 @@ struct grpc_channel_security_connector {
grpc_security_connector base;
grpc_channel_credentials* channel_creds;
grpc_call_credentials* request_metadata_creds;
- bool (*check_call_host)(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc, const char* host,
+ bool (*check_call_host)(grpc_channel_security_connector* sc, const char* host,
grpc_auth_context* auth_context,
grpc_closure* on_call_host_checked,
grpc_error** error);
- void (*cancel_check_call_host)(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+ void (*cancel_check_call_host)(grpc_channel_security_connector* sc,
grpc_closure* on_call_host_checked,
grpc_error* error);
- void (*add_handshakers)(grpc_exec_ctx* exec_ctx,
- grpc_channel_security_connector* sc,
+ void (*add_handshakers)(grpc_channel_security_connector* sc,
grpc_handshake_manager* handshake_mgr);
};
@@ -142,20 +135,20 @@ int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
/// be set to indicate the result. Otherwise, \a on_call_host_checked
/// will be invoked when complete.
bool grpc_channel_security_connector_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- const char* host, grpc_auth_context* auth_context,
- grpc_closure* on_call_host_checked, grpc_error** error);
+ grpc_channel_security_connector* sc, const char* host,
+ grpc_auth_context* auth_context, grpc_closure* on_call_host_checked,
+ grpc_error** error);
/// Cancels a pending asychronous call to
/// grpc_channel_security_connector_check_call_host() with
/// \a on_call_host_checked as its callback.
void grpc_channel_security_connector_cancel_check_call_host(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
- grpc_closure* on_call_host_checked, grpc_error* error);
+ grpc_channel_security_connector* sc, grpc_closure* on_call_host_checked,
+ grpc_error* error);
/* Registers handshakers with \a handshake_mgr. */
void grpc_channel_security_connector_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* connector,
+ grpc_channel_security_connector* connector,
grpc_handshake_manager* handshake_mgr);
/* --- server_security_connector object. ---
@@ -168,8 +161,7 @@ typedef struct grpc_server_security_connector grpc_server_security_connector;
struct grpc_server_security_connector {
grpc_security_connector base;
grpc_server_credentials* server_creds;
- void (*add_handshakers)(grpc_exec_ctx* exec_ctx,
- grpc_server_security_connector* sc,
+ void (*add_handshakers)(grpc_server_security_connector* sc,
grpc_handshake_manager* handshake_mgr);
};
@@ -178,8 +170,7 @@ int grpc_server_security_connector_cmp(grpc_server_security_connector* sc1,
grpc_server_security_connector* sc2);
void grpc_server_security_connector_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_server_security_connector* sc,
- grpc_handshake_manager* handshake_mgr);
+ grpc_server_security_connector* sc, grpc_handshake_manager* handshake_mgr);
/* --- Creation security connectors. --- */
@@ -216,7 +207,7 @@ typedef struct {
specific error code otherwise.
*/
grpc_security_status grpc_ssl_channel_security_connector_create(
- grpc_exec_ctx* exec_ctx, grpc_channel_credentials* channel_creds,
+ grpc_channel_credentials* channel_creds,
grpc_call_credentials* request_metadata_creds,
const grpc_ssl_config* config, const char* target_name,
const char* overridden_target_name, grpc_channel_security_connector** sc);
@@ -242,7 +233,7 @@ typedef struct {
specific error code otherwise.
*/
grpc_security_status grpc_ssl_server_security_connector_create(
- grpc_exec_ctx* exec_ctx, grpc_server_credentials* server_credentials,
+ grpc_server_credentials* server_credentials,
grpc_server_security_connector** sc);
/* Util. */
diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc
index 7067b70cb6..7623fbfd5b 100644
--- a/src/core/lib/security/transport/security_handshaker.cc
+++ b/src/core/lib/security/transport/security_handshaker.cc
@@ -65,8 +65,7 @@ typedef struct {
tsi_handshaker_result* handshaker_result;
} security_handshaker;
-static size_t move_read_buffer_into_handshake_buffer(grpc_exec_ctx* exec_ctx,
- security_handshaker* h) {
+static size_t move_read_buffer_into_handshake_buffer(security_handshaker* h) {
size_t bytes_in_read_buffer = h->args->read_buffer->length;
if (h->handshake_buffer_size < bytes_in_read_buffer) {
h->handshake_buffer =
@@ -79,48 +78,45 @@ static size_t move_read_buffer_into_handshake_buffer(grpc_exec_ctx* exec_ctx,
memcpy(h->handshake_buffer + offset, GRPC_SLICE_START_PTR(next_slice),
GRPC_SLICE_LENGTH(next_slice));
offset += GRPC_SLICE_LENGTH(next_slice);
- grpc_slice_unref_internal(exec_ctx, next_slice);
+ grpc_slice_unref_internal(next_slice);
}
return bytes_in_read_buffer;
}
-static void security_handshaker_unref(grpc_exec_ctx* exec_ctx,
- security_handshaker* h) {
+static void security_handshaker_unref(security_handshaker* h) {
if (gpr_unref(&h->refs)) {
gpr_mu_destroy(&h->mu);
tsi_handshaker_destroy(h->handshaker);
tsi_handshaker_result_destroy(h->handshaker_result);
if (h->endpoint_to_destroy != nullptr) {
- grpc_endpoint_destroy(exec_ctx, h->endpoint_to_destroy);
+ grpc_endpoint_destroy(h->endpoint_to_destroy);
}
if (h->read_buffer_to_destroy != nullptr) {
- grpc_slice_buffer_destroy_internal(exec_ctx, h->read_buffer_to_destroy);
+ grpc_slice_buffer_destroy_internal(h->read_buffer_to_destroy);
gpr_free(h->read_buffer_to_destroy);
}
gpr_free(h->handshake_buffer);
- grpc_slice_buffer_destroy_internal(exec_ctx, &h->outgoing);
+ grpc_slice_buffer_destroy_internal(&h->outgoing);
GRPC_AUTH_CONTEXT_UNREF(h->auth_context, "handshake");
- GRPC_SECURITY_CONNECTOR_UNREF(exec_ctx, h->connector, "handshake");
+ GRPC_SECURITY_CONNECTOR_UNREF(h->connector, "handshake");
gpr_free(h);
}
}
// Set args fields to NULL, saving the endpoint and read buffer for
// later destruction.
-static void cleanup_args_for_failure_locked(grpc_exec_ctx* exec_ctx,
- security_handshaker* h) {
+static void cleanup_args_for_failure_locked(security_handshaker* h) {
h->endpoint_to_destroy = h->args->endpoint;
h->args->endpoint = nullptr;
h->read_buffer_to_destroy = h->args->read_buffer;
h->args->read_buffer = nullptr;
- grpc_channel_args_destroy(exec_ctx, h->args->args);
+ grpc_channel_args_destroy(h->args->args);
h->args->args = nullptr;
}
// If the handshake failed or we're shutting down, clean up and invoke the
// callback with the error.
-static void security_handshake_failed_locked(grpc_exec_ctx* exec_ctx,
- security_handshaker* h,
+static void security_handshake_failed_locked(security_handshaker* h,
grpc_error* error) {
if (error == GRPC_ERROR_NONE) {
// If we were shut down after the handshake succeeded but before an
@@ -135,34 +131,33 @@ static void security_handshake_failed_locked(grpc_exec_ctx* exec_ctx,
// before destroying them, even if we know that there are no
// pending read/write callbacks. This should be fixed, at which
// point this can be removed.
- grpc_endpoint_shutdown(exec_ctx, h->args->endpoint, GRPC_ERROR_REF(error));
+ grpc_endpoint_shutdown(h->args->endpoint, GRPC_ERROR_REF(error));
// Not shutting down, so the write failed. Clean up before
// invoking the callback.
- cleanup_args_for_failure_locked(exec_ctx, h);
+ cleanup_args_for_failure_locked(h);
// Set shutdown to true so that subsequent calls to
// security_handshaker_shutdown() do nothing.
h->shutdown = true;
}
// Invoke callback.
- GRPC_CLOSURE_SCHED(exec_ctx, h->on_handshake_done, error);
+ GRPC_CLOSURE_SCHED(h->on_handshake_done, error);
}
-static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
- security_handshaker* h, grpc_error* error) {
+static void on_peer_checked_inner(security_handshaker* h, grpc_error* error) {
if (error != GRPC_ERROR_NONE || h->shutdown) {
- security_handshake_failed_locked(exec_ctx, h, GRPC_ERROR_REF(error));
+ security_handshake_failed_locked(h, GRPC_ERROR_REF(error));
return;
}
// Create zero-copy frame protector, if implemented.
tsi_zero_copy_grpc_protector* zero_copy_protector = nullptr;
tsi_result result = tsi_handshaker_result_create_zero_copy_grpc_protector(
- exec_ctx, h->handshaker_result, nullptr, &zero_copy_protector);
+ h->handshaker_result, nullptr, &zero_copy_protector);
if (result != TSI_OK && result != TSI_UNIMPLEMENTED) {
error = grpc_set_tsi_error_result(
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Zero-copy frame protector creation failed"),
result);
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
return;
}
// Create frame protector if zero-copy frame protector is NULL.
@@ -174,7 +169,7 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
error = grpc_set_tsi_error_result(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Frame protector creation failed"),
result);
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
return;
}
}
@@ -189,7 +184,7 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
grpc_slice_from_copied_buffer((char*)unused_bytes, unused_bytes_size);
h->args->endpoint = grpc_secure_endpoint_create(
protector, zero_copy_protector, h->args->endpoint, &slice, 1);
- grpc_slice_unref_internal(exec_ctx, slice);
+ grpc_slice_unref_internal(slice);
} else {
h->args->endpoint = grpc_secure_endpoint_create(
protector, zero_copy_protector, h->args->endpoint, nullptr, 0);
@@ -201,25 +196,23 @@ static void on_peer_checked_inner(grpc_exec_ctx* exec_ctx,
grpc_channel_args* tmp_args = h->args->args;
h->args->args =
grpc_channel_args_copy_and_add(tmp_args, &auth_context_arg, 1);
- grpc_channel_args_destroy(exec_ctx, tmp_args);
+ grpc_channel_args_destroy(tmp_args);
// Invoke callback.
- GRPC_CLOSURE_SCHED(exec_ctx, h->on_handshake_done, GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(h->on_handshake_done, GRPC_ERROR_NONE);
// Set shutdown to true so that subsequent calls to
// security_handshaker_shutdown() do nothing.
h->shutdown = true;
}
-static void on_peer_checked(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_peer_checked(void* arg, grpc_error* error) {
security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
- on_peer_checked_inner(exec_ctx, h, error);
+ on_peer_checked_inner(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
}
-static grpc_error* check_peer_locked(grpc_exec_ctx* exec_ctx,
- security_handshaker* h) {
+static grpc_error* check_peer_locked(security_handshaker* h) {
tsi_peer peer;
tsi_result result =
tsi_handshaker_result_extract_peer(h->handshaker_result, &peer);
@@ -227,20 +220,20 @@ static grpc_error* check_peer_locked(grpc_exec_ctx* exec_ctx,
return grpc_set_tsi_error_result(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Peer extraction failed"), result);
}
- grpc_security_connector_check_peer(exec_ctx, h->connector, peer,
- &h->auth_context, &h->on_peer_checked);
+ grpc_security_connector_check_peer(h->connector, peer, &h->auth_context,
+ &h->on_peer_checked);
return GRPC_ERROR_NONE;
}
static grpc_error* on_handshake_next_done_locked(
- grpc_exec_ctx* exec_ctx, security_handshaker* h, tsi_result result,
+ security_handshaker* h, tsi_result result,
const unsigned char* bytes_to_send, size_t bytes_to_send_size,
tsi_handshaker_result* handshaker_result) {
grpc_error* error = GRPC_ERROR_NONE;
// Read more if we need to.
if (result == TSI_INCOMPLETE_DATA) {
GPR_ASSERT(bytes_to_send_size == 0);
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
return error;
}
@@ -257,17 +250,17 @@ static grpc_error* on_handshake_next_done_locked(
// Send data to peer, if needed.
grpc_slice to_send = grpc_slice_from_copied_buffer(
(const char*)bytes_to_send, bytes_to_send_size);
- grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &h->outgoing);
+ grpc_slice_buffer_reset_and_unref_internal(&h->outgoing);
grpc_slice_buffer_add(&h->outgoing, to_send);
- grpc_endpoint_write(exec_ctx, h->args->endpoint, &h->outgoing,
+ grpc_endpoint_write(h->args->endpoint, &h->outgoing,
&h->on_handshake_data_sent_to_peer);
} else if (handshaker_result == nullptr) {
// There is nothing to send, but need to read from peer.
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
} else {
// Handshake has finished, check peer and so on.
- error = check_peer_locked(exec_ctx, h);
+ error = check_peer_locked(h);
}
return error;
}
@@ -278,24 +271,22 @@ static void on_handshake_next_done_grpc_wrapper(
security_handshaker* h = (security_handshaker*)user_data;
// This callback will be invoked by TSI in a non-grpc thread, so it's
// safe to create our own exec_ctx here.
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
gpr_mu_lock(&h->mu);
- grpc_error* error =
- on_handshake_next_done_locked(&exec_ctx, h, result, bytes_to_send,
- bytes_to_send_size, handshaker_result);
+ grpc_error* error = on_handshake_next_done_locked(
+ h, result, bytes_to_send, bytes_to_send_size, handshaker_result);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(&exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(&exec_ctx, h);
+ security_handshaker_unref(h);
} else {
gpr_mu_unlock(&h->mu);
}
- grpc_exec_ctx_finish(&exec_ctx);
}
static grpc_error* do_handshaker_next_locked(
- grpc_exec_ctx* exec_ctx, security_handshaker* h,
- const unsigned char* bytes_received, size_t bytes_received_size) {
+ security_handshaker* h, const unsigned char* bytes_received,
+ size_t bytes_received_size) {
// Invoke TSI handshaker.
const unsigned char* bytes_to_send = nullptr;
size_t bytes_to_send_size = 0;
@@ -311,62 +302,57 @@ static grpc_error* do_handshaker_next_locked(
}
// Handshaker returned synchronously. Invoke callback directly in
// this thread with our existing exec_ctx.
- return on_handshake_next_done_locked(exec_ctx, h, result, bytes_to_send,
+ return on_handshake_next_done_locked(h, result, bytes_to_send,
bytes_to_send_size, handshaker_result);
}
-static void on_handshake_data_received_from_peer(grpc_exec_ctx* exec_ctx,
- void* arg, grpc_error* error) {
+static void on_handshake_data_received_from_peer(void* arg, grpc_error* error) {
security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
if (error != GRPC_ERROR_NONE || h->shutdown) {
security_handshake_failed_locked(
- exec_ctx, h,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Handshake read failed", &error, 1));
+ h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Handshake read failed", &error, 1));
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
// Copy all slices received.
- size_t bytes_received_size =
- move_read_buffer_into_handshake_buffer(exec_ctx, h);
+ size_t bytes_received_size = move_read_buffer_into_handshake_buffer(h);
// Call TSI handshaker.
- error = do_handshaker_next_locked(exec_ctx, h, h->handshake_buffer,
- bytes_received_size);
+ error =
+ do_handshaker_next_locked(h, h->handshake_buffer, bytes_received_size);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
} else {
gpr_mu_unlock(&h->mu);
}
}
-static void on_handshake_data_sent_to_peer(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void on_handshake_data_sent_to_peer(void* arg, grpc_error* error) {
security_handshaker* h = (security_handshaker*)arg;
gpr_mu_lock(&h->mu);
if (error != GRPC_ERROR_NONE || h->shutdown) {
security_handshake_failed_locked(
- exec_ctx, h,
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
- "Handshake write failed", &error, 1));
+ h, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
+ "Handshake write failed", &error, 1));
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
// We may be done.
if (h->handshaker_result == nullptr) {
- grpc_endpoint_read(exec_ctx, h->args->endpoint, h->args->read_buffer,
+ grpc_endpoint_read(h->args->endpoint, h->args->read_buffer,
&h->on_handshake_data_received_from_peer);
} else {
- error = check_peer_locked(exec_ctx, h);
+ error = check_peer_locked(h);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
}
@@ -377,28 +363,25 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx* exec_ctx, void* arg,
// public handshaker API
//
-static void security_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
+static void security_handshaker_destroy(grpc_handshaker* handshaker) {
security_handshaker* h = (security_handshaker*)handshaker;
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
}
-static void security_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+static void security_handshaker_shutdown(grpc_handshaker* handshaker,
grpc_error* why) {
security_handshaker* h = (security_handshaker*)handshaker;
gpr_mu_lock(&h->mu);
if (!h->shutdown) {
h->shutdown = true;
- grpc_endpoint_shutdown(exec_ctx, h->args->endpoint, GRPC_ERROR_REF(why));
- cleanup_args_for_failure_locked(exec_ctx, h);
+ grpc_endpoint_shutdown(h->args->endpoint, GRPC_ERROR_REF(why));
+ cleanup_args_for_failure_locked(h);
}
gpr_mu_unlock(&h->mu);
GRPC_ERROR_UNREF(why);
}
-static void security_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+static void security_handshaker_do_handshake(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args) {
@@ -407,14 +390,13 @@ static void security_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
h->args = args;
h->on_handshake_done = on_handshake_done;
gpr_ref(&h->refs);
- size_t bytes_received_size =
- move_read_buffer_into_handshake_buffer(exec_ctx, h);
- grpc_error* error = do_handshaker_next_locked(
- exec_ctx, h, h->handshake_buffer, bytes_received_size);
+ size_t bytes_received_size = move_read_buffer_into_handshake_buffer(h);
+ grpc_error* error =
+ do_handshaker_next_locked(h, h->handshake_buffer, bytes_received_size);
if (error != GRPC_ERROR_NONE) {
- security_handshake_failed_locked(exec_ctx, h, error);
+ security_handshake_failed_locked(h, error);
gpr_mu_unlock(&h->mu);
- security_handshaker_unref(exec_ctx, h);
+ security_handshaker_unref(h);
return;
}
gpr_mu_unlock(&h->mu);
@@ -425,8 +407,7 @@ static const grpc_handshaker_vtable security_handshaker_vtable = {
security_handshaker_do_handshake};
static grpc_handshaker* security_handshaker_create(
- grpc_exec_ctx* exec_ctx, tsi_handshaker* handshaker,
- grpc_security_connector* connector) {
+ tsi_handshaker* handshaker, grpc_security_connector* connector) {
security_handshaker* h =
(security_handshaker*)gpr_zalloc(sizeof(security_handshaker));
grpc_handshaker_init(&security_handshaker_vtable, &h->base);
@@ -452,23 +433,20 @@ static grpc_handshaker* security_handshaker_create(
// fail_handshaker
//
-static void fail_handshaker_destroy(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker) {
+static void fail_handshaker_destroy(grpc_handshaker* handshaker) {
gpr_free(handshaker);
}
-static void fail_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+static void fail_handshaker_shutdown(grpc_handshaker* handshaker,
grpc_error* why) {
GRPC_ERROR_UNREF(why);
}
-static void fail_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
- grpc_handshaker* handshaker,
+static void fail_handshaker_do_handshake(grpc_handshaker* handshaker,
grpc_tcp_server_acceptor* acceptor,
grpc_closure* on_handshake_done,
grpc_handshaker_args* args) {
- GRPC_CLOSURE_SCHED(exec_ctx, on_handshake_done,
+ GRPC_CLOSURE_SCHED(on_handshake_done,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to create security handshaker"));
}
@@ -488,27 +466,27 @@ static grpc_handshaker* fail_handshaker_create() {
//
static void client_handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
grpc_channel_security_connector* security_connector =
(grpc_channel_security_connector*)grpc_security_connector_find_in_args(
args);
- grpc_channel_security_connector_add_handshakers(exec_ctx, security_connector,
+ grpc_channel_security_connector_add_handshakers(security_connector,
handshake_mgr);
}
static void server_handshaker_factory_add_handshakers(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* hf,
- const grpc_channel_args* args, grpc_handshake_manager* handshake_mgr) {
+ grpc_handshaker_factory* hf, const grpc_channel_args* args,
+ grpc_handshake_manager* handshake_mgr) {
grpc_server_security_connector* security_connector =
(grpc_server_security_connector*)grpc_security_connector_find_in_args(
args);
- grpc_server_security_connector_add_handshakers(exec_ctx, security_connector,
+ grpc_server_security_connector_add_handshakers(security_connector,
handshake_mgr);
}
static void handshaker_factory_destroy(
- grpc_exec_ctx* exec_ctx, grpc_handshaker_factory* handshaker_factory) {}
+ grpc_handshaker_factory* handshaker_factory) {}
static const grpc_handshaker_factory_vtable client_handshaker_factory_vtable = {
client_handshaker_factory_add_handshakers, handshaker_factory_destroy};
@@ -527,14 +505,13 @@ static grpc_handshaker_factory server_handshaker_factory = {
//
grpc_handshaker* grpc_security_handshaker_create(
- grpc_exec_ctx* exec_ctx, tsi_handshaker* handshaker,
- grpc_security_connector* connector) {
+ tsi_handshaker* handshaker, grpc_security_connector* connector) {
// If no TSI handshaker was created, return a handshaker that always fails.
// Otherwise, return a real security handshaker.
if (handshaker == nullptr) {
return fail_handshaker_create();
} else {
- return security_handshaker_create(exec_ctx, handshaker, connector);
+ return security_handshaker_create(handshaker, connector);
}
}
diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h
index 6c3a0510ce..6cd6446b5a 100644
--- a/src/core/lib/security/transport/security_handshaker.h
+++ b/src/core/lib/security/transport/security_handshaker.h
@@ -25,8 +25,7 @@
/// Creates a security handshaker using \a handshaker.
grpc_handshaker* grpc_security_handshaker_create(
- grpc_exec_ctx* exec_ctx, tsi_handshaker* handshaker,
- grpc_security_connector* connector);
+ tsi_handshaker* handshaker, grpc_security_connector* connector);
/// Registers security handshaker factories.
void grpc_security_register_handshaker_factories();
diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc
index 9cf368acd0..73653f2a66 100644
--- a/src/core/lib/security/transport/server_auth_filter.cc
+++ b/src/core/lib/security/transport/server_auth_filter.cc
@@ -73,8 +73,7 @@ static grpc_metadata_array metadata_batch_to_md_array(
return result;
}
-static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx* exec_ctx,
- void* user_data,
+static grpc_filtered_mdelem remove_consumed_md(void* user_data,
grpc_mdelem md) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
@@ -88,8 +87,7 @@ static grpc_filtered_mdelem remove_consumed_md(grpc_exec_ctx* exec_ctx,
return GRPC_FILTERED_MDELEM(md);
}
-static void on_md_processing_done_inner(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static void on_md_processing_done_inner(grpc_call_element* elem,
const grpc_metadata* consumed_md,
size_t num_consumed_md,
const grpc_metadata* response_md,
@@ -107,11 +105,10 @@ static void on_md_processing_done_inner(grpc_exec_ctx* exec_ctx,
calld->consumed_md = consumed_md;
calld->num_consumed_md = num_consumed_md;
error = grpc_metadata_batch_filter(
- exec_ctx, batch->payload->recv_initial_metadata.recv_initial_metadata,
+ batch->payload->recv_initial_metadata.recv_initial_metadata,
remove_consumed_md, elem, "Response metadata filtering error");
}
- GRPC_CLOSURE_SCHED(exec_ctx, calld->original_recv_initial_metadata_ready,
- error);
+ GRPC_CLOSURE_SCHED(calld->original_recv_initial_metadata_ready, error);
}
// Called from application code.
@@ -121,7 +118,7 @@ static void on_md_processing_done(
grpc_status_code status, const char* error_details) {
grpc_call_element* elem = (grpc_call_element*)user_data;
call_data* calld = (call_data*)elem->call_data;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_core::ExecCtx exec_ctx;
// If the call was not cancelled while we were in flight, process the result.
if (gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
(gpr_atm)STATE_DONE)) {
@@ -134,34 +131,32 @@ static void on_md_processing_done(
GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_details),
GRPC_ERROR_INT_GRPC_STATUS, status);
}
- on_md_processing_done_inner(&exec_ctx, elem, consumed_md, num_consumed_md,
- response_md, num_response_md, error);
+ on_md_processing_done_inner(elem, consumed_md, num_consumed_md, response_md,
+ num_response_md, error);
}
// Clean up.
for (size_t i = 0; i < calld->md.count; i++) {
- grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].key);
- grpc_slice_unref_internal(&exec_ctx, calld->md.metadata[i].value);
+ grpc_slice_unref_internal(calld->md.metadata[i].key);
+ grpc_slice_unref_internal(calld->md.metadata[i].value);
}
grpc_metadata_array_destroy(&calld->md);
- GRPC_CALL_STACK_UNREF(&exec_ctx, calld->owning_call, "server_auth_metadata");
- grpc_exec_ctx_finish(&exec_ctx);
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "server_auth_metadata");
}
-static void cancel_call(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
+static void cancel_call(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
// If the result was not already processed, invoke the callback now.
if (error != GRPC_ERROR_NONE &&
gpr_atm_full_cas(&calld->state, (gpr_atm)STATE_INIT,
(gpr_atm)STATE_CANCELLED)) {
- on_md_processing_done_inner(exec_ctx, elem, nullptr, 0, nullptr, 0,
+ on_md_processing_done_inner(elem, nullptr, 0, nullptr, 0,
GRPC_ERROR_REF(error));
}
- GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "cancel_call");
+ GRPC_CALL_STACK_UNREF(calld->owning_call, "cancel_call");
}
-static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
- grpc_error* error) {
+static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
@@ -173,7 +168,7 @@ static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
GRPC_CALL_STACK_REF(calld->owning_call, "cancel_call");
GRPC_CLOSURE_INIT(&calld->cancel_closure, cancel_call, elem,
grpc_schedule_on_exec_ctx);
- grpc_call_combiner_set_notify_on_cancel(exec_ctx, calld->call_combiner,
+ grpc_call_combiner_set_notify_on_cancel(calld->call_combiner,
&calld->cancel_closure);
GRPC_CALL_STACK_REF(calld->owning_call, "server_auth_metadata");
calld->md = metadata_batch_to_md_array(
@@ -184,13 +179,12 @@ static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
return;
}
}
- GRPC_CLOSURE_RUN(exec_ctx, calld->original_recv_initial_metadata_ready,
+ GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready,
GRPC_ERROR_REF(error));
}
static void auth_start_transport_stream_op_batch(
- grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
- grpc_transport_stream_op_batch* batch) {
+ grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
call_data* calld = (call_data*)elem->call_data;
if (batch->recv_initial_metadata) {
// Inject our callback.
@@ -200,12 +194,11 @@ static void auth_start_transport_stream_op_batch(
batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
&calld->recv_initial_metadata_ready;
}
- grpc_call_next_op(exec_ctx, elem, batch);
+ grpc_call_next_op(elem, batch);
}
/* Constructor for call_data */
-static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
- grpc_call_element* elem,
+static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
@@ -231,13 +224,12 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for call_data */
-static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
+static void destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {}
/* Constructor for channel_data */
-static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem,
+static grpc_error* init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(!args->is_last);
channel_data* chand = (channel_data*)elem->channel_data;
@@ -253,11 +245,10 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
}
/* Destructor for channel data */
-static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
- grpc_channel_element* elem) {
+static void destroy_channel_elem(grpc_channel_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
GRPC_AUTH_CONTEXT_UNREF(chand->auth_context, "server_auth_filter");
- grpc_server_credentials_unref(exec_ctx, chand->creds);
+ grpc_server_credentials_unref(chand->creds);
}
const grpc_channel_filter grpc_server_auth_filter = {