diff options
author | Mark D. Roth <roth@google.com> | 2018-06-27 07:24:32 -0700 |
---|---|---|
committer | Mark D. Roth <roth@google.com> | 2018-06-27 09:59:05 -0700 |
commit | d463a64384649b499d9eec7cff1cacd71d9f3261 (patch) | |
tree | 2c5fd935eb797d39cead502c791e9d3e153e1f61 | |
parent | 2223e60b63cb7d9cadc4db30064767738d2b7559 (diff) | |
download | grpc-grpc-d463a64384649b499d9eec7cff1cacd71d9f3261.tar.gz |
Fix subchannel call to align its call stack (similar to 15b37ac for parent call).
-rw-r--r-- | src/core/ext/filters/client_channel/subchannel.cc | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index f010002ab9..8ab3fe40f5 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -38,6 +38,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/debug/stats.h" +#include "src/core/lib/gpr/alloc.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" @@ -140,9 +141,13 @@ struct grpc_subchannel_call { grpc_closure* schedule_closure_after_destroy; }; -#define SUBCHANNEL_CALL_TO_CALL_STACK(call) ((grpc_call_stack*)((call) + 1)) -#define CALLSTACK_TO_SUBCHANNEL_CALL(callstack) \ - (((grpc_subchannel_call*)(callstack)) - 1) +#define SUBCHANNEL_CALL_TO_CALL_STACK(call) \ + (grpc_call_stack*)((char*)(call) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE( \ + sizeof(grpc_subchannel_call))) +#define CALLSTACK_TO_SUBCHANNEL_CALL(callstack) \ + (grpc_subchannel_call*)(((char*)(call_stack)) - \ + GPR_ROUND_UP_TO_ALIGNMENT_SIZE( \ + sizeof(grpc_subchannel_call))) static void on_subchannel_connected(void* subchannel, grpc_error* error); @@ -783,9 +788,17 @@ void ConnectedSubchannel::Ping(grpc_closure* on_initiate, grpc_error* ConnectedSubchannel::CreateCall(const CallArgs& args, grpc_subchannel_call** call) { - *call = static_cast<grpc_subchannel_call*>(gpr_arena_alloc( - args.arena, sizeof(grpc_subchannel_call) + - channel_stack_->call_stack_size + args.parent_data_size)); + size_t allocation_size = + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_subchannel_call)); + if (args.parent_data_size > 0) { + allocation_size += + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(channel_stack_->call_stack_size) + + args.parent_data_size; + } else { + allocation_size += channel_stack_->call_stack_size; + } + *call = static_cast<grpc_subchannel_call*>( + gpr_arena_alloc(args.arena, allocation_size)); grpc_call_stack* callstk = SUBCHANNEL_CALL_TO_CALL_STACK(*call); RefCountedPtr<ConnectedSubchannel> connection = Ref(DEBUG_LOCATION, "subchannel_call"); |