aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++/impl
diff options
context:
space:
mode:
Diffstat (limited to 'include/grpc++/impl')
-rw-r--r--include/grpc++/impl/codegen/fc_unary.h10
-rw-r--r--include/grpc++/impl/codegen/method_handler_impl.h3
-rw-r--r--include/grpc++/impl/codegen/sync_stream.h11
3 files changed, 17 insertions, 7 deletions
diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h
index c5e44ca0fd..abbdd42c78 100644
--- a/include/grpc++/impl/codegen/fc_unary.h
+++ b/include/grpc++/impl/codegen/fc_unary.h
@@ -45,16 +45,17 @@ namespace grpc {
/// of a hybrid between conventional unary and streaming. This is invoked
/// through a unary call on the client side, but the server responds to it
/// as though it were a single-ping-pong streaming call. The server can use
-/// the \a Size method to determine an upper-bound on the size of the message
+/// the \a NextMessageSize method to determine an upper-bound on the size of
+/// the message.
/// A key difference relative to streaming: an FCUnary must have exactly 1 Read
/// and exactly 1 Write, in that order, to function correctly.
-/// Otherwise, the RPC is in error
+/// Otherwise, the RPC is in error.
template <class RequestType, class ResponseType>
class FCUnary GRPC_FINAL {
public:
- FCUnary(Call* call, ServerContext* ctx, int max_message_size): call_(call), ctx_(ctx), max_msg_size_(max_message_size), read_done_(false), write_done_(false) {}
+ FCUnary(Call* call, ServerContext* ctx): call_(call), ctx_(ctx), read_done_(false), write_done_(false) {}
~FCUnary() {}
- uint32_t Size() {return max_msg_size_;}
+ uint32_t NextMessageSize() {return call_->max_message_size();}
bool Read(RequestType *request) {
if (read_done_) {
return false;
@@ -88,7 +89,6 @@ template <class RequestType, class ResponseType>
private:
Call* const call_;
ServerContext* const ctx_;
- const int max_msg_size_;
bool read_done_;
bool write_done_;
};
diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h
index ecf481ebb6..2a14ef3977 100644
--- a/include/grpc++/impl/codegen/method_handler_impl.h
+++ b/include/grpc++/impl/codegen/method_handler_impl.h
@@ -204,8 +204,7 @@ class FCUnaryMethodHandler : public MethodHandler {
void RunHandler(const HandlerParameter& param) GRPC_FINAL {
FCUnary<RequestType, ResponseType> fc_unary(param.call,
- param.server_context,
- param.max_message_size);
+ param.server_context);
Status status = func_(service_, param.server_context, &fc_unary);
if (!param.server_context->sent_initial_metadata_) {
// means that the write never happened, which is bad
diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h
index e94ffe5842..eb76edd140 100644
--- a/include/grpc++/impl/codegen/sync_stream.h
+++ b/include/grpc++/impl/codegen/sync_stream.h
@@ -70,6 +70,9 @@ class ReaderInterface {
public:
virtual ~ReaderInterface() {}
+ /// Upper bound on the next message size available for reading on this stream
+ virtual uint32_t NextMessageSize() = 0;
+
/// Blocking read a message and parse to \a msg. Returns \a true on success.
///
/// \param[out] msg The read message.
@@ -143,6 +146,8 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface<R> {
cq_.Pluck(&ops); /// status ignored
}
+ uint32_t NextMessageSize() GRPC_OVERRIDE {return call_.max_message_size();}
+
bool Read(R* msg) GRPC_OVERRIDE {
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> ops;
if (!context_->initial_metadata_received_) {
@@ -286,6 +291,8 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface<W, R> {
cq_.Pluck(&ops); // status ignored
}
+ uint32_t NextMessageSize() GRPC_OVERRIDE {return call_.max_message_size();}
+
bool Read(R* msg) GRPC_OVERRIDE {
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> ops;
if (!context_->initial_metadata_received_) {
@@ -345,6 +352,8 @@ class ServerReader GRPC_FINAL : public ReaderInterface<R> {
call_->cq()->Pluck(&ops);
}
+ uint32_t NextMessageSize() GRPC_OVERRIDE {return call_->max_message_size();}
+
bool Read(R* msg) GRPC_OVERRIDE {
CallOpSet<CallOpRecvMessage<R>> ops;
ops.RecvMessage(msg);
@@ -411,6 +420,8 @@ class ServerReaderWriter GRPC_FINAL : public WriterInterface<W>,
call_->cq()->Pluck(&ops);
}
+ uint32_t NextMessageSize() GRPC_OVERRIDE {return call_->max_message_size();}
+
bool Read(R* msg) GRPC_OVERRIDE {
CallOpSet<CallOpRecvMessage<R>> ops;
ops.RecvMessage(msg);