aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar hcaseyal <hcaseyal@gmail.com>2018-06-25 11:41:39 -0700
committerGravatar GitHub <noreply@github.com>2018-06-25 11:41:39 -0700
commit618a3f561d4a93f263cca23abad086ed8f4d5e86 (patch)
tree7f2b79337889ca2fb249164a3de6415622affee7 /src
parent3acf8e62079e727ae1925be759fa917f10e982bb (diff)
parent8f3222c4eb3ddcc7ec18e1f175e684f2fb862f94 (diff)
Merge pull request #15839 from hcaseyal/server_auth_allocation
Remove allocation in server_auth filter
Diffstat (limited to 'src')
-rw-r--r--src/core/lib/security/context/security_context.cc8
-rw-r--r--src/core/lib/security/context/security_context.h5
-rw-r--r--src/core/lib/security/transport/server_auth_filter.cc2
-rw-r--r--src/core/lib/surface/call.cc2
-rw-r--r--src/core/lib/surface/call.h2
5 files changed, 13 insertions, 6 deletions
diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc
index 14051a3f00..dbf6e39577 100644
--- a/src/core/lib/security/context/security_context.cc
+++ b/src/core/lib/security/context/security_context.cc
@@ -21,6 +21,7 @@
#include <string.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/security/context/security_context.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_create(void) {
+grpc_server_security_context* grpc_server_security_context_create(
+ gpr_arena* arena) {
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) {
@@ -112,7 +113,6 @@ void grpc_server_security_context_destroy(void* ctx) {
if (c->extension.instance != nullptr && c->extension.destroy != nullptr) {
c->extension.destroy(c->extension.instance);
}
- gpr_free(ctx);
}
/* --- grpc_auth_context --- */
diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h
index e782e4f28f..1e98d169a2 100644
--- a/src/core/lib/security/context/security_context.h
+++ b/src/core/lib/security/context/security_context.h
@@ -26,6 +26,8 @@
extern grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount;
+struct gpr_arena;
+
/* --- grpc_auth_context ---
High level authentication context object. Can optionally be chained. */
@@ -101,7 +103,8 @@ typedef struct {
grpc_security_context_extension extension;
} 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);
/* --- Channel args for auth context --- */
diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc
index a560a4a02e..0bf91d219e 100644
--- a/src/core/lib/security/transport/server_auth_filter.cc
+++ b/src/core/lib/security/transport/server_auth_filter.cc
@@ -214,7 +214,7 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
// Create server security context. Set its auth context from channel
// data and save it in the call context.
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);
calld->auth_context = server_ctx->auth_context;
if (args->context[GRPC_CONTEXT_SECURITY].value != nullptr) {
diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc
index 556eb234b4..3f26b05c34 100644
--- a/src/core/lib/surface/call.cc
+++ b/src/core/lib/surface/call.cc
@@ -1113,6 +1113,8 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b) {
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) {
return CALL_STACK_FROM_CALL(call);
}
diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h
index e000f13e7d..b3b06059d4 100644
--- a/src/core/lib/surface/call.h
+++ b/src/core/lib/surface/call.h
@@ -71,6 +71,8 @@ void grpc_call_internal_unref(grpc_call* call);
#define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call)
#endif
+gpr_arena* grpc_call_get_arena(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,