aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2017-02-17 09:55:03 -0800
committerGravatar yang-g <yangg@google.com>2017-02-17 09:55:03 -0800
commit55c6ebfd7a9f8077557a43dee9bf67d5c60528cb (patch)
treebac81627fcc53203050c4362b7036e7c486c44d0 /include/grpc++
parent076bac017b200accb8071e569b471f118fc3ba32 (diff)
parent13e185419cd177b7fb552601665e43820321a96b (diff)
Merge branch 'master' into health
Diffstat (limited to 'include/grpc++')
-rw-r--r--include/grpc++/impl/codegen/call.h15
-rw-r--r--include/grpc++/impl/codegen/proto_utils.h9
-rw-r--r--include/grpc++/impl/codegen/server_context.h9
-rw-r--r--include/grpc++/impl/codegen/sync_stream.h8
-rw-r--r--include/grpc++/server.h2
-rw-r--r--include/grpc++/test/server_context_test_spouse.h15
6 files changed, 49 insertions, 9 deletions
diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h
index a17cdf9236..19a5ca2b2e 100644
--- a/include/grpc++/impl/codegen/call.h
+++ b/include/grpc++/impl/codegen/call.h
@@ -618,7 +618,17 @@ class Call final {
public:
/* call is owned by the caller */
Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq)
- : call_hook_(call_hook), cq_(cq), call_(call) {}
+ : call_hook_(call_hook),
+ cq_(cq),
+ call_(call),
+ max_receive_message_size_(-1) {}
+
+ Call(grpc_call* call, CallHook* call_hook, CompletionQueue* cq,
+ int max_receive_message_size)
+ : call_hook_(call_hook),
+ cq_(cq),
+ call_(call),
+ max_receive_message_size_(max_receive_message_size) {}
void PerformOps(CallOpSetInterface* ops) {
call_hook_->PerformOpsOnCall(ops, this);
@@ -627,10 +637,13 @@ class Call final {
grpc_call* call() const { return call_; }
CompletionQueue* cq() const { return cq_; }
+ int max_receive_message_size() const { return max_receive_message_size_; }
+
private:
CallHook* call_hook_;
CompletionQueue* cq_;
grpc_call* call_;
+ int max_receive_message_size_;
};
} // namespace grpc
diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h
index 2123b62ed9..6df9de4fd2 100644
--- a/include/grpc++/impl/codegen/proto_utils.h
+++ b/include/grpc++/impl/codegen/proto_utils.h
@@ -50,6 +50,8 @@ extern CoreCodegenInterface* g_core_codegen_interface;
namespace internal {
+class GrpcBufferWriterPeer;
+
const int kGrpcBufferWriterMaxBufferLength = 8192;
class GrpcBufferWriter final
@@ -91,13 +93,18 @@ class GrpcBufferWriter final
&slice_, GRPC_SLICE_LENGTH(slice_) - count);
g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_);
}
- have_backup_ = true;
+ // It's dangerous to keep an inlined grpc_slice as the backup slice, since
+ // on a following Next() call, a reference will be returned to this slice
+ // via GRPC_SLICE_START_PTR, which will not be an adddress held by
+ // slice_buffer_.
+ have_backup_ = backup_slice_.refcount != NULL;
byte_count_ -= count;
}
grpc::protobuf::int64 ByteCount() const override { return byte_count_; }
private:
+ friend class GrpcBufferWriterPeer;
const int block_size_;
int64_t byte_count_;
grpc_slice_buffer* slice_buffer_;
diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h
index 8c7fe0809e..43bbff6ce9 100644
--- a/include/grpc++/impl/codegen/server_context.h
+++ b/include/grpc++/impl/codegen/server_context.h
@@ -36,6 +36,10 @@
#include <map>
#include <memory>
+#include <vector>
+
+#include <grpc/impl/codegen/compression_types.h>
+#include <grpc/load_reporting.h>
#include <grpc++/impl/codegen/config.h>
#include <grpc++/impl/codegen/create_auth_context.h>
@@ -43,14 +47,12 @@
#include <grpc++/impl/codegen/security/auth_context.h>
#include <grpc++/impl/codegen/string_ref.h>
#include <grpc++/impl/codegen/time.h>
-#include <grpc/impl/codegen/compression_types.h>
struct grpc_metadata;
struct grpc_call;
struct census_context;
namespace grpc {
-
class ClientContext;
template <class W, class R>
class ServerAsyncReader;
@@ -143,6 +145,9 @@ class ServerContext {
}
void set_compression_algorithm(grpc_compression_algorithm algorithm);
+ // Set the load reporting costs in \a cost_data for the call.
+ void SetLoadReportingCosts(const std::vector<grpc::string>& cost_data);
+
std::shared_ptr<const AuthContext> auth_context() const {
if (auth_context_.get() == nullptr) {
auth_context_ = CreateAuthContext(call_);
diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h
index 1f7708bab9..4d9b074e95 100644
--- a/include/grpc++/impl/codegen/sync_stream.h
+++ b/include/grpc++/impl/codegen/sync_stream.h
@@ -160,7 +160,7 @@ class ClientReader final : public ClientReaderInterface<R> {
}
bool NextMessageSize(uint32_t* sz) override {
- *sz = INT_MAX;
+ *sz = call_.max_receive_message_size();
return true;
}
@@ -310,7 +310,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
}
bool NextMessageSize(uint32_t* sz) override {
- *sz = INT_MAX;
+ *sz = call_.max_receive_message_size();
return true;
}
@@ -382,7 +382,7 @@ class ServerReader final : public ServerReaderInterface<R> {
}
bool NextMessageSize(uint32_t* sz) override {
- *sz = INT_MAX;
+ *sz = call_->max_receive_message_size();
return true;
}
@@ -474,7 +474,7 @@ class ServerReaderWriterBody final {
}
bool NextMessageSize(uint32_t* sz) {
- *sz = INT_MAX;
+ *sz = call_->max_receive_message_size();
return true;
}
diff --git a/include/grpc++/server.h b/include/grpc++/server.h
index e3e9174c9c..3e54405974 100644
--- a/include/grpc++/server.h
+++ b/include/grpc++/server.h
@@ -86,6 +86,8 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen {
virtual void PreSynchronousRequest(ServerContext* context) = 0;
/// Called after application callback for each synchronous server request
virtual void PostSynchronousRequest(ServerContext* context) = 0;
+ /// Called before server is started.
+ virtual void PreServerStart(Server* server) {}
};
/// Set the global callback object. Can only be called once. Does not take
/// ownership of callbacks, and expects the pointed to object to be alive
diff --git a/include/grpc++/test/server_context_test_spouse.h b/include/grpc++/test/server_context_test_spouse.h
index b2482854b5..bac0db7bdc 100644
--- a/include/grpc++/test/server_context_test_spouse.h
+++ b/include/grpc++/test/server_context_test_spouse.h
@@ -48,10 +48,23 @@ class ServerContextTestSpouse {
// Inject client metadata to the ServerContext for the test. The test spouse
// must be alive when ServerContext::client_metadata is called.
- void AddClientMetadata(const grpc::string& key, const grpc::string& value);
+ void AddClientMetadata(const grpc::string& key, const grpc::string& value) {
+ client_metadata_storage_.insert(
+ std::pair<grpc::string, grpc::string>(key, value));
+ ctx_->client_metadata_.map()->clear();
+ for (auto iter = client_metadata_storage_.begin();
+ iter != client_metadata_storage_.end(); ++iter) {
+ ctx_->client_metadata_.map()->insert(
+ std::pair<grpc::string_ref, grpc::string_ref>(
+ iter->first.c_str(),
+ grpc::string_ref(iter->second.data(), iter->second.size())));
+ }
+ }
+
std::multimap<grpc::string, grpc::string> GetInitialMetadata() const {
return ctx_->initial_metadata_;
}
+
std::multimap<grpc::string, grpc::string> GetTrailingMetadata() const {
return ctx_->trailing_metadata_;
}