From e46de3d416efd6d2f6f69bb3c3803ebaac20bc01 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 17 Nov 2016 15:20:02 -0800 Subject: [PATCH 1/2] Expose message limit constants so that users can reference them --- include/grpc/impl/codegen/grpc_types.h | 4 ++++ src/core/lib/channel/message_size_filter.c | 17 +++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 9a862247952..750d9b806e9 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -261,6 +261,10 @@ typedef enum grpc_call_error { GRPC_CALL_ERROR_PAYLOAD_TYPE_MISMATCH } grpc_call_error; +/* Default send/receive message size limits in bytes. -1 for unlimited. */ +#define GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH -1 +#define GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH (4 * 1024 * 1024) + /* Write Flags: */ /** Hint that the write may be buffered and need not go out on the wire immediately. GRPC is free to buffer the message until the next non-buffered diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index 28ad587c0e4..1cf68d790d8 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -42,10 +43,6 @@ #include "src/core/lib/support/string.h" #include "src/core/lib/transport/service_config.h" -#define DEFAULT_MAX_SEND_MESSAGE_LENGTH -1 // Unlimited. -// The protobuf library will (by default) start warning at 100 megs. -#define DEFAULT_MAX_RECV_MESSAGE_LENGTH (4 * 1024 * 1024) - typedef struct message_size_limits { int max_send_size; int max_recv_size; @@ -201,20 +198,20 @@ static void init_channel_elem(grpc_exec_ctx* exec_ctx, GPR_ASSERT(!args->is_last); channel_data* chand = elem->channel_data; memset(chand, 0, sizeof(*chand)); - chand->max_send_size = DEFAULT_MAX_SEND_MESSAGE_LENGTH; - chand->max_recv_size = DEFAULT_MAX_RECV_MESSAGE_LENGTH; + chand->max_send_size = GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH; + chand->max_recv_size = GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH; for (size_t i = 0; i < args->channel_args->num_args; ++i) { if (strcmp(args->channel_args->args[i].key, GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) == 0) { - const grpc_integer_options options = {DEFAULT_MAX_SEND_MESSAGE_LENGTH, 0, - INT_MAX}; + const grpc_integer_options options = { + GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH, 0, INT_MAX}; chand->max_send_size = grpc_channel_arg_get_integer(&args->channel_args->args[i], options); } if (strcmp(args->channel_args->args[i].key, GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH) == 0) { - const grpc_integer_options options = {DEFAULT_MAX_RECV_MESSAGE_LENGTH, 0, - INT_MAX}; + const grpc_integer_options options = { + GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH, 0, INT_MAX}; chand->max_recv_size = grpc_channel_arg_get_integer(&args->channel_args->args[i], options); } From 8706c6ec5d9beb09f2bb2f64e8e600e8cc8f9f6f Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 18 Nov 2016 10:41:30 -0800 Subject: [PATCH 2/2] add todo --- include/grpc/impl/codegen/grpc_types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 750d9b806e9..da1bd9dcbf0 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -262,6 +262,7 @@ typedef enum grpc_call_error { } grpc_call_error; /* Default send/receive message size limits in bytes. -1 for unlimited. */ +/* TODO(roth) Make this match the default receive limit after next release */ #define GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH -1 #define GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH (4 * 1024 * 1024)