aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2018-10-12 14:33:45 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2018-10-16 14:10:30 -0700
commit6fb7bd23bf05b89394ed5ae6e8f60332d0f02fc6 (patch)
treec752b11cc0128ec7a342def2133c4c32772f4001
parent6f05a711e651196672450693493dee181368697d (diff)
s/GPR_ASSERT/GPR_CODEGEN_ASSERT and few more bugs
-rw-r--r--include/grpcpp/impl/codegen/async_stream.h27
-rw-r--r--include/grpcpp/impl/codegen/async_unary_call.h9
-rw-r--r--include/grpcpp/impl/codegen/call.h15
-rw-r--r--include/grpcpp/impl/codegen/client_callback.h2
-rw-r--r--include/grpcpp/impl/codegen/client_interceptor.h2
-rw-r--r--include/grpcpp/impl/codegen/client_unary_call.h5
-rw-r--r--include/grpcpp/impl/codegen/interceptor.h1
-rw-r--r--include/grpcpp/impl/codegen/service_type.h2
-rw-r--r--src/cpp/client/channel_cc.cc5
-rw-r--r--src/cpp/client/client_interceptor.cc4
-rw-r--r--src/cpp/server/server_cc.cc6
11 files changed, 33 insertions, 45 deletions
diff --git a/include/grpcpp/impl/codegen/async_stream.h b/include/grpcpp/impl/codegen/async_stream.h
index 258b73535e..6e58fd0eef 100644
--- a/include/grpcpp/impl/codegen/async_stream.h
+++ b/include/grpcpp/impl/codegen/async_stream.h
@@ -188,7 +188,7 @@ class ClientAsyncReaderFactory {
::grpc::internal::Call call = channel->CreateCall(method, context, cq);
return new (g_core_codegen_interface->grpc_call_arena_alloc(
call.call(), sizeof(ClientAsyncReader<R>)))
- ClientAsyncReader<R>(std::move(call), context, request, start, tag);
+ ClientAsyncReader<R>(call, context, request, start, tag);
}
};
} // namespace internal
@@ -264,7 +264,7 @@ class ClientAsyncReader final : public ClientAsyncReaderInterface<R> {
template <class W>
ClientAsyncReader(::grpc::internal::Call call, ClientContext* context,
const W& request, bool start, void* tag)
- : context_(context), call_(std::move(call)), started_(start) {
+ : context_(context), call_(call), started_(start) {
// TODO(ctiller): don't assert
GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
init_ops_.ClientSendClose();
@@ -336,7 +336,7 @@ class ClientAsyncWriterFactory {
::grpc::internal::Call call = channel->CreateCall(method, context, cq);
return new (g_core_codegen_interface->grpc_call_arena_alloc(
call.call(), sizeof(ClientAsyncWriter<W>)))
- ClientAsyncWriter<W>(std::move(call), context, response, start, tag);
+ ClientAsyncWriter<W>(call, context, response, start, tag);
}
};
} // namespace internal
@@ -430,7 +430,7 @@ class ClientAsyncWriter final : public ClientAsyncWriterInterface<W> {
template <class R>
ClientAsyncWriter(::grpc::internal::Call call, ClientContext* context,
R* response, bool start, void* tag)
- : context_(context), call_(std::move(call)), started_(start) {
+ : context_(context), call_(call), started_(start) {
finish_ops_.RecvMessage(response);
finish_ops_.AllowNoMessage();
if (start) {
@@ -501,7 +501,7 @@ class ClientAsyncReaderWriterFactory {
return new (g_core_codegen_interface->grpc_call_arena_alloc(
call.call(), sizeof(ClientAsyncReaderWriter<W, R>)))
- ClientAsyncReaderWriter<W, R>(std::move(call), context, start, tag);
+ ClientAsyncReaderWriter<W, R>(call, context, start, tag);
}
};
} // namespace internal
@@ -603,7 +603,7 @@ class ClientAsyncReaderWriter final
friend class internal::ClientAsyncReaderWriterFactory<W, R>;
ClientAsyncReaderWriter(::grpc::internal::Call call, ClientContext* context,
bool start, void* tag)
- : context_(context), call_(std::move(call)), started_(start) {
+ : context_(context), call_(call), started_(start) {
if (start) {
StartCallInternal(tag);
} else {
@@ -781,10 +781,7 @@ class ServerAsyncReader final : public ServerAsyncReaderInterface<W, R> {
}
private:
- ::grpc::internal::Call* BindCall(::grpc::internal::Call call) override {
- call_ = std::move(call);
- return &call_;
- }
+ void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
::grpc::internal::Call call_;
ServerContext* ctx_;
@@ -930,10 +927,7 @@ class ServerAsyncWriter final : public ServerAsyncWriterInterface<W> {
}
private:
- ::grpc::internal::Call* BindCall(::grpc::internal::Call call) override {
- call_ = std::move(call);
- return &call_;
- }
+ void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
template <class T>
void EnsureInitialMetadataSent(T* ops) {
@@ -1107,10 +1101,7 @@ class ServerAsyncReaderWriter final
private:
friend class ::grpc::Server;
- ::grpc::internal::Call* BindCall(::grpc::internal::Call call) override {
- call_ = std::move(call);
- return &call_;
- }
+ void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
template <class T>
void EnsureInitialMetadataSent(T* ops) {
diff --git a/include/grpcpp/impl/codegen/async_unary_call.h b/include/grpcpp/impl/codegen/async_unary_call.h
index f34bc6b792..60ff8e2f05 100644
--- a/include/grpcpp/impl/codegen/async_unary_call.h
+++ b/include/grpcpp/impl/codegen/async_unary_call.h
@@ -87,7 +87,7 @@ class ClientAsyncResponseReaderFactory {
::grpc::internal::Call call = channel->CreateCall(method, context, cq);
return new (g_core_codegen_interface->grpc_call_arena_alloc(
call.call(), sizeof(ClientAsyncResponseReader<R>)))
- ClientAsyncResponseReader<R>(std::move(call), context, request, start);
+ ClientAsyncResponseReader<R>(call, context, request, start);
}
};
} // namespace internal
@@ -165,7 +165,7 @@ class ClientAsyncResponseReader final
template <class W>
ClientAsyncResponseReader(::grpc::internal::Call call, ClientContext* context,
const W& request, bool start)
- : context_(context), call_(std::move(call)), started_(start) {
+ : context_(context), call_(call), started_(start) {
// Bind the metadata at time of StartCallInternal but set up the rest here
// TODO(ctiller): don't assert
GPR_CODEGEN_ASSERT(single_buf.SendMessage(request).ok());
@@ -286,10 +286,7 @@ class ServerAsyncResponseWriter final
}
private:
- ::grpc::internal::Call* BindCall(::grpc::internal::Call call) override {
- call_ = std::move(call);
- return &call_;
- }
+ void BindCall(::grpc::internal::Call* call) override { call_ = *call; }
::grpc::internal::Call call_;
ServerContext* ctx_;
diff --git a/include/grpcpp/impl/codegen/call.h b/include/grpcpp/impl/codegen/call.h
index 1f9128d8db..684148efb6 100644
--- a/include/grpcpp/impl/codegen/call.h
+++ b/include/grpcpp/impl/codegen/call.h
@@ -19,8 +19,8 @@
#ifndef GRPCPP_IMPL_CODEGEN_CALL_H
#define GRPCPP_IMPL_CODEGEN_CALL_H
-#include <array>
#include <assert.h>
+#include <array>
#include <cstring>
#include <functional>
#include <map>
@@ -900,7 +900,7 @@ class InterceptorBatchMethodsImpl
}
virtual void Hijack() override { /* fill this */
- GPR_ASSERT(!reverse_);
+ GPR_CODEGEN_ASSERT(!reverse_);
auto* rpc_info = call_->rpc_info();
rpc_info->hijacked_ = true;
rpc_info->hijacked_interceptor_ = curr_iteration_;
@@ -1158,17 +1158,18 @@ class CallOpSet : public CallOpSetInterface,
this->Op4::AddOp(ops, &nops);
this->Op5::AddOp(ops, &nops);
this->Op6::AddOp(ops, &nops);
- GPR_ASSERT(GRPC_CALL_OK == g_core_codegen_interface->grpc_call_start_batch(
- call_.call(), ops, nops, cq_tag(), nullptr));
+ GPR_CODEGEN_ASSERT(GRPC_CALL_OK ==
+ g_core_codegen_interface->grpc_call_start_batch(
+ call_.call(), ops, nops, cq_tag(), nullptr));
}
/* Should be called after interceptors are done running on the finalize result
* path */
void ContinueFinalizeResultAfterInterception() override {
done_intercepting_ = true;
- GPR_ASSERT(GRPC_CALL_OK ==
- g_core_codegen_interface->grpc_call_start_batch(
- call_.call(), nullptr, 0, cq_tag(), nullptr));
+ GPR_CODEGEN_ASSERT(GRPC_CALL_OK ==
+ g_core_codegen_interface->grpc_call_start_batch(
+ call_.call(), nullptr, 0, cq_tag(), nullptr));
}
private:
diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h
index ae9a8a95f9..4d4faea063 100644
--- a/include/grpcpp/impl/codegen/client_callback.h
+++ b/include/grpcpp/impl/codegen/client_callback.h
@@ -57,7 +57,7 @@ class CallbackUnaryCallImpl {
std::function<void(Status)> on_completion) {
CompletionQueue* cq = channel->CallbackCQ();
GPR_CODEGEN_ASSERT(cq != nullptr);
- Call call = channel->CreateCall(method, context, cq);
+ Call call(channel->CreateCall(method, context, cq));
using FullCallOpSet =
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h
index 6b02a89012..50272721f0 100644
--- a/include/grpcpp/impl/codegen/client_interceptor.h
+++ b/include/grpcpp/impl/codegen/client_interceptor.h
@@ -105,7 +105,7 @@ class ClientRpcInfo {
void RunInterceptor(
experimental::InterceptorBatchMethods* interceptor_methods,
unsigned int pos) {
- GPR_ASSERT(pos < interceptors_.size());
+ GPR_CODEGEN_ASSERT(pos < interceptors_.size());
interceptors_[pos]->Intercept(interceptor_methods);
}
diff --git a/include/grpcpp/impl/codegen/client_unary_call.h b/include/grpcpp/impl/codegen/client_unary_call.h
index dad31546cc..e4e8364e07 100644
--- a/include/grpcpp/impl/codegen/client_unary_call.h
+++ b/include/grpcpp/impl/codegen/client_unary_call.h
@@ -52,7 +52,7 @@ class BlockingUnaryCallImpl {
CompletionQueue cq(grpc_completion_queue_attributes{
GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING,
nullptr}); // Pluckable completion queue
- call_ = std::move(channel->CreateCall(method, context, &cq));
+ Call call(channel->CreateCall(method, context, &cq));
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>,
CallOpClientSendClose, CallOpClientRecvStatus>
@@ -68,7 +68,7 @@ class BlockingUnaryCallImpl {
ops.AllowNoMessage();
ops.ClientSendClose();
ops.ClientRecvStatus(context, &status_);
- call_.PerformOps(&ops);
+ call.PerformOps(&ops);
if (cq.Pluck(&ops)) {
if (!ops.got_message && status_.ok()) {
status_ = Status(StatusCode::UNIMPLEMENTED,
@@ -82,7 +82,6 @@ class BlockingUnaryCallImpl {
private:
Status status_;
- Call call_;
};
} // namespace internal
diff --git a/include/grpcpp/impl/codegen/interceptor.h b/include/grpcpp/impl/codegen/interceptor.h
index 0b6d796d35..2409388695 100644
--- a/include/grpcpp/impl/codegen/interceptor.h
+++ b/include/grpcpp/impl/codegen/interceptor.h
@@ -21,6 +21,7 @@
#include <grpc/impl/codegen/grpc_types.h>
#include <grpcpp/impl/codegen/config.h>
+#include <grpcpp/impl/codegen/core_codegen_interface.h>
// struct grpc_byte_buffer;
// struct grpc_status_code;
diff --git a/include/grpcpp/impl/codegen/service_type.h b/include/grpcpp/impl/codegen/service_type.h
index e6ade93087..9f1a052168 100644
--- a/include/grpcpp/impl/codegen/service_type.h
+++ b/include/grpcpp/impl/codegen/service_type.h
@@ -50,7 +50,7 @@ class ServerAsyncStreamingInterface {
private:
friend class ::grpc::ServerInterface;
- virtual Call* BindCall(Call call) = 0;
+ virtual void BindCall(Call* call) = 0;
};
} // namespace internal
diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc
index 4d509c93c2..12ff20c7ea 100644
--- a/src/cpp/client/channel_cc.cc
+++ b/src/cpp/client/channel_cc.cc
@@ -57,9 +57,8 @@ Channel::Channel(
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators)
: host_(host), c_channel_(channel) {
- auto* vector = interceptor_creators.release();
- if (vector != nullptr) {
- interceptor_creators_ = std::move(*vector);
+ if (interceptor_creators != nullptr) {
+ interceptor_creators_ = std::move(*interceptor_creators);
}
g_gli_initializer.summon();
}
diff --git a/src/cpp/client/client_interceptor.cc b/src/cpp/client/client_interceptor.cc
index 7cc07fa46d..02b3d825b6 100644
--- a/src/cpp/client/client_interceptor.cc
+++ b/src/cpp/client/client_interceptor.cc
@@ -20,7 +20,7 @@
namespace grpc {
namespace experimental {
-const ClientRpcInfo::grpc::InterceptedMessage& outgoing_message() {}
+/*const ClientRpcInfo::grpc::InterceptedMessage& outgoing_message() {}
grpc::InterceptedMessage* ClientRpcInfo::mutable_outgoing_message() {}
const grpc::InterceptedMessage& ClientRpcInfo::received_message() {}
grpc::InterceptedMessage* ClientRpcInfo::mutable_received_message() {}
@@ -41,6 +41,6 @@ void ClientRpcInfo::set_server_initial_metadata(
const std::multimap<grpc::string, grpc::string>& overwrite) {}
void ClientRpcInfo::set_server_trailing_metadata(
const std::multimap<grpc::string, grpc::string>& overwrite) {}
-void ClientRpcInfo::set_status(Status status) {}
+void ClientRpcInfo::set_status(Status status) {}*/
} // namespace experimental
} // namespace grpc
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index 2faaf618a5..a9babae63c 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -695,11 +695,11 @@ bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag,
internal::Call call(call_, server_, call_cq_,
server_->max_receive_message_size());
- // just the pointers inside call are copied here
- auto* new_call = stream_->BindCall(std::move(call));
if (*status && call_) {
- context_->BeginCompletionOp(new_call);
+ context_->BeginCompletionOp(&call);
}
+ // just the pointers inside call are copied here
+ stream_->BindCall(&call);
*tag = tag_;
if (delete_on_finalize_) {