@ -18,6 +18,7 @@
# ifndef GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H
# define GRPCPP_IMPL_SERVER_CALLBACK_HANDLERS_H
# include <grpc/grpc.h>
# include <grpcpp/impl/rpc_service_method.h>
# include <grpcpp/server_context.h>
# include <grpcpp/support/message_allocator.h>
@ -43,13 +44,13 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
void RunHandler ( const HandlerParameter & param ) final {
// Arena allocate a controller structure (that includes request/response)
grpc : : g_core_codegen_interface - > grpc _call_ref( param . call - > call ( ) ) ;
grpc_call_ref ( param . call - > call ( ) ) ;
auto * allocator_state =
static_cast < MessageHolder < RequestType , ResponseType > * > (
param . internal_data ) ;
auto * call = new ( grpc : : g_core_codegen_interface - > grpc_call_arena_alloc (
param . call - > call ( ) , sizeof ( ServerCallbackUnaryImpl ) ) )
auto * call = new ( grpc_call_arena_alloc ( param . call - > call ( ) ,
sizeof ( ServerCallbackUnaryImpl ) ) )
ServerCallbackUnaryImpl (
static_cast < grpc : : CallbackServerContext * > ( param . server_context ) ,
param . call , allocator_state , param . call_requester ) ;
@ -66,8 +67,8 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
if ( reactor = = nullptr ) {
// if deserialization or reactor creator failed, we need to fail the call
reactor = new ( grpc : : g_core_codegen_interface - > grpc_call_arena_alloc (
param . call - > call ( ) , sizeof ( UnimplementedUnaryReactor ) ) )
reactor = new ( grpc_call_arena_alloc ( param . call - > call ( ) ,
sizeof ( UnimplementedUnaryReactor ) ) )
UnimplementedUnaryReactor (
grpc : : Status ( grpc : : StatusCode : : UNIMPLEMENTED , " " ) ) ;
}
@ -85,10 +86,9 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
if ( allocator_ ! = nullptr ) {
allocator_state = allocator_ - > AllocateMessages ( ) ;
} else {
allocator_state =
new ( grpc : : g_core_codegen_interface - > grpc_call_arena_alloc (
call , sizeof ( DefaultMessageHolder < RequestType , ResponseType > ) ) )
DefaultMessageHolder < RequestType , ResponseType > ( ) ;
allocator_state = new ( grpc_call_arena_alloc (
call , sizeof ( DefaultMessageHolder < RequestType , ResponseType > ) ) )
DefaultMessageHolder < RequestType , ResponseType > ( ) ;
}
* handler_data = allocator_state ;
request = allocator_state - > request ( ) ;
@ -208,7 +208,7 @@ class CallbackUnaryHandler : public grpc::internal::MethodHandler {
ctx_ - > context_allocator ( ) - > Release ( ctx_ ) ;
}
this - > ~ ServerCallbackUnaryImpl ( ) ; // explicitly call destructor
grpc : : g_core_codegen_interface - > grpc _call_unref( call ) ;
grpc_call_unref ( call ) ;
call_requester ( ) ;
}
@ -256,10 +256,10 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler {
: get_reactor_ ( std : : move ( get_reactor ) ) { }
void RunHandler ( const HandlerParameter & param ) final {
// Arena allocate a reader structure (that includes response)
grpc : : g_core_codegen_interface - > grpc _call_ref( param . call - > call ( ) ) ;
grpc_call_ref ( param . call - > call ( ) ) ;
auto * reader = new ( grpc : : g_core_codegen_interface - > grpc_call_arena_alloc (
param . call - > call ( ) , sizeof ( ServerCallbackReaderImpl ) ) )
auto * reader = new ( grpc_call_arena_alloc ( param . call - > call ( ) ,
sizeof ( ServerCallbackReaderImpl ) ) )
ServerCallbackReaderImpl (
static_cast < grpc : : CallbackServerContext * > ( param . server_context ) ,
param . call , param . call_requester ) ;
@ -282,7 +282,7 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler {
if ( reactor = = nullptr ) {
// if deserialization or reactor creator failed, we need to fail the call
reactor = new ( grpc : : g_core_codegen_interface - > grpc _call_arena_alloc(
reactor = new ( grpc_call_arena_alloc (
param . call - > call ( ) , sizeof ( UnimplementedReadReactor < RequestType > ) ) )
UnimplementedReadReactor < RequestType > (
grpc : : Status ( grpc : : StatusCode : : UNIMPLEMENTED , " " ) ) ;
@ -405,7 +405,7 @@ class CallbackClientStreamingHandler : public grpc::internal::MethodHandler {
ctx_ - > context_allocator ( ) - > Release ( ctx_ ) ;
}
this - > ~ ServerCallbackReaderImpl ( ) ; // explicitly call destructor
grpc : : g_core_codegen_interface - > grpc _call_unref( call ) ;
grpc_call_unref ( call ) ;
call_requester ( ) ;
}
@ -447,10 +447,10 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
: get_reactor_ ( std : : move ( get_reactor ) ) { }
void RunHandler ( const HandlerParameter & param ) final {
// Arena allocate a writer structure
grpc : : g_core_codegen_interface - > grpc _call_ref( param . call - > call ( ) ) ;
grpc_call_ref ( param . call - > call ( ) ) ;
auto * writer = new ( grpc : : g_core_codegen_interface - > grpc_call_arena_alloc (
param . call - > call ( ) , sizeof ( ServerCallbackWriterImpl ) ) )
auto * writer = new ( grpc_call_arena_alloc ( param . call - > call ( ) ,
sizeof ( ServerCallbackWriterImpl ) ) )
ServerCallbackWriterImpl (
static_cast < grpc : : CallbackServerContext * > ( param . server_context ) ,
param . call , static_cast < RequestType * > ( param . request ) ,
@ -473,7 +473,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
}
if ( reactor = = nullptr ) {
// if deserialization or reactor creator failed, we need to fail the call
reactor = new ( grpc : : g_core_codegen_interface - > grpc _call_arena_alloc(
reactor = new ( grpc_call_arena_alloc (
param . call - > call ( ) , sizeof ( UnimplementedWriteReactor < ResponseType > ) ) )
UnimplementedWriteReactor < ResponseType > (
grpc : : Status ( grpc : : StatusCode : : UNIMPLEMENTED , " " ) ) ;
@ -486,8 +486,8 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
grpc : : Status * status , void * * /*handler_data*/ ) final {
grpc : : ByteBuffer buf ;
buf . set_buffer ( req ) ;
auto * request = new ( grpc : : g_core_codegen_interface - > grpc_call_arena_alloc (
call , sizeof ( RequestType ) ) ) RequestType ( ) ;
auto * request =
new ( grpc_call_arena_alloc ( call , sizeof ( RequestType ) ) ) RequestType ( ) ;
* status =
grpc : : SerializationTraits < RequestType > : : Deserialize ( & buf , request ) ;
buf . Release ( ) ;
@ -630,7 +630,7 @@ class CallbackServerStreamingHandler : public grpc::internal::MethodHandler {
ctx_ - > context_allocator ( ) - > Release ( ctx_ ) ;
}
this - > ~ ServerCallbackWriterImpl ( ) ; // explicitly call destructor
grpc : : g_core_codegen_interface - > grpc _call_unref( call ) ;
grpc_call_unref ( call ) ;
call_requester ( ) ;
}
@ -672,9 +672,9 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
get_reactor )
: get_reactor_ ( std : : move ( get_reactor ) ) { }
void RunHandler ( const HandlerParameter & param ) final {
grpc : : g_core_codegen_interface - > grpc _call_ref( param . call - > call ( ) ) ;
grpc_call_ref ( param . call - > call ( ) ) ;
auto * stream = new ( grpc : : g_core_codegen_interface - > grpc _call_arena_alloc(
auto * stream = new ( grpc_call_arena_alloc (
param . call - > call ( ) , sizeof ( ServerCallbackReaderWriterImpl ) ) )
ServerCallbackReaderWriterImpl (
static_cast < grpc : : CallbackServerContext * > ( param . server_context ) ,
@ -697,7 +697,7 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
if ( reactor = = nullptr ) {
// if deserialization or reactor creator failed, we need to fail the call
reactor = new ( grpc : : g_core_codegen_interface - > grpc _call_arena_alloc(
reactor = new ( grpc_call_arena_alloc (
param . call - > call ( ) ,
sizeof ( UnimplementedBidiReactor < RequestType , ResponseType > ) ) )
UnimplementedBidiReactor < RequestType , ResponseType > (
@ -846,7 +846,7 @@ class CallbackBidiHandler : public grpc::internal::MethodHandler {
ctx_ - > context_allocator ( ) - > Release ( ctx_ ) ;
}
this - > ~ ServerCallbackReaderWriterImpl ( ) ; // explicitly call destructor
grpc : : g_core_codegen_interface - > grpc _call_unref( call ) ;
grpc_call_unref ( call ) ;
call_requester ( ) ;
}