Fix sanity: core_banned_functions

reviewable/pr8842/r4
Craig Tiller 8 years ago
parent 3e8deb188f
commit 9277aa74ae
  1. 10
      src/core/ext/lb_policy/grpclb/grpclb.c
  2. 6
      src/core/ext/transport/chttp2/transport/incoming_metadata.c
  3. 4
      src/core/lib/channel/compress_filter.c
  4. 16
      src/core/lib/channel/http_client_filter.c
  5. 6
      src/core/lib/channel/http_server_filter.c
  6. 2
      src/core/lib/security/transport/client_auth_filter.c
  7. 7
      src/core/lib/surface/call.c
  8. 8
      src/core/lib/surface/call_details.c
  9. 1
      src/core/lib/surface/channel.c
  10. 36
      src/core/lib/transport/metadata_batch.c
  11. 20
      src/core/lib/transport/metadata_batch.h

@ -136,12 +136,12 @@ int grpc_lb_glb_trace = 0;
/* add lb_token of selected subchannel (address) to the call's initial /* add lb_token of selected subchannel (address) to the call's initial
* metadata */ * metadata */
static grpc_error *initial_metadata_add_lb_token( static grpc_error *initial_metadata_add_lb_token(
grpc_metadata_batch *initial_metadata, grpc_exec_ctx *exec_ctx, grpc_metadata_batch *initial_metadata,
grpc_linked_mdelem *lb_token_mdelem_storage, grpc_mdelem lb_token) { grpc_linked_mdelem *lb_token_mdelem_storage, grpc_mdelem lb_token) {
GPR_ASSERT(lb_token_mdelem_storage != NULL); GPR_ASSERT(lb_token_mdelem_storage != NULL);
GPR_ASSERT(!GRPC_MDISNULL(lb_token)); GPR_ASSERT(!GRPC_MDISNULL(lb_token));
return grpc_metadata_batch_add_tail(initial_metadata, lb_token_mdelem_storage, return grpc_metadata_batch_add_tail(exec_ctx, initial_metadata,
lb_token); lb_token_mdelem_storage, lb_token);
} }
typedef struct wrapped_rr_closure_arg { typedef struct wrapped_rr_closure_arg {
@ -189,7 +189,7 @@ static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg,
* available */ * available */
if (*wc_arg->target != NULL) { if (*wc_arg->target != NULL) {
if (!GRPC_MDISNULL(wc_arg->lb_token)) { if (!GRPC_MDISNULL(wc_arg->lb_token)) {
initial_metadata_add_lb_token(wc_arg->initial_metadata, initial_metadata_add_lb_token(exec_ctx, wc_arg->initial_metadata,
wc_arg->lb_token_mdelem_storage, wc_arg->lb_token_mdelem_storage,
GRPC_MDELEM_REF(wc_arg->lb_token)); GRPC_MDELEM_REF(wc_arg->lb_token));
} else { } else {
@ -568,7 +568,7 @@ static bool pick_from_internal_rr_locked(
GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "glb_pick_sync"); GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "glb_pick_sync");
/* add the load reporting initial metadata */ /* add the load reporting initial metadata */
initial_metadata_add_lb_token(pick_args->initial_metadata, initial_metadata_add_lb_token(exec_ctx, pick_args->initial_metadata,
pick_args->lb_token_mdelem_storage, pick_args->lb_token_mdelem_storage,
GRPC_MDELEM_REF(wc_arg->lb_token)); GRPC_MDELEM_REF(wc_arg->lb_token));

@ -96,9 +96,9 @@ void grpc_chttp2_incoming_metadata_buffer_publish(
size_t i; size_t i;
for (i = 0; i < buffer->count; i++) { for (i = 0; i < buffer->count; i++) {
/* TODO(ctiller): do something better here */ /* TODO(ctiller): do something better here */
if (!GRPC_LOG_IF_ERROR( if (!GRPC_LOG_IF_ERROR("grpc_chttp2_incoming_metadata_buffer_publish",
"grpc_chttp2_incoming_metadata_buffer_publish", grpc_metadata_batch_link_tail(
grpc_metadata_batch_link_tail(batch, &buffer->elems[i]))) { exec_ctx, batch, &buffer->elems[i]))) {
GRPC_MDELEM_UNREF(exec_ctx, buffer->elems[i].md); GRPC_MDELEM_UNREF(exec_ctx, buffer->elems[i].md);
} }
} }

@ -146,14 +146,14 @@ static grpc_error *process_send_initial_metadata(
/* hint compression algorithm */ /* hint compression algorithm */
error = grpc_metadata_batch_add_tail( error = grpc_metadata_batch_add_tail(
initial_metadata, &calld->compression_algorithm_storage, exec_ctx, initial_metadata, &calld->compression_algorithm_storage,
grpc_compression_encoding_mdelem(calld->compression_algorithm)); grpc_compression_encoding_mdelem(calld->compression_algorithm));
if (error != GRPC_ERROR_NONE) return error; if (error != GRPC_ERROR_NONE) return error;
/* convey supported compression algorithms */ /* convey supported compression algorithms */
error = grpc_metadata_batch_add_tail( error = grpc_metadata_batch_add_tail(
initial_metadata, &calld->accept_encoding_storage, exec_ctx, initial_metadata, &calld->accept_encoding_storage,
GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS( GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(
channeld->supported_compression_algorithms)); channeld->supported_compression_algorithms));

@ -298,7 +298,8 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
exec_ctx, GRPC_MDSTR_GRPC_PAYLOAD_BIN, exec_ctx, GRPC_MDSTR_GRPC_PAYLOAD_BIN,
grpc_slice_from_copied_buffer((const char *)calld->payload_bytes, grpc_slice_from_copied_buffer((const char *)calld->payload_bytes,
op->send_message->length)); op->send_message->length));
error = grpc_metadata_batch_add_tail(op->send_initial_metadata, error =
grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata,
&calld->payload_bin, payload_bin); &calld->payload_bin, payload_bin);
if (error != GRPC_ERROR_NONE) return error; if (error != GRPC_ERROR_NONE) return error;
calld->on_complete = op->on_complete; calld->on_complete = op->on_complete;
@ -323,21 +324,22 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
/* Send : prefixed headers, which have to be before any application /* Send : prefixed headers, which have to be before any application
layer headers. */ layer headers. */
error = grpc_metadata_batch_add_head(op->send_initial_metadata, error = grpc_metadata_batch_add_head(exec_ctx, op->send_initial_metadata,
&calld->method, method); &calld->method, method);
if (error != GRPC_ERROR_NONE) return error; if (error != GRPC_ERROR_NONE) return error;
error = grpc_metadata_batch_add_head( error =
op->send_initial_metadata, &calld->scheme, channeld->static_scheme); grpc_metadata_batch_add_head(exec_ctx, op->send_initial_metadata,
&calld->scheme, channeld->static_scheme);
if (error != GRPC_ERROR_NONE) return error; if (error != GRPC_ERROR_NONE) return error;
error = grpc_metadata_batch_add_tail(op->send_initial_metadata, error = grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata,
&calld->te_trailers, &calld->te_trailers,
GRPC_MDELEM_TE_TRAILERS); GRPC_MDELEM_TE_TRAILERS);
if (error != GRPC_ERROR_NONE) return error; if (error != GRPC_ERROR_NONE) return error;
error = grpc_metadata_batch_add_tail( error = grpc_metadata_batch_add_tail(
op->send_initial_metadata, &calld->content_type, exec_ctx, op->send_initial_metadata, &calld->content_type,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC); GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC);
if (error != GRPC_ERROR_NONE) return error; if (error != GRPC_ERROR_NONE) return error;
error = grpc_metadata_batch_add_tail(op->send_initial_metadata, error = grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata,
&calld->user_agent, &calld->user_agent,
GRPC_MDELEM_REF(channeld->user_agent)); GRPC_MDELEM_REF(channeld->user_agent));
if (error != GRPC_ERROR_NONE) return error; if (error != GRPC_ERROR_NONE) return error;

@ -279,11 +279,11 @@ static void hs_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_error *error = GRPC_ERROR_NONE; grpc_error *error = GRPC_ERROR_NONE;
static const char *error_name = "Failed sending initial metadata"; static const char *error_name = "Failed sending initial metadata";
add_error(error_name, &error, grpc_metadata_batch_add_head( add_error(error_name, &error, grpc_metadata_batch_add_head(
op->send_initial_metadata, &calld->status, exec_ctx, op->send_initial_metadata,
GRPC_MDELEM_STATUS_200)); &calld->status, GRPC_MDELEM_STATUS_200));
add_error(error_name, &error, add_error(error_name, &error,
grpc_metadata_batch_add_tail( grpc_metadata_batch_add_tail(
op->send_initial_metadata, &calld->content_type, exec_ctx, op->send_initial_metadata, &calld->content_type,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)); GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC));
add_error(error_name, &error, add_error(error_name, &error,
server_filter_outgoing_metadata(exec_ctx, elem, server_filter_outgoing_metadata(exec_ctx, elem,

@ -136,7 +136,7 @@ static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *user_data,
} else { } else {
add_error(&error, add_error(&error,
grpc_metadata_batch_add_tail( grpc_metadata_batch_add_tail(
mdb, &calld->md_links[i], exec_ctx, mdb, &calld->md_links[i],
grpc_mdelem_from_slices( grpc_mdelem_from_slices(
exec_ctx, grpc_slice_ref_internal(md_elems[i].key), exec_ctx, grpc_slice_ref_internal(md_elems[i].key),
grpc_slice_ref_internal(md_elems[i].value)))); grpc_slice_ref_internal(md_elems[i].value))));

@ -796,14 +796,15 @@ static int prepare_application_metadata(
for (i = 0; i < call->send_extra_metadata_count; i++) { for (i = 0; i < call->send_extra_metadata_count; i++) {
GRPC_LOG_IF_ERROR("prepare_application_metadata", GRPC_LOG_IF_ERROR("prepare_application_metadata",
grpc_metadata_batch_link_tail( grpc_metadata_batch_link_tail(
batch, &call->send_extra_metadata[i])); exec_ctx, batch, &call->send_extra_metadata[i]));
} }
} }
} }
for (i = 0; i < total_count; i++) { for (i = 0; i < total_count; i++) {
grpc_metadata *md = get_md_elem(metadata, additional_metadata, i, count); grpc_metadata *md = get_md_elem(metadata, additional_metadata, i, count);
GRPC_LOG_IF_ERROR("prepare_application_metadata", GRPC_LOG_IF_ERROR(
grpc_metadata_batch_link_tail(batch, linked_from_md(md))); "prepare_application_metadata",
grpc_metadata_batch_link_tail(exec_ctx, batch, linked_from_md(md)));
} }
call->send_extra_metadata_count = 0; call->send_extra_metadata_count = 0;

@ -36,6 +36,8 @@
#include <string.h> #include <string.h>
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/api_trace.h"
void grpc_call_details_init(grpc_call_details* cd) { void grpc_call_details_init(grpc_call_details* cd) {
@ -47,6 +49,8 @@ void grpc_call_details_init(grpc_call_details* cd) {
void grpc_call_details_destroy(grpc_call_details* cd) { void grpc_call_details_destroy(grpc_call_details* cd) {
GRPC_API_TRACE("grpc_call_details_destroy(cd=%p)", 1, (cd)); GRPC_API_TRACE("grpc_call_details_destroy(cd=%p)", 1, (cd));
grpc_slice_unref_internal(exec_ctx, cd->method); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_slice_unref_internal(exec_ctx, cd->host); grpc_slice_unref_internal(&exec_ctx, cd->method);
grpc_slice_unref_internal(&exec_ctx, cd->host);
grpc_exec_ctx_finish(&exec_ctx);
} }

@ -43,6 +43,7 @@
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/support/string.h" #include "src/core/lib/support/string.h"
#include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h" #include "src/core/lib/surface/call.h"

@ -40,6 +40,7 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/lib/profiling/timers.h" #include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/slice/slice_string_helpers.h"
static void assert_valid_list(grpc_mdelem_list *list) { static void assert_valid_list(grpc_mdelem_list *list) {
@ -65,7 +66,8 @@ static void assert_valid_list(grpc_mdelem_list *list) {
#endif /* NDEBUG */ #endif /* NDEBUG */
} }
static void assert_valid_callouts(grpc_metadata_batch *batch) { static void assert_valid_callouts(grpc_exec_ctx *exec_ctx,
grpc_metadata_batch *batch) {
#ifndef NDEBUG #ifndef NDEBUG
for (grpc_linked_mdelem *l = batch->list.head; l != NULL; l = l->next) { for (grpc_linked_mdelem *l = batch->list.head; l != NULL; l = l->next) {
grpc_slice key_interned = grpc_slice_intern(GRPC_MDKEY(l->md)); grpc_slice key_interned = grpc_slice_intern(GRPC_MDKEY(l->md));
@ -138,12 +140,13 @@ static void maybe_unlink_callout(grpc_metadata_batch *batch,
batch->idx.array[idx] = NULL; batch->idx.array[idx] = NULL;
} }
grpc_error *grpc_metadata_batch_add_head(grpc_metadata_batch *batch, grpc_error *grpc_metadata_batch_add_head(grpc_exec_ctx *exec_ctx,
grpc_metadata_batch *batch,
grpc_linked_mdelem *storage, grpc_linked_mdelem *storage,
grpc_mdelem elem_to_add) { grpc_mdelem elem_to_add) {
GPR_ASSERT(!GRPC_MDISNULL(elem_to_add)); GPR_ASSERT(!GRPC_MDISNULL(elem_to_add));
storage->md = elem_to_add; storage->md = elem_to_add;
return grpc_metadata_batch_link_head(batch, storage); return grpc_metadata_batch_link_head(exec_ctx, batch, storage);
} }
static void link_head(grpc_mdelem_list *list, grpc_linked_mdelem *storage) { static void link_head(grpc_mdelem_list *list, grpc_linked_mdelem *storage) {
@ -161,25 +164,27 @@ static void link_head(grpc_mdelem_list *list, grpc_linked_mdelem *storage) {
assert_valid_list(list); assert_valid_list(list);
} }
grpc_error *grpc_metadata_batch_link_head(grpc_metadata_batch *batch, grpc_error *grpc_metadata_batch_link_head(grpc_exec_ctx *exec_ctx,
grpc_metadata_batch *batch,
grpc_linked_mdelem *storage) { grpc_linked_mdelem *storage) {
assert_valid_callouts(batch); assert_valid_callouts(exec_ctx, batch);
grpc_error *err = maybe_link_callout(batch, storage); grpc_error *err = maybe_link_callout(batch, storage);
if (err != GRPC_ERROR_NONE) { if (err != GRPC_ERROR_NONE) {
assert_valid_callouts(batch); assert_valid_callouts(exec_ctx, batch);
return err; return err;
} }
link_head(&batch->list, storage); link_head(&batch->list, storage);
assert_valid_callouts(batch); assert_valid_callouts(exec_ctx, batch);
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
grpc_error *grpc_metadata_batch_add_tail(grpc_metadata_batch *batch, grpc_error *grpc_metadata_batch_add_tail(grpc_exec_ctx *exec_ctx,
grpc_metadata_batch *batch,
grpc_linked_mdelem *storage, grpc_linked_mdelem *storage,
grpc_mdelem elem_to_add) { grpc_mdelem elem_to_add) {
GPR_ASSERT(!GRPC_MDISNULL(elem_to_add)); GPR_ASSERT(!GRPC_MDISNULL(elem_to_add));
storage->md = elem_to_add; storage->md = elem_to_add;
return grpc_metadata_batch_link_tail(batch, storage); return grpc_metadata_batch_link_tail(exec_ctx, batch, storage);
} }
static void link_tail(grpc_mdelem_list *list, grpc_linked_mdelem *storage) { static void link_tail(grpc_mdelem_list *list, grpc_linked_mdelem *storage) {
@ -198,16 +203,17 @@ static void link_tail(grpc_mdelem_list *list, grpc_linked_mdelem *storage) {
assert_valid_list(list); assert_valid_list(list);
} }
grpc_error *grpc_metadata_batch_link_tail(grpc_metadata_batch *batch, grpc_error *grpc_metadata_batch_link_tail(grpc_exec_ctx *exec_ctx,
grpc_metadata_batch *batch,
grpc_linked_mdelem *storage) { grpc_linked_mdelem *storage) {
assert_valid_callouts(batch); assert_valid_callouts(exec_ctx, batch);
grpc_error *err = maybe_link_callout(batch, storage); grpc_error *err = maybe_link_callout(batch, storage);
if (err != GRPC_ERROR_NONE) { if (err != GRPC_ERROR_NONE) {
assert_valid_callouts(batch); assert_valid_callouts(exec_ctx, batch);
return err; return err;
} }
link_tail(&batch->list, storage); link_tail(&batch->list, storage);
assert_valid_callouts(batch); assert_valid_callouts(exec_ctx, batch);
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
@ -231,11 +237,11 @@ static void unlink_storage(grpc_mdelem_list *list,
void grpc_metadata_batch_remove(grpc_exec_ctx *exec_ctx, void grpc_metadata_batch_remove(grpc_exec_ctx *exec_ctx,
grpc_metadata_batch *batch, grpc_metadata_batch *batch,
grpc_linked_mdelem *storage) { grpc_linked_mdelem *storage) {
assert_valid_callouts(batch); assert_valid_callouts(exec_ctx, batch);
maybe_unlink_callout(batch, storage); maybe_unlink_callout(batch, storage);
unlink_storage(&batch->list, storage); unlink_storage(&batch->list, storage);
GRPC_MDELEM_UNREF(exec_ctx, storage->md); GRPC_MDELEM_UNREF(exec_ctx, storage->md);
assert_valid_callouts(batch); assert_valid_callouts(exec_ctx, batch);
} }
void grpc_metadata_batch_set_value(grpc_exec_ctx *exec_ctx, void grpc_metadata_batch_set_value(grpc_exec_ctx *exec_ctx,

@ -100,17 +100,17 @@ void grpc_metadata_batch_set_value(grpc_exec_ctx *exec_ctx,
\a storage is owned by the caller and must survive for the \a storage is owned by the caller and must survive for the
lifetime of batch. This usually means it should be around lifetime of batch. This usually means it should be around
for the lifetime of the call. */ for the lifetime of the call. */
grpc_error *grpc_metadata_batch_link_head(grpc_metadata_batch *batch, grpc_error *grpc_metadata_batch_link_head(
grpc_linked_mdelem *storage) grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
GRPC_MUST_USE_RESULT; grpc_linked_mdelem *storage) GRPC_MUST_USE_RESULT;
/** Add \a storage to the end of \a batch. storage->md is /** Add \a storage to the end of \a batch. storage->md is
assumed to be valid. assumed to be valid.
\a storage is owned by the caller and must survive for the \a storage is owned by the caller and must survive for the
lifetime of batch. This usually means it should be around lifetime of batch. This usually means it should be around
for the lifetime of the call. */ for the lifetime of the call. */
grpc_error *grpc_metadata_batch_link_tail(grpc_metadata_batch *batch, grpc_error *grpc_metadata_batch_link_tail(
grpc_linked_mdelem *storage) grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
GRPC_MUST_USE_RESULT; grpc_linked_mdelem *storage) GRPC_MUST_USE_RESULT;
/** Add \a elem_to_add as the first element in \a batch, using /** Add \a elem_to_add as the first element in \a batch, using
\a storage as backing storage for the linked list element. \a storage as backing storage for the linked list element.
@ -119,8 +119,8 @@ grpc_error *grpc_metadata_batch_link_tail(grpc_metadata_batch *batch,
for the lifetime of the call. for the lifetime of the call.
Takes ownership of \a elem_to_add */ Takes ownership of \a elem_to_add */
grpc_error *grpc_metadata_batch_add_head( grpc_error *grpc_metadata_batch_add_head(
grpc_metadata_batch *batch, grpc_linked_mdelem *storage, grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT; grpc_linked_mdelem *storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
/** Add \a elem_to_add as the last element in \a batch, using /** Add \a elem_to_add as the last element in \a batch, using
\a storage as backing storage for the linked list element. \a storage as backing storage for the linked list element.
\a storage is owned by the caller and must survive for the \a storage is owned by the caller and must survive for the
@ -128,8 +128,8 @@ grpc_error *grpc_metadata_batch_add_head(
for the lifetime of the call. for the lifetime of the call.
Takes ownership of \a elem_to_add */ Takes ownership of \a elem_to_add */
grpc_error *grpc_metadata_batch_add_tail( grpc_error *grpc_metadata_batch_add_tail(
grpc_metadata_batch *batch, grpc_linked_mdelem *storage, grpc_exec_ctx *exec_ctx, grpc_metadata_batch *batch,
grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT; grpc_linked_mdelem *storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT;
grpc_error *grpc_attach_md_to_error(grpc_error *src, grpc_mdelem md); grpc_error *grpc_attach_md_to_error(grpc_error *src, grpc_mdelem md);

Loading…
Cancel
Save