Merge pull request #15839 from hcaseyal/server_auth_allocation

Remove allocation in server_auth filter
pull/15879/head
hcaseyal 7 years ago committed by GitHub
commit 618a3f561d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/core/lib/security/context/security_context.cc
  2. 5
      src/core/lib/security/context/security_context.h
  3. 2
      src/core/lib/security/transport/server_auth_filter.cc
  4. 2
      src/core/lib/surface/call.cc
  5. 2
      src/core/lib/surface/call.h

@ -21,6 +21,7 @@
#include <string.h> #include <string.h>
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/arena.h"
#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/api_trace.h"
@ -99,10 +100,10 @@ void grpc_client_security_context_destroy(void* ctx) {
} }
/* --- grpc_server_security_context --- */ /* --- grpc_server_security_context --- */
grpc_server_security_context* grpc_server_security_context_create(
grpc_server_security_context* grpc_server_security_context_create(void) { gpr_arena* arena) {
return static_cast<grpc_server_security_context*>( return static_cast<grpc_server_security_context*>(
gpr_zalloc(sizeof(grpc_server_security_context))); gpr_arena_alloc(arena, sizeof(grpc_server_security_context)));
} }
void grpc_server_security_context_destroy(void* ctx) { void grpc_server_security_context_destroy(void* ctx) {
@ -112,7 +113,6 @@ void grpc_server_security_context_destroy(void* ctx) {
if (c->extension.instance != nullptr && c->extension.destroy != nullptr) { if (c->extension.instance != nullptr && c->extension.destroy != nullptr) {
c->extension.destroy(c->extension.instance); c->extension.destroy(c->extension.instance);
} }
gpr_free(ctx);
} }
/* --- grpc_auth_context --- */ /* --- grpc_auth_context --- */

@ -26,6 +26,8 @@
extern grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount; extern grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount;
struct gpr_arena;
/* --- grpc_auth_context --- /* --- grpc_auth_context ---
High level authentication context object. Can optionally be chained. */ High level authentication context object. Can optionally be chained. */
@ -101,7 +103,8 @@ typedef struct {
grpc_security_context_extension extension; grpc_security_context_extension extension;
} grpc_server_security_context; } grpc_server_security_context;
grpc_server_security_context* grpc_server_security_context_create(void); grpc_server_security_context* grpc_server_security_context_create(
gpr_arena* arena);
void grpc_server_security_context_destroy(void* ctx); void grpc_server_security_context_destroy(void* ctx);
/* --- Channel args for auth context --- */ /* --- Channel args for auth context --- */

@ -214,7 +214,7 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
// Create server security context. Set its auth context from channel // Create server security context. Set its auth context from channel
// data and save it in the call context. // data and save it in the call context.
grpc_server_security_context* server_ctx = grpc_server_security_context* server_ctx =
grpc_server_security_context_create(); grpc_server_security_context_create(args->arena);
server_ctx->auth_context = grpc_auth_context_create(chand->auth_context); server_ctx->auth_context = grpc_auth_context_create(chand->auth_context);
calld->auth_context = server_ctx->auth_context; calld->auth_context = server_ctx->auth_context;
if (args->context[GRPC_CONTEXT_SECURITY].value != nullptr) { if (args->context[GRPC_CONTEXT_SECURITY].value != nullptr) {

@ -1113,6 +1113,8 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b) {
publish_app_metadata(call, b, true); publish_app_metadata(call, b, true);
} }
gpr_arena* grpc_call_get_arena(grpc_call* call) { return call->arena; }
grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) { grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
return CALL_STACK_FROM_CALL(call); return CALL_STACK_FROM_CALL(call);
} }

@ -71,6 +71,8 @@ void grpc_call_internal_unref(grpc_call* call);
#define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call) #define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call)
#endif #endif
gpr_arena* grpc_call_get_arena(grpc_call* call);
grpc_call_stack* grpc_call_get_call_stack(grpc_call* call); grpc_call_stack* grpc_call_get_call_stack(grpc_call* call);
grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call, grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call,

Loading…
Cancel
Save