aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD3
-rw-r--r--build.yaml1
-rw-r--r--gRPC.podspec2
-rw-r--r--src/core/channel/compress_filter.c2
-rw-r--r--src/core/surface/call.c26
-rw-r--r--src/core/surface/call.h11
-rw-r--r--src/core/surface/call_test_only.h65
-rw-r--r--test/core/end2end/tests/compressed_payload.c11
-rw-r--r--test/cpp/interop/client_helper.h6
-rw-r--r--test/cpp/interop/server_helper.cc6
-rw-r--r--tools/doxygen/Doxyfile.core.internal1
-rw-r--r--tools/run_tests/sources_and_headers.json4
-rw-r--r--vsprojects/vcxproj/grpc/grpc.vcxproj1
-rw-r--r--vsprojects/vcxproj/grpc/grpc.vcxproj.filters3
-rw-r--r--vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj1
-rw-r--r--vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters3
16 files changed, 116 insertions, 30 deletions
diff --git a/BUILD b/BUILD
index 3e2a45b8a0..ffeb31e424 100644
--- a/BUILD
+++ b/BUILD
@@ -223,6 +223,7 @@ cc_library(
"src/core/surface/api_trace.h",
"src/core/surface/byte_buffer_queue.h",
"src/core/surface/call.h",
+ "src/core/surface/call_test_only.h",
"src/core/surface/channel.h",
"src/core/surface/completion_queue.h",
"src/core/surface/event_string.h",
@@ -509,6 +510,7 @@ cc_library(
"src/core/surface/api_trace.h",
"src/core/surface/byte_buffer_queue.h",
"src/core/surface/call.h",
+ "src/core/surface/call_test_only.h",
"src/core/surface/channel.h",
"src/core/surface/completion_queue.h",
"src/core/surface/event_string.h",
@@ -1296,6 +1298,7 @@ objc_library(
"src/core/surface/api_trace.h",
"src/core/surface/byte_buffer_queue.h",
"src/core/surface/call.h",
+ "src/core/surface/call_test_only.h",
"src/core/surface/channel.h",
"src/core/surface/completion_queue.h",
"src/core/surface/event_string.h",
diff --git a/build.yaml b/build.yaml
index 98fb0348ca..e277b60b77 100644
--- a/build.yaml
+++ b/build.yaml
@@ -183,6 +183,7 @@ filegroups:
- src/core/surface/api_trace.h
- src/core/surface/byte_buffer_queue.h
- src/core/surface/call.h
+ - src/core/surface/call_test_only.h
- src/core/surface/channel.h
- src/core/surface/completion_queue.h
- src/core/surface/event_string.h
diff --git a/gRPC.podspec b/gRPC.podspec
index 717e7005ee..6378cf0413 100644
--- a/gRPC.podspec
+++ b/gRPC.podspec
@@ -227,6 +227,7 @@ Pod::Spec.new do |s|
'src/core/surface/api_trace.h',
'src/core/surface/byte_buffer_queue.h',
'src/core/surface/call.h',
+ 'src/core/surface/call_test_only.h',
'src/core/surface/channel.h',
'src/core/surface/completion_queue.h',
'src/core/surface/event_string.h',
@@ -518,6 +519,7 @@ Pod::Spec.new do |s|
'src/core/surface/api_trace.h',
'src/core/surface/byte_buffer_queue.h',
'src/core/surface/call.h',
+ 'src/core/surface/call_test_only.h',
'src/core/surface/channel.h',
'src/core/surface/completion_queue.h',
'src/core/surface/event_string.h',
diff --git a/src/core/channel/compress_filter.c b/src/core/channel/compress_filter.c
index 182fbf18bf..c32f150715 100644
--- a/src/core/channel/compress_filter.c
+++ b/src/core/channel/compress_filter.c
@@ -242,7 +242,7 @@ static void process_send_ops(grpc_call_element *elem,
GPR_ASSERT(calld->remaining_slice_bytes > 0);
/* Increase input ref count, gpr_slice_buffer_add takes ownership. */
gpr_slice_buffer_add(&calld->slices, gpr_slice_ref(sop->data.slice));
- GPR_ASSERT(GPR_SLICE_LENGTH(sop->data.slice) >=
+ GPR_ASSERT(GPR_SLICE_LENGTH(sop->data.slice) <=
calld->remaining_slice_bytes);
calld->remaining_slice_bytes -=
(gpr_uint32)GPR_SLICE_LENGTH(sop->data.slice);
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 8a7a772821..022ca191cd 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -527,9 +527,13 @@ static void set_compression_algorithm(grpc_call *call,
call->compression_algorithm = algo;
}
-grpc_compression_algorithm grpc_call_get_compression_algorithm(
- const grpc_call *call) {
- return call->compression_algorithm;
+grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
+ grpc_call *call) {
+ grpc_compression_algorithm algorithm;
+ gpr_mu_lock(&call->mu);
+ algorithm = call->compression_algorithm;
+ gpr_mu_unlock(&call->mu);
+ return algorithm;
}
static void set_encodings_accepted_by_peer(
@@ -563,12 +567,20 @@ static void set_encodings_accepted_by_peer(
}
}
-gpr_uint32 grpc_call_get_encodings_accepted_by_peer(grpc_call *call) {
- return call->encodings_accepted_by_peer;
+gpr_uint32 grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call) {
+ gpr_uint32 encodings_accepted_by_peer;
+ gpr_mu_lock(&call->mu);
+ encodings_accepted_by_peer = call->encodings_accepted_by_peer;
+ gpr_mu_unlock(&call->mu);
+ return encodings_accepted_by_peer;
}
-gpr_uint32 grpc_call_get_message_flags(const grpc_call *call) {
- return call->incoming_message_flags;
+gpr_uint32 grpc_call_test_only_get_message_flags(grpc_call *call) {
+ gpr_uint32 flags;
+ gpr_mu_lock(&call->mu);
+ flags = call->incoming_message_flags;
+ gpr_mu_unlock(&call->mu);
+ return flags;
}
static void set_status_details(grpc_call *call, status_source source,
diff --git a/src/core/surface/call.h b/src/core/surface/call.h
index f421a81619..9b7c6f9bfb 100644
--- a/src/core/surface/call.h
+++ b/src/core/surface/call.h
@@ -169,17 +169,6 @@ void *grpc_call_context_get(grpc_call *call, grpc_context_index elem);
gpr_uint8 grpc_call_is_client(grpc_call *call);
-grpc_compression_algorithm grpc_call_get_compression_algorithm(
- const grpc_call *call);
-
-gpr_uint32 grpc_call_get_message_flags(const grpc_call *call);
-
-/** Returns a bitset for the encodings (compression algorithms) supported by \a
- * call's peer.
- *
- * To be indexed by grpc_compression_algorithm enum values. */
-gpr_uint32 grpc_call_get_encodings_accepted_by_peer(grpc_call *call);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/core/surface/call_test_only.h b/src/core/surface/call_test_only.h
new file mode 100644
index 0000000000..df4be3248b
--- /dev/null
+++ b/src/core/surface/call_test_only.h
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_INTERNAL_CORE_SURFACE_CALL_TEST_ONLY_H
+#define GRPC_INTERNAL_CORE_SURFACE_CALL_TEST_ONLY_H
+
+#include <grpc/grpc.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Return the compression algorithm from \a call.
+ *
+ * \warning This function should \b only be used in test code. */
+grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
+ grpc_call *call);
+
+/** Return the message flags from \a call.
+ *
+ * \warning This function should \b only be used in test code. */
+gpr_uint32 grpc_call_test_only_get_message_flags(grpc_call *call);
+
+/** Returns a bitset for the encodings (compression algorithms) supported by \a
+ * call's peer.
+ *
+ * To be indexed by grpc_compression_algorithm enum values. */
+gpr_uint32 grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_TEST_ONLY_H */
diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c
index a4614a2aba..f321fe1e7c 100644
--- a/test/core/end2end/tests/compressed_payload.c
+++ b/test/core/end2end/tests/compressed_payload.c
@@ -46,7 +46,7 @@
#include "test/core/end2end/cq_verifier.h"
#include "src/core/channel/channel_args.h"
#include "src/core/channel/compress_filter.h"
-#include "src/core/surface/call.h"
+#include "src/core/surface/call_test_only.h"
enum { TIMEOUT = 200000 };
@@ -196,12 +196,13 @@ static void request_with_payload_template(
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
- GPR_ASSERT(GPR_BITCOUNT(grpc_call_get_encodings_accepted_by_peer(s)) == 3);
- GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s),
+ GPR_ASSERT(
+ GPR_BITCOUNT(grpc_call_test_only_get_encodings_accepted_by_peer(s)) == 3);
+ GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
GRPC_COMPRESS_NONE) != 0);
- GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s),
+ GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
GRPC_COMPRESS_DEFLATE) != 0);
- GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s),
+ GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
GRPC_COMPRESS_GZIP) != 0);
op = ops;
diff --git a/test/cpp/interop/client_helper.h b/test/cpp/interop/client_helper.h
index 0221df93db..ace193042e 100644
--- a/test/cpp/interop/client_helper.h
+++ b/test/cpp/interop/client_helper.h
@@ -38,7 +38,7 @@
#include <grpc++/channel.h>
-#include "src/core/surface/call.h"
+#include "src/core/surface/call_test_only.h"
namespace grpc {
namespace testing {
@@ -57,11 +57,11 @@ class InteropClientContextInspector {
// Inspector methods, able to peek inside ClientContext, follow.
grpc_compression_algorithm GetCallCompressionAlgorithm() const {
- return grpc_call_get_compression_algorithm(context_.call_);
+ return grpc_call_test_only_get_compression_algorithm(context_.call_);
}
gpr_uint32 GetMessageFlags() const {
- return grpc_call_get_message_flags(context_.call_);
+ return grpc_call_test_only_get_message_flags(context_.call_);
}
private:
diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc
index 4570750846..5138a38170 100644
--- a/test/cpp/interop/server_helper.cc
+++ b/test/cpp/interop/server_helper.cc
@@ -38,7 +38,7 @@
#include <gflags/gflags.h>
#include <grpc++/security/server_credentials.h>
-#include "src/core/surface/call.h"
+#include "src/core/surface/call_test_only.h"
#include "test/core/end2end/data/ssl_test_data.h"
DECLARE_bool(use_tls);
@@ -65,11 +65,11 @@ InteropServerContextInspector::InteropServerContextInspector(
grpc_compression_algorithm
InteropServerContextInspector::GetCallCompressionAlgorithm() const {
- return grpc_call_get_compression_algorithm(context_.call_);
+ return grpc_call_test_only_get_compression_algorithm(context_.call_);
}
gpr_uint32 InteropServerContextInspector::GetEncodingsAcceptedByClient() const {
- return grpc_call_get_encodings_accepted_by_peer(context_.call_);
+ return grpc_call_test_only_get_encodings_accepted_by_peer(context_.call_);
}
std::shared_ptr<const AuthContext>
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index 5658a102d7..5fd3ee70d6 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -858,6 +858,7 @@ src/core/statistics/census_rpc_stats.h \
src/core/surface/api_trace.h \
src/core/surface/byte_buffer_queue.h \
src/core/surface/call.h \
+src/core/surface/call_test_only.h \
src/core/surface/channel.h \
src/core/surface/completion_queue.h \
src/core/surface/event_string.h \
diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json
index 1ceff15a3b..76d66ed7a0 100644
--- a/tools/run_tests/sources_and_headers.json
+++ b/tools/run_tests/sources_and_headers.json
@@ -12365,6 +12365,7 @@
"src/core/surface/api_trace.h",
"src/core/surface/byte_buffer_queue.h",
"src/core/surface/call.h",
+ "src/core/surface/call_test_only.h",
"src/core/surface/channel.h",
"src/core/surface/completion_queue.h",
"src/core/surface/event_string.h",
@@ -12607,6 +12608,7 @@
"src/core/surface/call.h",
"src/core/surface/call_details.c",
"src/core/surface/call_log_batch.c",
+ "src/core/surface/call_test_only.h",
"src/core/surface/channel.c",
"src/core/surface/channel.h",
"src/core/surface/channel_connectivity.c",
@@ -12861,6 +12863,7 @@
"src/core/surface/api_trace.h",
"src/core/surface/byte_buffer_queue.h",
"src/core/surface/call.h",
+ "src/core/surface/call_test_only.h",
"src/core/surface/channel.h",
"src/core/surface/completion_queue.h",
"src/core/surface/event_string.h",
@@ -13073,6 +13076,7 @@
"src/core/surface/call.h",
"src/core/surface/call_details.c",
"src/core/surface/call_log_batch.c",
+ "src/core/surface/call_test_only.h",
"src/core/surface/channel.c",
"src/core/surface/channel.h",
"src/core/surface/channel_connectivity.c",
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj
index 183edbc05b..88b883f67c 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj
@@ -344,6 +344,7 @@
<ClInclude Include="..\..\..\src\core\surface\api_trace.h" />
<ClInclude Include="..\..\..\src\core\surface\byte_buffer_queue.h" />
<ClInclude Include="..\..\..\src\core\surface\call.h" />
+ <ClInclude Include="..\..\..\src\core\surface\call_test_only.h" />
<ClInclude Include="..\..\..\src\core\surface\channel.h" />
<ClInclude Include="..\..\..\src\core\surface\completion_queue.h" />
<ClInclude Include="..\..\..\src\core\surface\event_string.h" />
diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
index 66ce9ca05b..1a46ac8e34 100644
--- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters
@@ -743,6 +743,9 @@
<ClInclude Include="..\..\..\src\core\surface\call.h">
<Filter>src\core\surface</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\src\core\surface\call_test_only.h">
+ <Filter>src\core\surface</Filter>
+ </ClInclude>
<ClInclude Include="..\..\..\src\core\surface\channel.h">
<Filter>src\core\surface</Filter>
</ClInclude>
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
index b527179f9f..cddd00374b 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
@@ -323,6 +323,7 @@
<ClInclude Include="..\..\..\src\core\surface\api_trace.h" />
<ClInclude Include="..\..\..\src\core\surface\byte_buffer_queue.h" />
<ClInclude Include="..\..\..\src\core\surface\call.h" />
+ <ClInclude Include="..\..\..\src\core\surface\call_test_only.h" />
<ClInclude Include="..\..\..\src\core\surface\channel.h" />
<ClInclude Include="..\..\..\src\core\surface\completion_queue.h" />
<ClInclude Include="..\..\..\src\core\surface\event_string.h" />
diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
index 7be3c9ec93..01e0d8dadd 100644
--- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters
@@ -641,6 +641,9 @@
<ClInclude Include="..\..\..\src\core\surface\call.h">
<Filter>src\core\surface</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\src\core\surface\call_test_only.h">
+ <Filter>src\core\surface</Filter>
+ </ClInclude>
<ClInclude Include="..\..\..\src\core\surface\channel.h">
<Filter>src\core\surface</Filter>
</ClInclude>