From a21ab2ba29bd5f84c861476871cf811131449ec8 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Thu, 1 Feb 2018 16:24:00 -0800 Subject: [PATCH] Fix compression algorithm accessors --- include/grpc++/impl/codegen/client_context.h | 4 +++- include/grpc++/impl/codegen/server_context.h | 5 ++++- src/cpp/client/client_context.cc | 1 + src/cpp/server/server_context.cc | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h index 61d97ce8180..ff6b107452d 100644 --- a/include/grpc++/impl/codegen/client_context.h +++ b/include/grpc++/impl/codegen/client_context.h @@ -289,7 +289,9 @@ class ClientContext { creds_ = creds; } - /// Return the compression algorithm to be used by the client call. + /// Return the compression algorithm the client call will request be used. + /// Note that the gRPC runtime may decide to ignore this request, for example, + /// due to resource constraints. grpc_compression_algorithm compression_algorithm() const { return compression_algorithm_; } diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index a2d6967bf84..c36975860ef 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -185,7 +185,10 @@ class ServerContext { /// \a set_compression_level. bool compression_level_set() const { return compression_level_set_; } - /// Return the compression algorithm to be used by the server call. + /// Return the compression algorithm the server call will request be used. + /// Note that the gRPC runtime may decide to ignore this request, for example, + /// due to resource constraints, or if the server is aware the client doesn't + /// support the requested algorithm. grpc_compression_algorithm compression_algorithm() const { return compression_algorithm_; } diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index dafa8081e99..5c908384407 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -96,6 +96,7 @@ void ClientContext::set_call(grpc_call* call, void ClientContext::set_compression_algorithm( grpc_compression_algorithm algorithm) { + compression_algorithm_ = algorithm; const char* algorithm_name = nullptr; if (!grpc_compression_algorithm_name(algorithm, &algorithm_name)) { gpr_log(GPR_ERROR, "Name for compression algorithm '%d' unknown.", diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index f0cbbdb86dd..878be1c4b67 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -190,6 +190,7 @@ bool ServerContext::IsCancelled() const { void ServerContext::set_compression_algorithm( grpc_compression_algorithm algorithm) { + compression_algorithm_ = algorithm; const char* algorithm_name = nullptr; if (!grpc_compression_algorithm_name(algorithm, &algorithm_name)) { gpr_log(GPR_ERROR, "Name for compression algorithm '%d' unknown.",