From 7f3f7076f3160e0da7990c6478eb9de0e1db8afa Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 29 Jun 2016 07:58:33 -0700 Subject: [PATCH] Fix C++ API to support returning an error from call data initialization. --- include/grpc++/channel_filter.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/grpc++/channel_filter.h b/include/grpc++/channel_filter.h index 0a327b82229..b474722c342 100644 --- a/include/grpc++/channel_filter.h +++ b/include/grpc++/channel_filter.h @@ -231,6 +231,8 @@ class CallData { public: virtual ~CallData() {} + virtual grpc_error* Init() { return GRPC_ERROR_NONE; } + virtual void StartTransportStreamOp(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, TransportStreamOp *op); @@ -242,8 +244,6 @@ class CallData { virtual char *GetPeer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem); protected: -// FIXME: once PR #7024 has been merged, update this API to provide a -// way to return an error from call initialization explicit CallData(const ChannelData &) {} }; @@ -281,12 +281,14 @@ class ChannelFilter GRPC_FINAL { static const size_t call_data_size = sizeof(CallDataType); - static void InitCallElement(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_call_element_args *args) { + static grpc_error* InitCallElement(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_call_element_args *args) { const ChannelDataType &channel_data = *(ChannelDataType *)elem->channel_data; // Construct the object in the already-allocated memory. - new (elem->call_data) CallDataType(channel_data); + CallDataType* call_data = new (elem->call_data) CallDataType(channel_data); + return call_data->Init(); } static void DestroyCallElement(grpc_exec_ctx *exec_ctx,