From 3e8deb188f63f5acb0f06c1169b230f82d5eed14 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 11 Jan 2017 14:06:16 -0800 Subject: [PATCH] Fix sanity: core_banned_functions --- .../ext/transport/chttp2/transport/hpack_encoder.c | 2 +- src/core/lib/channel/http_server_filter.c | 13 +++++++------ .../credentials/plugin/plugin_credentials.c | 4 ++-- src/core/lib/slice/slice_hash_table.c | 2 +- src/core/lib/surface/call_details.c | 4 ++-- src/core/lib/surface/channel.c | 8 ++++---- src/core/lib/surface/server.c | 4 ++-- src/core/lib/transport/metadata_batch.c | 6 +++--- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index ae2055bc3e9..63df8e135f8 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -296,7 +296,7 @@ static grpc_slice get_wire_value(grpc_mdelem elem, uint8_t *huffman_prefix) { } /* TODO(ctiller): opportunistically compress non-binary headers */ *huffman_prefix = 0x00; - return grpc_slice_ref(GRPC_MDVALUE(elem)); + return grpc_slice_ref_internal(GRPC_MDVALUE(elem)); } static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c, diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index 776eff456d1..da105d06fdb 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -199,12 +199,13 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, } if (b->idx.named.host != NULL) { - add_error(error_name, &error, - grpc_metadata_batch_substitute( - exec_ctx, b, b->idx.named.host, - grpc_mdelem_from_slices( - exec_ctx, GRPC_MDSTR_AUTHORITY, - grpc_slice_ref(GRPC_MDVALUE(b->idx.named.host->md))))); + add_error( + error_name, &error, + grpc_metadata_batch_substitute( + exec_ctx, b, b->idx.named.host, + grpc_mdelem_from_slices( + exec_ctx, GRPC_MDSTR_AUTHORITY, + grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.host->md))))); } if (b->idx.named.authority == NULL) { diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.c b/src/core/lib/security/credentials/plugin/plugin_credentials.c index f98c9cd8ef2..c5e8d67039d 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.c +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.c @@ -97,8 +97,8 @@ static void plugin_md_request_metadata_ready(void *request, } else if (num_md > 0) { md_array = gpr_malloc(num_md * sizeof(grpc_credentials_md)); for (i = 0; i < num_md; i++) { - md_array[i].key = grpc_slice_ref(md[i].key); - md_array[i].value = grpc_slice_ref(md[i].value); + md_array[i].key = grpc_slice_ref_internal(md[i].key); + md_array[i].value = grpc_slice_ref_internal(md[i].value); } r->cb(&exec_ctx, r->user_data, md_array, num_md, GRPC_CREDENTIALS_OK, NULL); diff --git a/src/core/lib/slice/slice_hash_table.c b/src/core/lib/slice/slice_hash_table.c index 1f3ca72ce6b..46c109439b4 100644 --- a/src/core/lib/slice/slice_hash_table.c +++ b/src/core/lib/slice/slice_hash_table.c @@ -75,7 +75,7 @@ static void grpc_slice_hash_table_add( grpc_slice_hash_table_find_index(table, key, true /* find_empty */); GPR_ASSERT(idx != table->size); // Table should never be full. grpc_slice_hash_table_entry* entry = &table->entries[idx]; - entry->key = grpc_slice_ref(key); + entry->key = grpc_slice_ref_internal(key); entry->value = vtable->copy_value(value); entry->vtable = vtable; } diff --git a/src/core/lib/surface/call_details.c b/src/core/lib/surface/call_details.c index 5efa3b0141b..51e84c29459 100644 --- a/src/core/lib/surface/call_details.c +++ b/src/core/lib/surface/call_details.c @@ -47,6 +47,6 @@ void grpc_call_details_init(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_slice_unref(cd->method); - grpc_slice_unref(cd->host); + grpc_slice_unref_internal(exec_ctx, cd->method); + grpc_slice_unref_internal(exec_ctx, cd->host); } diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index 1ef023ed628..1a257489779 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -234,9 +234,9 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, grpc_call *call = grpc_channel_create_call_internal( &exec_ctx, channel, parent_call, propagation_mask, cq, NULL, grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_PATH, - grpc_slice_ref(method)), + grpc_slice_ref_internal(method)), host != NULL ? grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_AUTHORITY, - grpc_slice_ref(*host)) + grpc_slice_ref_internal(*host)) : GRPC_MDNULL, deadline); grpc_exec_ctx_finish(&exec_ctx); @@ -251,9 +251,9 @@ grpc_call *grpc_channel_create_pollset_set_call( return grpc_channel_create_call_internal( exec_ctx, channel, parent_call, propagation_mask, NULL, pollset_set, grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_PATH, - grpc_slice_ref(method)), + grpc_slice_ref_internal(method)), host != NULL ? grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY, - grpc_slice_ref(*host)) + grpc_slice_ref_internal(*host)) : GRPC_MDNULL, deadline); } diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 7d0b30e97a6..3782b491226 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -748,9 +748,9 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr, if (error == GRPC_ERROR_NONE) { GPR_ASSERT(calld->recv_initial_metadata->idx.named.path != NULL); GPR_ASSERT(calld->recv_initial_metadata->idx.named.authority != NULL); - calld->path = grpc_slice_ref( + calld->path = grpc_slice_ref_internal( GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.path->md)); - calld->host = grpc_slice_ref( + calld->host = grpc_slice_ref_internal( GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.authority->md)); calld->path_set = true; calld->host_set = true; diff --git a/src/core/lib/transport/metadata_batch.c b/src/core/lib/transport/metadata_batch.c index 18b0f161ab5..c11c797d394 100644 --- a/src/core/lib/transport/metadata_batch.c +++ b/src/core/lib/transport/metadata_batch.c @@ -74,7 +74,7 @@ static void assert_valid_callouts(grpc_metadata_batch *batch) { if (callout_idx != GRPC_BATCH_CALLOUTS_COUNT) { GPR_ASSERT(batch->idx.array[callout_idx] == l); } - grpc_slice_unref(key_interned); + grpc_slice_unref_internal(exec_ctx, key_interned); } #endif } @@ -242,8 +242,8 @@ void grpc_metadata_batch_set_value(grpc_exec_ctx *exec_ctx, grpc_linked_mdelem *storage, grpc_slice value) { grpc_mdelem old = storage->md; - grpc_mdelem new = - grpc_mdelem_from_slices(exec_ctx, grpc_slice_ref(GRPC_MDKEY(old)), value); + grpc_mdelem new = grpc_mdelem_from_slices( + exec_ctx, grpc_slice_ref_internal(GRPC_MDKEY(old)), value); storage->md = new; GRPC_MDELEM_UNREF(exec_ctx, old); }