aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/census/aggregation.h8
-rw-r--r--src/core/census/grpc_filter.h8
-rw-r--r--src/core/census/grpc_plugin.c72
-rw-r--r--src/core/census/grpc_plugin.h (renamed from src/core/surface/server_create.c)20
-rw-r--r--src/core/census/mlog.h6
-rw-r--r--src/core/census/rpc_metric_id.h8
-rw-r--r--src/core/channel/channel_args.h6
-rw-r--r--src/core/channel/channel_stack.h8
-rw-r--r--src/core/channel/channel_stack_builder.c259
-rw-r--r--src/core/channel/channel_stack_builder.h155
-rw-r--r--src/core/channel/client_channel.h8
-rw-r--r--src/core/channel/client_uchannel.c12
-rw-r--r--src/core/channel/client_uchannel.h8
-rw-r--r--src/core/channel/compress_filter.h8
-rw-r--r--src/core/channel/connected_channel.c31
-rw-r--r--src/core/channel/connected_channel.h23
-rw-r--r--src/core/channel/context.h8
-rw-r--r--src/core/channel/http_client_filter.h8
-rw-r--r--src/core/channel/http_server_filter.h8
-rw-r--r--src/core/channel/subchannel_call_holder.h8
-rw-r--r--src/core/client_config/client_config.h8
-rw-r--r--src/core/client_config/connector.h9
-rw-r--r--src/core/client_config/initial_connect_string.h8
-rw-r--r--src/core/client_config/lb_policies/load_balancer_api.h6
-rw-r--r--src/core/client_config/lb_policies/pick_first.h8
-rw-r--r--src/core/client_config/lb_policies/round_robin.h8
-rw-r--r--src/core/client_config/lb_policy.h6
-rw-r--r--src/core/client_config/lb_policy_factory.h8
-rw-r--r--src/core/client_config/lb_policy_registry.h8
-rw-r--r--src/core/client_config/resolver.h8
-rw-r--r--src/core/client_config/resolver_factory.h8
-rw-r--r--src/core/client_config/resolver_registry.h8
-rw-r--r--src/core/client_config/resolvers/dns_resolver.h8
-rw-r--r--src/core/client_config/resolvers/sockaddr_resolver.h8
-rw-r--r--src/core/client_config/resolvers/zookeeper_resolver.h8
-rw-r--r--src/core/client_config/subchannel.c28
-rw-r--r--src/core/client_config/subchannel.h6
-rw-r--r--src/core/client_config/subchannel_factory.h8
-rw-r--r--src/core/client_config/subchannel_index.c1
-rw-r--r--src/core/client_config/subchannel_index.h6
-rw-r--r--src/core/client_config/uri_parser.h8
-rw-r--r--src/core/compression/algorithm_metadata.h8
-rw-r--r--src/core/compression/compression_algorithm.c47
-rw-r--r--src/core/compression/message_compress.h8
-rw-r--r--src/core/debug/trace.h8
-rw-r--r--src/core/httpcli/format_request.h8
-rw-r--r--src/core/httpcli/httpcli.h6
-rw-r--r--src/core/httpcli/parser.h8
-rw-r--r--src/core/iomgr/closure.h6
-rw-r--r--src/core/iomgr/endpoint.h8
-rw-r--r--src/core/iomgr/endpoint_pair.h8
-rw-r--r--src/core/iomgr/exec_ctx.h6
-rw-r--r--src/core/iomgr/executor.h6
-rw-r--r--src/core/iomgr/fd_posix.c9
-rw-r--r--src/core/iomgr/fd_posix.h6
-rw-r--r--src/core/iomgr/iocp_windows.h6
-rw-r--r--src/core/iomgr/iomgr.h8
-rw-r--r--src/core/iomgr/iomgr_internal.h6
-rw-r--r--src/core/iomgr/iomgr_posix.h8
-rw-r--r--src/core/iomgr/pollset.h6
-rw-r--r--src/core/iomgr/pollset_posix.h6
-rw-r--r--src/core/iomgr/pollset_set.h6
-rw-r--r--src/core/iomgr/pollset_set_posix.h6
-rw-r--r--src/core/iomgr/pollset_set_windows.h6
-rw-r--r--src/core/iomgr/pollset_windows.h6
-rw-r--r--src/core/iomgr/resolve_address.h6
-rw-r--r--src/core/iomgr/sockaddr.h8
-rw-r--r--src/core/iomgr/sockaddr_posix.h8
-rw-r--r--src/core/iomgr/sockaddr_utils.h8
-rw-r--r--src/core/iomgr/sockaddr_win32.h6
-rw-r--r--src/core/iomgr/socket_utils_posix.h8
-rw-r--r--src/core/iomgr/socket_windows.h8
-rw-r--r--src/core/iomgr/tcp_client.h8
-rw-r--r--src/core/iomgr/tcp_posix.h6
-rw-r--r--src/core/iomgr/tcp_server.h6
-rw-r--r--src/core/iomgr/tcp_windows.h8
-rw-r--r--src/core/iomgr/time_averaged_stats.h8
-rw-r--r--src/core/iomgr/timer.h6
-rw-r--r--src/core/iomgr/timer_heap.h8
-rw-r--r--src/core/iomgr/udp_server.h6
-rw-r--r--src/core/iomgr/wakeup_fd_pipe.h8
-rw-r--r--src/core/iomgr/wakeup_fd_posix.h8
-rw-r--r--src/core/iomgr/workqueue.h6
-rw-r--r--src/core/iomgr/workqueue_posix.h6
-rw-r--r--src/core/iomgr/workqueue_windows.h8
-rw-r--r--src/core/json/json.h8
-rw-r--r--src/core/json/json_common.h8
-rw-r--r--src/core/json/json_reader.h8
-rw-r--r--src/core/json/json_writer.h8
-rw-r--r--src/core/security/auth_filters.h8
-rw-r--r--src/core/security/b64.h6
-rw-r--r--src/core/security/credentials.h6
-rw-r--r--src/core/security/handshake.h6
-rw-r--r--src/core/security/json_token.h8
-rw-r--r--src/core/security/jwt_verifier.h8
-rw-r--r--src/core/security/secure_endpoint.h8
-rw-r--r--src/core/security/security_connector.c16
-rw-r--r--src/core/security/security_connector.h6
-rw-r--r--src/core/security/security_context.h8
-rw-r--r--src/core/security/server_secure_chttp2.c5
-rw-r--r--src/core/statistics/census_interface.h8
-rw-r--r--src/core/statistics/census_log.h8
-rw-r--r--src/core/statistics/census_rpc_stats.h8
-rw-r--r--src/core/statistics/census_tracing.h8
-rw-r--r--src/core/statistics/hash_table.h8
-rw-r--r--src/core/statistics/window_stats.h8
-rw-r--r--src/core/support/backoff.h6
-rw-r--r--src/core/support/block_annotate.h8
-rw-r--r--src/core/support/env.h8
-rw-r--r--src/core/support/load_file.h6
-rw-r--r--src/core/support/murmur_hash.h8
-rw-r--r--src/core/support/stack_lockfree.h8
-rw-r--r--src/core/support/string.h8
-rw-r--r--src/core/support/string_win32.h8
-rw-r--r--src/core/support/thd_internal.h8
-rw-r--r--src/core/support/time_precise.h8
-rw-r--r--src/core/support/tmpfile.h6
-rw-r--r--src/core/surface/api_trace.h8
-rw-r--r--src/core/surface/call.c8
-rw-r--r--src/core/surface/call.h15
-rw-r--r--src/core/surface/call_test_only.h8
-rw-r--r--src/core/surface/channel.c27
-rw-r--r--src/core/surface/channel.h17
-rw-r--r--src/core/surface/channel_create.c14
-rw-r--r--src/core/surface/channel_init.c148
-rw-r--r--src/core/surface/channel_init.h86
-rw-r--r--src/core/surface/channel_stack_type.c56
-rw-r--r--src/core/surface/channel_stack_type.h61
-rw-r--r--src/core/surface/completion_queue.h8
-rw-r--r--src/core/surface/event_string.h8
-rw-r--r--src/core/surface/init.c90
-rw-r--r--src/core/surface/init.h9
-rw-r--r--src/core/surface/init_secure.c49
-rw-r--r--src/core/surface/init_unsecure.c4
-rw-r--r--src/core/surface/lame_client.c14
-rw-r--r--src/core/surface/lame_client.h41
-rw-r--r--src/core/surface/secure_channel_create.c20
-rw-r--r--src/core/surface/server.c52
-rw-r--r--src/core/surface/server.h17
-rw-r--r--src/core/surface/server_chttp2.c5
-rw-r--r--src/core/surface/surface_trace.h8
-rw-r--r--src/core/transport/byte_stream.h8
-rw-r--r--src/core/transport/chttp2/alpn.h8
-rw-r--r--src/core/transport/chttp2/bin_encoder.h6
-rw-r--r--src/core/transport/chttp2/frame.h8
-rw-r--r--src/core/transport/chttp2/frame_data.h8
-rw-r--r--src/core/transport/chttp2/frame_goaway.h8
-rw-r--r--src/core/transport/chttp2/frame_ping.h8
-rw-r--r--src/core/transport/chttp2/frame_rst_stream.h8
-rw-r--r--src/core/transport/chttp2/frame_settings.h8
-rw-r--r--src/core/transport/chttp2/frame_window_update.h8
-rw-r--r--src/core/transport/chttp2/hpack_encoder.h8
-rw-r--r--src/core/transport/chttp2/hpack_parser.h8
-rw-r--r--src/core/transport/chttp2/hpack_table.h8
-rw-r--r--src/core/transport/chttp2/http2_errors.h8
-rw-r--r--src/core/transport/chttp2/huffsyms.h8
-rw-r--r--src/core/transport/chttp2/incoming_metadata.h8
-rw-r--r--src/core/transport/chttp2/internal.h6
-rw-r--r--src/core/transport/chttp2/status_conversion.h8
-rw-r--r--src/core/transport/chttp2/stream_map.h8
-rw-r--r--src/core/transport/chttp2/timeout_encoding.h8
-rw-r--r--src/core/transport/chttp2/varint.h8
-rw-r--r--src/core/transport/chttp2_transport.c5
-rw-r--r--src/core/transport/chttp2_transport.h8
-rw-r--r--src/core/transport/connectivity_state.h8
-rw-r--r--src/core/transport/metadata.h6
-rw-r--r--src/core/transport/metadata_batch.h8
-rw-r--r--src/core/transport/static_metadata.h6
-rw-r--r--src/core/transport/transport.h6
-rw-r--r--src/core/transport/transport_impl.h11
-rw-r--r--src/core/tsi/fake_transport_security.h8
-rw-r--r--src/core/tsi/ssl_transport_security.c27
-rw-r--r--src/core/tsi/ssl_transport_security.h8
-rw-r--r--src/core/tsi/ssl_types.h8
-rw-r--r--src/core/tsi/transport_security.h8
-rw-r--r--src/core/tsi/transport_security_interface.h8
-rw-r--r--src/cpp/README.md4
-rw-r--r--src/cpp/client/secure_credentials.cc3
-rw-r--r--src/cpp/server/server_context.cc3
-rw-r--r--src/csharp/Grpc.Core/Internal/NativeExtension.cs23
-rw-r--r--src/csharp/Grpc.Core/Logging/ConsoleLogger.cs8
-rw-r--r--src/csharp/README.md15
-rw-r--r--src/php/ext/grpc/channel.c2
-rw-r--r--src/python/grpcio/README.rst35
-rw-r--r--src/python/grpcio/commands.py12
-rw-r--r--src/python/grpcio/grpc/_adapter/_types.py19
-rw-r--r--src/python/grpcio/grpc/_cython/imports.generated.h2
-rw-r--r--src/python/grpcio/grpc/_links/invocation.py7
-rw-r--r--src/python/grpcio/grpc/beta/interfaces.py22
-rw-r--r--src/python/grpcio/grpc/framework/alpha/_face_utilities.py10
-rw-r--r--src/python/grpcio/grpc/framework/alpha/exceptions.py7
-rw-r--r--src/python/grpcio/grpc/framework/alpha/interfaces.py34
-rw-r--r--src/python/grpcio/grpc/framework/base/_ingestion.py7
-rw-r--r--src/python/grpcio/grpc/framework/base/_interfaces.py25
-rw-r--r--src/python/grpcio/grpc/framework/base/_reception.py7
-rw-r--r--src/python/grpcio/grpc/framework/base/_transmission.py10
-rw-r--r--src/python/grpcio/grpc/framework/base/interfaces.py40
-rw-r--r--src/python/grpcio/grpc/framework/core/_end.py7
-rw-r--r--src/python/grpcio/grpc/framework/core/_ingestion.py7
-rw-r--r--src/python/grpcio/grpc/framework/core/_interfaces.py28
-rw-r--r--src/python/grpcio/grpc/framework/core/_termination.py5
-rw-r--r--src/python/grpcio/grpc/framework/crust/_control.py5
-rw-r--r--src/python/grpcio/grpc/framework/face/_control.py5
-rw-r--r--src/python/grpcio/grpc/framework/face/exceptions.py7
-rw-r--r--src/python/grpcio/grpc/framework/face/interfaces.py40
-rw-r--r--src/python/grpcio/grpc/framework/foundation/activated.py6
-rw-r--r--src/python/grpcio/grpc/framework/foundation/callable_util.py7
-rw-r--r--src/python/grpcio/grpc/framework/foundation/future.py7
-rw-r--r--src/python/grpcio/grpc/framework/foundation/relay.py3
-rw-r--r--src/python/grpcio/grpc/framework/foundation/stream.py6
-rw-r--r--src/python/grpcio/grpc/framework/foundation/stream_util.py5
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/base/base.py25
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/face/face.py41
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/links/links.py7
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py5
-rw-r--r--src/python/grpcio/tests/_runner.py91
-rw-r--r--src/python/grpcio/tests/interop/methods.py5
-rw-r--r--src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py7
-rw-r--r--src/python/grpcio/tests/unit/_links/_proto_scenarios.py7
-rw-r--r--src/python/grpcio/tests/unit/beta/_beta_features_test.py5
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_control.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/common/test_coverage.py7
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/base_util.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/control.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/coverage.py12
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py11
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/interfaces.py7
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/service.py40
-rw-r--r--src/python/grpcio/tests/unit/framework/face/testing/test_case.py7
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/_control.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py5
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py8
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/_service.py40
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py10
-rw-r--r--src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py7
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.h2
240 files changed, 2152 insertions, 1205 deletions
diff --git a/src/core/census/aggregation.h b/src/core/census/aggregation.h
index e9bc6ada96..e0ef9630c9 100644
--- a/src/core/census/aggregation.h
+++ b/src/core/census/aggregation.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,8 +33,8 @@
#include <stddef.h>
-#ifndef GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H
-#define GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H
+#ifndef GRPC_CORE_CENSUS_AGGREGATION_H
+#define GRPC_CORE_CENSUS_AGGREGATION_H
/** Structure used to describe an aggregation type. */
struct census_aggregation_ops {
@@ -63,4 +63,4 @@ struct census_aggregation_ops {
size_t (*print)(const void *aggregation, char *buffer, size_t n);
};
-#endif /* GRPC_INTERNAL_CORE_CENSUS_AGGREGATION_H */
+#endif /* GRPC_CORE_CENSUS_AGGREGATION_H */
diff --git a/src/core/census/grpc_filter.h b/src/core/census/grpc_filter.h
index b3de3adc94..4699e4d692 100644
--- a/src/core/census/grpc_filter.h
+++ b/src/core/census/grpc_filter.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CENSUS_GRPC_FILTER_H
-#define GRPC_INTERNAL_CORE_CENSUS_GRPC_FILTER_H
+#ifndef GRPC_CORE_CENSUS_GRPC_FILTER_H
+#define GRPC_CORE_CENSUS_GRPC_FILTER_H
#include "src/core/channel/channel_stack.h"
@@ -41,4 +41,4 @@
extern const grpc_channel_filter grpc_client_census_filter;
extern const grpc_channel_filter grpc_server_census_filter;
-#endif /* GRPC_INTERNAL_CORE_CENSUS_GRPC_FILTER_H */
+#endif /* GRPC_CORE_CENSUS_GRPC_FILTER_H */
diff --git a/src/core/census/grpc_plugin.c b/src/core/census/grpc_plugin.c
new file mode 100644
index 0000000000..3be2a48eb8
--- /dev/null
+++ b/src/core/census/grpc_plugin.c
@@ -0,0 +1,72 @@
+/*
+ *
+ * Copyright 2015-2016, 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.
+ *
+ */
+
+#include "src/core/census/grpc_plugin.h"
+
+#include <limits.h>
+
+#include <grpc/census.h>
+
+#include "src/core/census/grpc_filter.h"
+#include "src/core/surface/channel_init.h"
+#include "src/core/channel/channel_stack_builder.h"
+
+static bool maybe_add_census_filter(grpc_channel_stack_builder *builder,
+ void *arg_must_be_null) {
+ const grpc_channel_args *args =
+ grpc_channel_stack_builder_get_channel_arguments(builder);
+ if (grpc_channel_args_is_census_enabled(args)) {
+ return grpc_channel_stack_builder_prepend_filter(
+ builder, &grpc_client_census_filter, NULL, NULL);
+ }
+ return true;
+}
+
+void census_grpc_plugin_init(void) {
+ /* Only initialize census if no one else has and some features are
+ * available. */
+ if (census_enabled() == CENSUS_FEATURE_NONE &&
+ census_supported() != CENSUS_FEATURE_NONE) {
+ if (census_initialize(census_supported())) { /* enable all features. */
+ gpr_log(GPR_ERROR, "Could not initialize census.");
+ }
+ }
+ grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
+ maybe_add_census_filter, NULL);
+ grpc_channel_init_register_stage(GRPC_CLIENT_UCHANNEL, INT_MAX,
+ maybe_add_census_filter, NULL);
+ grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
+ maybe_add_census_filter, NULL);
+}
+
+void census_grpc_plugin_destroy(void) { census_shutdown(); }
diff --git a/src/core/surface/server_create.c b/src/core/census/grpc_plugin.h
index 5e37e80948..9321c2c30f 100644
--- a/src/core/surface/server_create.c
+++ b/src/core/census/grpc_plugin.h
@@ -31,18 +31,10 @@
*
*/
-#include <grpc/grpc.h>
-#include "src/core/census/grpc_filter.h"
-#include "src/core/channel/channel_args.h"
-#include "src/core/channel/compress_filter.h"
-#include "src/core/surface/api_trace.h"
-#include "src/core/surface/completion_queue.h"
-#include "src/core/surface/server.h"
+#ifndef GRPC_CORE_CENSUS_GRPC_PLUGIN_H
+#define GRPC_CORE_CENSUS_GRPC_PLUGIN_H
-grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
- const grpc_channel_filter *filters[3];
- size_t num_filters = 0;
- filters[num_filters++] = &grpc_compress_filter;
- GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
- return grpc_server_create_from_filters(filters, num_filters, args);
-}
+void census_grpc_plugin_init(void);
+void census_grpc_plugin_destroy(void);
+
+#endif /* GRPC_CORE_CENSUS_GRPC_PLUGIN_H */
diff --git a/src/core/census/mlog.h b/src/core/census/mlog.h
index aaba9e1535..bc6eaeaf28 100644
--- a/src/core/census/mlog.h
+++ b/src/core/census/mlog.h
@@ -33,8 +33,8 @@
/* A very fast in-memory log, optimized for multiple writers. */
-#ifndef GRPC_INTERNAL_CORE_CENSUS_MLOG_H
-#define GRPC_INTERNAL_CORE_CENSUS_MLOG_H
+#ifndef GRPC_CORE_CENSUS_MLOG_H
+#define GRPC_CORE_CENSUS_MLOG_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
@@ -92,4 +92,4 @@ size_t census_log_remaining_space(void);
out-of-space. */
int64_t census_log_out_of_space_count(void);
-#endif /* GRPC_INTERNAL_CORE_CENSUS_LOG_H */
+#endif /* GRPC_CORE_CENSUS_MLOG_H */
diff --git a/src/core/census/rpc_metric_id.h b/src/core/census/rpc_metric_id.h
index f199839511..f8d8dad0bf 100644
--- a/src/core/census/rpc_metric_id.h
+++ b/src/core/census/rpc_metric_id.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef CENSUS_RPC_METRIC_ID_H
-#define CENSUS_RPC_METRIC_ID_H
+#ifndef GRPC_CORE_CENSUS_RPC_METRIC_ID_H
+#define GRPC_CORE_CENSUS_RPC_METRIC_ID_H
/* Metric ID's used for RPC measurements. */
/* Count of client requests sent. */
@@ -48,4 +48,4 @@
/* Server side request latency. */
#define CENSUS_METRIC_RPC_SERVER_LATENCY ((uint32_t)5)
-#endif /* CENSUS_RPC_METRIC_ID_H */
+#endif /* GRPC_CORE_CENSUS_RPC_METRIC_ID_H */
diff --git a/src/core/channel/channel_args.h b/src/core/channel/channel_args.h
index b3a7c9f434..e19440f76f 100644
--- a/src/core/channel/channel_args.h
+++ b/src/core/channel/channel_args.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H
-#define GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H
+#ifndef GRPC_CORE_CHANNEL_CHANNEL_ARGS_H
+#define GRPC_CORE_CHANNEL_CHANNEL_ARGS_H
#include <grpc/compression.h>
#include <grpc/grpc.h>
@@ -91,4 +91,4 @@ int grpc_channel_args_compression_algorithm_get_states(
int grpc_channel_args_compare(const grpc_channel_args *a,
const grpc_channel_args *b);
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_ARGS_H */
+#endif /* GRPC_CORE_CHANNEL_CHANNEL_ARGS_H */
diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h
index c01050e717..52362f0b20 100644
--- a/src/core/channel/channel_stack.h
+++ b/src/core/channel/channel_stack.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H
-#define GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H
+#ifndef GRPC_CORE_CHANNEL_CHANNEL_STACK_H
+#define GRPC_CORE_CHANNEL_CHANNEL_STACK_H
/* A channel filter defines how operations on a channel are implemented.
Channel filters are chained together to create full channels, and if those
@@ -257,4 +257,4 @@ extern int grpc_trace_channel;
#define GRPC_CALL_LOG_OP(sev, elem, op) \
if (grpc_trace_channel) grpc_call_log_op(sev, elem, op)
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H */
+#endif /* GRPC_CORE_CHANNEL_CHANNEL_STACK_H */
diff --git a/src/core/channel/channel_stack_builder.c b/src/core/channel/channel_stack_builder.c
new file mode 100644
index 0000000000..80e2e393f9
--- /dev/null
+++ b/src/core/channel/channel_stack_builder.c
@@ -0,0 +1,259 @@
+/*
+ *
+ * Copyright 2016, 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.
+ *
+ */
+
+#include "src/core/channel/channel_stack_builder.h"
+
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+
+int grpc_trace_channel_stack_builder = 0;
+
+typedef struct filter_node {
+ struct filter_node *next;
+ struct filter_node *prev;
+ const grpc_channel_filter *filter;
+ grpc_post_filter_create_init_func init;
+ void *init_arg;
+} filter_node;
+
+struct grpc_channel_stack_builder {
+ // sentinel nodes for filters that have been added
+ filter_node begin;
+ filter_node end;
+ // various set/get-able parameters
+ const grpc_channel_args *args;
+ grpc_transport *transport;
+ const char *name;
+};
+
+struct grpc_channel_stack_builder_iterator {
+ grpc_channel_stack_builder *builder;
+ filter_node *node;
+};
+
+grpc_channel_stack_builder *grpc_channel_stack_builder_create(void) {
+ grpc_channel_stack_builder *b = gpr_malloc(sizeof(*b));
+ memset(b, 0, sizeof(*b));
+
+ b->begin.filter = NULL;
+ b->end.filter = NULL;
+ b->begin.next = &b->end;
+ b->begin.prev = &b->end;
+ b->end.next = &b->begin;
+ b->end.prev = &b->begin;
+
+ return b;
+}
+
+static grpc_channel_stack_builder_iterator *create_iterator_at_filter_node(
+ grpc_channel_stack_builder *builder, filter_node *node) {
+ grpc_channel_stack_builder_iterator *it = gpr_malloc(sizeof(*it));
+ it->builder = builder;
+ it->node = node;
+ return it;
+}
+
+void grpc_channel_stack_builder_iterator_destroy(
+ grpc_channel_stack_builder_iterator *it) {
+ gpr_free(it);
+}
+
+grpc_channel_stack_builder_iterator *
+grpc_channel_stack_builder_create_iterator_at_first(
+ grpc_channel_stack_builder *builder) {
+ return create_iterator_at_filter_node(builder, &builder->begin);
+}
+
+grpc_channel_stack_builder_iterator *
+grpc_channel_stack_builder_create_iterator_at_last(
+ grpc_channel_stack_builder *builder) {
+ return create_iterator_at_filter_node(builder, &builder->end);
+}
+
+bool grpc_channel_stack_builder_move_next(
+ grpc_channel_stack_builder_iterator *iterator) {
+ if (iterator->node == &iterator->builder->end) return false;
+ iterator->node = iterator->node->next;
+ return true;
+}
+
+bool grpc_channel_stack_builder_move_prev(
+ grpc_channel_stack_builder_iterator *iterator) {
+ if (iterator->node == &iterator->builder->begin) return false;
+ iterator->node = iterator->node->prev;
+ return true;
+}
+
+bool grpc_channel_stack_builder_move_prev(
+ grpc_channel_stack_builder_iterator *iterator);
+
+void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder *builder,
+ const char *name) {
+ GPR_ASSERT(builder->name == NULL);
+ builder->name = name;
+}
+
+void grpc_channel_stack_builder_set_channel_arguments(
+ grpc_channel_stack_builder *builder, const grpc_channel_args *args) {
+ GPR_ASSERT(builder->args == NULL);
+ builder->args = args;
+}
+
+void grpc_channel_stack_builder_set_transport(
+ grpc_channel_stack_builder *builder, grpc_transport *transport) {
+ GPR_ASSERT(builder->transport == NULL);
+ builder->transport = transport;
+}
+
+grpc_transport *grpc_channel_stack_builder_get_transport(
+ grpc_channel_stack_builder *builder) {
+ return builder->transport;
+}
+
+const grpc_channel_args *grpc_channel_stack_builder_get_channel_arguments(
+ grpc_channel_stack_builder *builder) {
+ return builder->args;
+}
+
+bool grpc_channel_stack_builder_append_filter(
+ grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func, void *user_data) {
+ grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder_create_iterator_at_last(builder);
+ bool ok = grpc_channel_stack_builder_add_filter_before(
+ it, filter, post_init_func, user_data);
+ grpc_channel_stack_builder_iterator_destroy(it);
+ return ok;
+}
+
+bool grpc_channel_stack_builder_prepend_filter(
+ grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func, void *user_data) {
+ grpc_channel_stack_builder_iterator *it =
+ grpc_channel_stack_builder_create_iterator_at_first(builder);
+ bool ok = grpc_channel_stack_builder_add_filter_after(
+ it, filter, post_init_func, user_data);
+ grpc_channel_stack_builder_iterator_destroy(it);
+ return ok;
+}
+
+static void add_after(filter_node *before, const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func,
+ void *user_data) {
+ filter_node *new = gpr_malloc(sizeof(*new));
+ new->next = before->next;
+ new->prev = before;
+ new->next->prev = new->prev->next = new;
+ new->filter = filter;
+ new->init = post_init_func;
+ new->init_arg = user_data;
+}
+
+bool grpc_channel_stack_builder_add_filter_before(
+ grpc_channel_stack_builder_iterator *iterator,
+ const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func, void *user_data) {
+ if (iterator->node == &iterator->builder->begin) return false;
+ add_after(iterator->node->prev, filter, post_init_func, user_data);
+ return true;
+}
+
+bool grpc_channel_stack_builder_add_filter_after(
+ grpc_channel_stack_builder_iterator *iterator,
+ const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func, void *user_data) {
+ if (iterator->node == &iterator->builder->end) return false;
+ add_after(iterator->node, filter, post_init_func, user_data);
+ return true;
+}
+
+void grpc_channel_stack_builder_destroy(grpc_channel_stack_builder *builder) {
+ filter_node *p = builder->begin.next;
+ while (p != &builder->end) {
+ filter_node *next = p->next;
+ gpr_free(p);
+ p = next;
+ }
+ gpr_free(builder);
+}
+
+void *grpc_channel_stack_builder_finish(grpc_exec_ctx *exec_ctx,
+ grpc_channel_stack_builder *builder,
+ size_t prefix_bytes, int initial_refs,
+ grpc_iomgr_cb_func destroy,
+ void *destroy_arg) {
+ // count the number of filters
+ size_t num_filters = 0;
+ for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) {
+ gpr_log(GPR_DEBUG, "%d: %s", num_filters, p->filter->name);
+ num_filters++;
+ }
+
+ // create an array of filters
+ const grpc_channel_filter **filters =
+ gpr_malloc(sizeof(*filters) * num_filters);
+ size_t i = 0;
+ for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) {
+ filters[i++] = p->filter;
+ }
+
+ // calculate the size of the channel stack
+ size_t channel_stack_size = grpc_channel_stack_size(filters, num_filters);
+
+ // allocate memory, with prefix_bytes followed by channel_stack_size
+ char *result = gpr_malloc(prefix_bytes + channel_stack_size);
+ // fetch a pointer to the channel stack
+ grpc_channel_stack *channel_stack =
+ (grpc_channel_stack *)(result + prefix_bytes);
+ // and initialize it
+ grpc_channel_stack_init(exec_ctx, initial_refs, destroy,
+ destroy_arg == NULL ? result : destroy_arg, filters,
+ num_filters, builder->args, builder->name,
+ channel_stack);
+
+ // run post-initialization functions
+ i = 0;
+ for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) {
+ if (p->init != NULL) {
+ p->init(channel_stack, grpc_channel_stack_element(channel_stack, i),
+ p->init_arg);
+ }
+ i++;
+ }
+
+ grpc_channel_stack_builder_destroy(builder);
+ gpr_free((grpc_channel_filter **)filters);
+
+ return result;
+}
diff --git a/src/core/channel/channel_stack_builder.h b/src/core/channel/channel_stack_builder.h
new file mode 100644
index 0000000000..15f395e8b8
--- /dev/null
+++ b/src/core/channel/channel_stack_builder.h
@@ -0,0 +1,155 @@
+/*
+ *
+ * Copyright 2016, 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_CORE_CHANNEL_CHANNEL_STACK_BUILDER_H
+#define GRPC_CORE_CHANNEL_CHANNEL_STACK_BUILDER_H
+
+#include <stdbool.h>
+
+#include "src/core/channel/channel_args.h"
+#include "src/core/channel/channel_stack.h"
+
+/// grpc_channel_stack_builder offers a programmatic interface to selected
+/// and order channel filters
+typedef struct grpc_channel_stack_builder grpc_channel_stack_builder;
+typedef struct grpc_channel_stack_builder_iterator
+ grpc_channel_stack_builder_iterator;
+
+/// Create a new channel stack builder
+grpc_channel_stack_builder *grpc_channel_stack_builder_create(void);
+
+/// Assign a name to the channel stack: \a name must be statically allocated
+void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder *builder,
+ const char *name);
+
+/// Attach \a transport to the builder (does not take ownership)
+void grpc_channel_stack_builder_set_transport(
+ grpc_channel_stack_builder *builder, grpc_transport *transport);
+
+/// Fetch attached transport
+grpc_transport *grpc_channel_stack_builder_get_transport(
+ grpc_channel_stack_builder *builder);
+
+/// Set channel arguments: \a args must continue to exist until after
+/// grpc_channel_stack_builder_finish returns
+void grpc_channel_stack_builder_set_channel_arguments(
+ grpc_channel_stack_builder *builder, const grpc_channel_args *args);
+
+/// Return a borrowed pointer to the channel arguments
+const grpc_channel_args *grpc_channel_stack_builder_get_channel_arguments(
+ grpc_channel_stack_builder *builder);
+
+/// Begin iterating over already defined filters in the builder at the beginning
+grpc_channel_stack_builder_iterator *
+grpc_channel_stack_builder_create_iterator_at_first(
+ grpc_channel_stack_builder *builder);
+
+/// Begin iterating over already defined filters in the builder at the end
+grpc_channel_stack_builder_iterator *
+grpc_channel_stack_builder_create_iterator_at_last(
+ grpc_channel_stack_builder *builder);
+
+/// Is an iterator at the first element?
+bool grpc_channel_stack_builder_iterator_is_first(
+ grpc_channel_stack_builder_iterator *iterator);
+
+/// Is an iterator at the end?
+bool grpc_channel_stack_builder_iterator_is_end(
+ grpc_channel_stack_builder_iterator *iterator);
+
+/// Move an iterator to the next item
+bool grpc_channel_stack_builder_move_next(
+ grpc_channel_stack_builder_iterator *iterator);
+
+/// Move an iterator to the previous item
+bool grpc_channel_stack_builder_move_prev(
+ grpc_channel_stack_builder_iterator *iterator);
+
+typedef void (*grpc_post_filter_create_init_func)(
+ grpc_channel_stack *channel_stack, grpc_channel_element *elem, void *arg);
+
+/// Add \a filter to the stack, after \a iterator.
+/// Call \a post_init_func(..., \a user_data) once the channel stack is
+/// created.
+bool grpc_channel_stack_builder_add_filter_after(
+ grpc_channel_stack_builder_iterator *iterator,
+ const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func,
+ void *user_data) GRPC_MUST_USE_RESULT;
+
+/// Add \a filter to the stack, before \a iterator.
+/// Call \a post_init_func(..., \a user_data) once the channel stack is
+/// created.
+bool grpc_channel_stack_builder_add_filter_before(
+ grpc_channel_stack_builder_iterator *iterator,
+ const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func,
+ void *user_data) GRPC_MUST_USE_RESULT;
+
+/// Add \a filter to the beginning of the filter list.
+/// Call \a post_init_func(..., \a user_data) once the channel stack is
+/// created.
+bool grpc_channel_stack_builder_prepend_filter(
+ grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func,
+ void *user_data) GRPC_MUST_USE_RESULT;
+
+/// Add \a filter to the end of the filter list.
+/// Call \a post_init_func(..., \a user_data) once the channel stack is
+/// created.
+bool grpc_channel_stack_builder_append_filter(
+ grpc_channel_stack_builder *builder, const grpc_channel_filter *filter,
+ grpc_post_filter_create_init_func post_init_func,
+ void *user_data) GRPC_MUST_USE_RESULT;
+
+/// Terminate iteration and destroy \a iterator
+void grpc_channel_stack_builder_iterator_destroy(
+ grpc_channel_stack_builder_iterator *iterator);
+
+/// Destroy the builder, return the freshly minted channel stack
+/// Allocates \a prefix_bytes bytes before the channel stack
+/// Returns the base pointer of the allocated block
+/// \a initial_refs, \a destroy, \a destroy_arg are as per
+/// grpc_channel_stack_init
+void *grpc_channel_stack_builder_finish(grpc_exec_ctx *exec_ctx,
+ grpc_channel_stack_builder *builder,
+ size_t prefix_bytes, int initial_refs,
+ grpc_iomgr_cb_func destroy,
+ void *destroy_arg);
+
+/// Destroy the builder without creating a channel stack
+void grpc_channel_stack_builder_destroy(grpc_channel_stack_builder *builder);
+
+extern int grpc_trace_channel_stack_builder;
+
+#endif /* GRPC_CORE_CHANNEL_CHANNEL_STACK_BUILDER_H */
diff --git a/src/core/channel/client_channel.h b/src/core/channel/client_channel.h
index d9bc4971f1..422f7f8374 100644
--- a/src/core/channel/client_channel.h
+++ b/src/core/channel/client_channel.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H
-#define GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H
+#ifndef GRPC_CORE_CHANNEL_CLIENT_CHANNEL_H
+#define GRPC_CORE_CHANNEL_CLIENT_CHANNEL_H
#include "src/core/channel/channel_stack.h"
#include "src/core/client_config/resolver.h"
@@ -60,4 +60,4 @@ void grpc_client_channel_watch_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset,
grpc_connectivity_state *state, grpc_closure *on_complete);
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_CLIENT_CHANNEL_H */
+#endif /* GRPC_CORE_CHANNEL_CLIENT_CHANNEL_H */
diff --git a/src/core/channel/client_uchannel.c b/src/core/channel/client_uchannel.c
index 83fcc3a87f..d32327206e 100644
--- a/src/core/channel/client_uchannel.c
+++ b/src/core/channel/client_uchannel.c
@@ -212,20 +212,10 @@ void grpc_client_uchannel_watch_connectivity_state(
grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
grpc_channel_args *args) {
grpc_channel *channel = NULL;
-#define MAX_FILTERS 3
- const grpc_channel_filter *filters[MAX_FILTERS];
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- size_t n = 0;
-
- if (grpc_channel_args_is_census_enabled(args)) {
- filters[n++] = &grpc_client_census_filter;
- }
- filters[n++] = &grpc_compress_filter;
- filters[n++] = &grpc_client_uchannel_filter;
- GPR_ASSERT(n <= MAX_FILTERS);
channel =
- grpc_channel_create_from_filters(&exec_ctx, NULL, filters, n, args, 1);
+ grpc_channel_create(&exec_ctx, NULL, args, GRPC_CLIENT_UCHANNEL, NULL);
return channel;
}
diff --git a/src/core/channel/client_uchannel.h b/src/core/channel/client_uchannel.h
index 92a831493c..8bb288e7d4 100644
--- a/src/core/channel/client_uchannel.h
+++ b/src/core/channel/client_uchannel.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_CLIENT_MICROCHANNEL_H
-#define GRPC_INTERNAL_CORE_CHANNEL_CLIENT_MICROCHANNEL_H
+#ifndef GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H
+#define GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H
#include "src/core/channel/channel_stack.h"
#include "src/core/client_config/resolver.h"
@@ -57,4 +57,4 @@ grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
void grpc_client_uchannel_set_connected_subchannel(
grpc_channel *uchannel, grpc_connected_subchannel *connected_subchannel);
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_CLIENT_MICROCHANNEL_H */
+#endif /* GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H */
diff --git a/src/core/channel/compress_filter.h b/src/core/channel/compress_filter.h
index 415459bca6..8c208ac799 100644
--- a/src/core/channel/compress_filter.h
+++ b/src/core/channel/compress_filter.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_COMPRESS_FILTER_H
-#define GRPC_INTERNAL_CORE_CHANNEL_COMPRESS_FILTER_H
+#ifndef GRPC_CORE_CHANNEL_COMPRESS_FILTER_H
+#define GRPC_CORE_CHANNEL_COMPRESS_FILTER_H
#include "src/core/channel/channel_stack.h"
@@ -62,4 +62,4 @@
extern const grpc_channel_filter grpc_compress_filter;
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_COMPRESS_FILTER_H */
+#endif /* GRPC_CORE_CHANNEL_COMPRESS_FILTER_H */
diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c
index e8eb9dcfc5..e7ed3ccfeb 100644
--- a/src/core/channel/connected_channel.c
+++ b/src/core/channel/connected_channel.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,6 @@ static void con_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
grpc_transport_stream_op *op) {
call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data;
- GPR_ASSERT(elem->filter == &grpc_connected_channel_filter);
GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
grpc_transport_perform_stream_op(exec_ctx, chand->transport,
@@ -88,7 +87,6 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
channel_data *chand = elem->channel_data;
int r;
- GPR_ASSERT(elem->filter == &grpc_connected_channel_filter);
r = grpc_transport_init_stream(
exec_ctx, chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
&args->call_stack->refcount, args->server_transport_data);
@@ -108,7 +106,6 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem) {
call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data;
- GPR_ASSERT(elem->filter == &grpc_connected_channel_filter);
grpc_transport_destroy_stream(exec_ctx, chand->transport,
TRANSPORT_STREAM_FROM_CALL_DATA(calld));
}
@@ -119,7 +116,6 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element_args *args) {
channel_data *cd = (channel_data *)elem->channel_data;
GPR_ASSERT(args->is_last);
- GPR_ASSERT(elem->filter == &grpc_connected_channel_filter);
cd->transport = NULL;
}
@@ -127,7 +123,6 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {
channel_data *cd = (channel_data *)elem->channel_data;
- GPR_ASSERT(elem->filter == &grpc_connected_channel_filter);
grpc_transport_destroy(exec_ctx, cd->transport);
}
@@ -136,21 +131,18 @@ static char *con_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
return grpc_transport_get_peer(exec_ctx, chand->transport);
}
-const grpc_channel_filter grpc_connected_channel_filter = {
+static const grpc_channel_filter connected_channel_filter = {
con_start_transport_stream_op, con_start_transport_op, sizeof(call_data),
init_call_elem, set_pollset, destroy_call_elem, sizeof(channel_data),
init_channel_elem, destroy_channel_elem, con_get_peer, "connected",
};
-void grpc_connected_channel_bind_transport(grpc_channel_stack *channel_stack,
- grpc_transport *transport) {
- /* Assumes that the connected channel filter is always the last filter
- in a channel stack */
- grpc_channel_element *elem = grpc_channel_stack_last_element(channel_stack);
+static void bind_transport(grpc_channel_stack *channel_stack,
+ grpc_channel_element *elem, void *t) {
channel_data *cd = (channel_data *)elem->channel_data;
- GPR_ASSERT(elem->filter == &grpc_connected_channel_filter);
+ GPR_ASSERT(elem->filter == &connected_channel_filter);
GPR_ASSERT(cd->transport == NULL);
- cd->transport = transport;
+ cd->transport = t;
/* HACK(ctiller): increase call stack size for the channel to make space
for channel data. We need a cleaner (but performant) way to do this,
@@ -158,7 +150,16 @@ void grpc_connected_channel_bind_transport(grpc_channel_stack *channel_stack,
This is only "safe" because call stacks place no additional data after
the last call element, and the last call element MUST be the connected
channel. */
- channel_stack->call_stack_size += grpc_transport_stream_size(transport);
+ channel_stack->call_stack_size += grpc_transport_stream_size(t);
+}
+
+bool grpc_add_connected_filter(grpc_channel_stack_builder *builder,
+ void *arg_must_be_null) {
+ GPR_ASSERT(arg_must_be_null == NULL);
+ grpc_transport *t = grpc_channel_stack_builder_get_transport(builder);
+ GPR_ASSERT(t != NULL);
+ return grpc_channel_stack_builder_append_filter(
+ builder, &connected_channel_filter, bind_transport, t);
}
grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem) {
diff --git a/src/core/channel/connected_channel.h b/src/core/channel/connected_channel.h
index 95c1834bfa..7c0c8359a4 100644
--- a/src/core/channel/connected_channel.h
+++ b/src/core/channel/connected_channel.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,21 +31,12 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H
-#define GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H
+#ifndef GRPC_CORE_CHANNEL_CONNECTED_CHANNEL_H
+#define GRPC_CORE_CHANNEL_CONNECTED_CHANNEL_H
-#include "src/core/channel/channel_stack.h"
+#include "src/core/channel/channel_stack_builder.h"
-/* A channel filter representing a channel that is on a connected transport.
- This filter performs actual sending and receiving of messages. */
+bool grpc_add_connected_filter(grpc_channel_stack_builder *builder,
+ void *arg_must_be_null);
-extern const grpc_channel_filter grpc_connected_channel_filter;
-
-/* Post construction fixup: set the transport in the connected channel.
- Must be called before any call stack using this filter is used. */
-void grpc_connected_channel_bind_transport(grpc_channel_stack* channel_stack,
- grpc_transport* transport);
-
-grpc_stream* grpc_connected_channel_get_stream(grpc_call_element* elem);
-
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_CONNECTED_CHANNEL_H */
+#endif /* GRPC_CORE_CHANNEL_CONNECTED_CHANNEL_H */
diff --git a/src/core/channel/context.h b/src/core/channel/context.h
index ac5796b9ef..db217dc133 100644
--- a/src/core/channel/context.h
+++ b/src/core/channel/context.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_CONTEXT_H
-#define GRPC_INTERNAL_CORE_CHANNEL_CONTEXT_H
+#ifndef GRPC_CORE_CHANNEL_CONTEXT_H
+#define GRPC_CORE_CHANNEL_CONTEXT_H
/* Call object context pointers */
typedef enum {
@@ -46,4 +46,4 @@ typedef struct {
void (*destroy)(void *);
} grpc_call_context_element;
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_CONTEXT_H */
+#endif /* GRPC_CORE_CHANNEL_CONTEXT_H */
diff --git a/src/core/channel/http_client_filter.h b/src/core/channel/http_client_filter.h
index 21c66b9b8e..6f619bbf00 100644
--- a/src/core/channel/http_client_filter.h
+++ b/src/core/channel/http_client_filter.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_HTTP_CLIENT_FILTER_H
-#define GRPC_INTERNAL_CORE_CHANNEL_HTTP_CLIENT_FILTER_H
+#ifndef GRPC_CORE_CHANNEL_HTTP_CLIENT_FILTER_H
+#define GRPC_CORE_CHANNEL_HTTP_CLIENT_FILTER_H
#include "src/core/channel/channel_stack.h"
@@ -41,4 +41,4 @@ extern const grpc_channel_filter grpc_http_client_filter;
#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme"
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_HTTP_CLIENT_FILTER_H */
+#endif /* GRPC_CORE_CHANNEL_HTTP_CLIENT_FILTER_H */
diff --git a/src/core/channel/http_server_filter.h b/src/core/channel/http_server_filter.h
index f219d4e66f..528c8648fd 100644
--- a/src/core/channel/http_server_filter.h
+++ b/src/core/channel/http_server_filter.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,12 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_HTTP_SERVER_FILTER_H
-#define GRPC_INTERNAL_CORE_CHANNEL_HTTP_SERVER_FILTER_H
+#ifndef GRPC_CORE_CHANNEL_HTTP_SERVER_FILTER_H
+#define GRPC_CORE_CHANNEL_HTTP_SERVER_FILTER_H
#include "src/core/channel/channel_stack.h"
/* Processes metadata on the client side for HTTP2 transports */
extern const grpc_channel_filter grpc_http_server_filter;
-#endif /* GRPC_INTERNAL_CORE_CHANNEL_HTTP_SERVER_FILTER_H */
+#endif /* GRPC_CORE_CHANNEL_HTTP_SERVER_FILTER_H */
diff --git a/src/core/channel/subchannel_call_holder.h b/src/core/channel/subchannel_call_holder.h
index 9cf72c6cf7..9086cdc882 100644
--- a/src/core/channel/subchannel_call_holder.h
+++ b/src/core/channel/subchannel_call_holder.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHANNEL_SUBCHANNEL_CALL_HOLDER_H
-#define GRPC_INTERNAL_CORE_CHANNEL_SUBCHANNEL_CALL_HOLDER_H
+#ifndef GRPC_CORE_CHANNEL_SUBCHANNEL_CALL_HOLDER_H
+#define GRPC_CORE_CHANNEL_SUBCHANNEL_CALL_HOLDER_H
#include "src/core/client_config/subchannel.h"
@@ -95,4 +95,4 @@ void grpc_subchannel_call_holder_perform_op(grpc_exec_ctx *exec_ctx,
char *grpc_subchannel_call_holder_get_peer(grpc_exec_ctx *exec_ctx,
grpc_subchannel_call_holder *holder);
-#endif
+#endif /* GRPC_CORE_CHANNEL_SUBCHANNEL_CALL_HOLDER_H */
diff --git a/src/core/client_config/client_config.h b/src/core/client_config/client_config.h
index 04bf036b00..9b37fdc211 100644
--- a/src/core/client_config/client_config.h
+++ b/src/core/client_config/client_config.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H
+#define GRPC_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H
#include "src/core/client_config/lb_policy.h"
@@ -50,4 +50,4 @@ void grpc_client_config_set_lb_policy(grpc_client_config *client_config,
grpc_lb_policy *grpc_client_config_get_lb_policy(
grpc_client_config *client_config);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_CLIENT_CONFIG_H */
diff --git a/src/core/client_config/connector.h b/src/core/client_config/connector.h
index b91eb512c3..93248fca4b 100644
--- a/src/core/client_config/connector.h
+++ b/src/core/client_config/connector.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONNECTOR_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_CONNECTOR_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_CONNECTOR_H
+#define GRPC_CORE_CLIENT_CONFIG_CONNECTOR_H
#include "src/core/channel/channel_stack.h"
#include "src/core/iomgr/sockaddr.h"
@@ -62,9 +62,6 @@ typedef struct {
typedef struct {
/** the connected transport */
grpc_transport *transport;
- /** any additional filters (owned by the caller of connect) */
- const grpc_channel_filter **filters;
- size_t num_filters;
/** channel arguments (to be passed to the filters) */
const grpc_channel_args *channel_args;
@@ -92,4 +89,4 @@ void grpc_connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
void grpc_connector_shutdown(grpc_exec_ctx *exec_ctx,
grpc_connector *connector);
-#endif
+#endif /* GRPC_CORE_CLIENT_CONFIG_CONNECTOR_H */
diff --git a/src/core/client_config/initial_connect_string.h b/src/core/client_config/initial_connect_string.h
index b6dca7134a..e6d2d8f8fe 100644
--- a/src/core/client_config/initial_connect_string.h
+++ b/src/core/client_config/initial_connect_string.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H
+#define GRPC_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H
#include <grpc/support/slice.h>
#include "src/core/iomgr/sockaddr.h"
@@ -47,4 +47,4 @@ void grpc_test_set_initial_connect_string_function(
void grpc_set_initial_connect_string(struct sockaddr **addr, size_t *addr_len,
gpr_slice *connect_string);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_INITIAL_CONNECT_STRING_H */
diff --git a/src/core/client_config/lb_policies/load_balancer_api.h b/src/core/client_config/lb_policies/load_balancer_api.h
index 4dbe1d6c22..b7a4c9c8f5 100644
--- a/src/core/client_config/lb_policies/load_balancer_api.h
+++ b/src/core/client_config/lb_policies/load_balancer_api.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H
+#define GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H
#include <grpc/support/slice_buffer.h>
@@ -82,4 +82,4 @@ void grpc_grpclb_response_destroy(grpc_grpclb_response *response);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_LOAD_BALANCER_API_H */
diff --git a/src/core/client_config/lb_policies/pick_first.h b/src/core/client_config/lb_policies/pick_first.h
index 3ca53ad42a..3a3f195df5 100644
--- a/src/core/client_config/lb_policies/pick_first.h
+++ b/src/core/client_config/lb_policies/pick_first.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_PICK_FIRST_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_PICK_FIRST_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_PICK_FIRST_H
+#define GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_PICK_FIRST_H
#include "src/core/client_config/lb_policy_factory.h"
@@ -40,4 +40,4 @@
* the first subchannel from \a subchannels to succesfully connect */
grpc_lb_policy_factory *grpc_pick_first_lb_factory_create();
-#endif
+#endif /* GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_PICK_FIRST_H */
diff --git a/src/core/client_config/lb_policies/round_robin.h b/src/core/client_config/lb_policies/round_robin.h
index cf1f69c85f..7e6f1769e4 100644
--- a/src/core/client_config/lb_policies/round_robin.h
+++ b/src/core/client_config/lb_policies/round_robin.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_ROUND_ROBIN_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_ROUND_ROBIN_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_ROUND_ROBIN_H
+#define GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_ROUND_ROBIN_H
#include "src/core/client_config/lb_policy.h"
@@ -43,4 +43,4 @@ extern int grpc_lb_round_robin_trace;
/** Returns a load balancing factory for the round robin policy */
grpc_lb_policy_factory *grpc_round_robin_lb_factory_create();
-#endif
+#endif /* GRPC_CORE_CLIENT_CONFIG_LB_POLICIES_ROUND_ROBIN_H */
diff --git a/src/core/client_config/lb_policy.h b/src/core/client_config/lb_policy.h
index 3457390606..ffebc2a69c 100644
--- a/src/core/client_config/lb_policy.h
+++ b/src/core/client_config/lb_policy.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_LB_POLICY_H
+#define GRPC_CORE_CLIENT_CONFIG_LB_POLICY_H
#include "src/core/client_config/subchannel.h"
#include "src/core/transport/connectivity_state.h"
@@ -141,4 +141,4 @@ void grpc_lb_policy_notify_on_state_change(grpc_exec_ctx *exec_ctx,
grpc_connectivity_state grpc_lb_policy_check_connectivity(
grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
-#endif /* GRPC_INTERNAL_CORE_CONFIG_LB_POLICY_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_LB_POLICY_H */
diff --git a/src/core/client_config/lb_policy_factory.h b/src/core/client_config/lb_policy_factory.h
index 04610316ee..842ba96098 100644
--- a/src/core/client_config/lb_policy_factory.h
+++ b/src/core/client_config/lb_policy_factory.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_FACTORY_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_FACTORY_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_LB_POLICY_FACTORY_H
+#define GRPC_CORE_CLIENT_CONFIG_LB_POLICY_FACTORY_H
#include "src/core/client_config/lb_policy.h"
#include "src/core/client_config/subchannel.h"
@@ -70,4 +70,4 @@ void grpc_lb_policy_factory_unref(grpc_lb_policy_factory *factory);
grpc_lb_policy *grpc_lb_policy_factory_create_lb_policy(
grpc_lb_policy_factory *factory, grpc_lb_policy_args *args);
-#endif /* GRPC_INTERNAL_CORE_CONFIG_LB_POLICY_FACTORY_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_LB_POLICY_FACTORY_H */
diff --git a/src/core/client_config/lb_policy_registry.h b/src/core/client_config/lb_policy_registry.h
index 96fc2a1628..f3a08a3558 100644
--- a/src/core/client_config/lb_policy_registry.h
+++ b/src/core/client_config/lb_policy_registry.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_REGISTRY_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_REGISTRY_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_LB_POLICY_REGISTRY_H
+#define GRPC_CORE_CLIENT_CONFIG_LB_POLICY_REGISTRY_H
#include "src/core/client_config/lb_policy_factory.h"
@@ -51,4 +51,4 @@ void grpc_register_lb_policy(grpc_lb_policy_factory *factory);
grpc_lb_policy *grpc_lb_policy_create(const char *name,
grpc_lb_policy_args *args);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_LB_POLICY_REGISTRY_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_LB_POLICY_REGISTRY_H */
diff --git a/src/core/client_config/resolver.h b/src/core/client_config/resolver.h
index e612eaf3b3..96f88fef84 100644
--- a/src/core/client_config/resolver.h
+++ b/src/core/client_config/resolver.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_RESOLVER_H
+#define GRPC_CORE_CLIENT_CONFIG_RESOLVER_H
#include "src/core/client_config/client_config.h"
#include "src/core/client_config/subchannel.h"
@@ -91,4 +91,4 @@ void grpc_resolver_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
grpc_client_config **target_config,
grpc_closure *on_complete);
-#endif /* GRPC_INTERNAL_CORE_CONFIG_RESOLVER_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_RESOLVER_H */
diff --git a/src/core/client_config/resolver_factory.h b/src/core/client_config/resolver_factory.h
index 4c4df353f7..477f8db7f7 100644
--- a/src/core/client_config/resolver_factory.h
+++ b/src/core/client_config/resolver_factory.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_FACTORY_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_FACTORY_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_RESOLVER_FACTORY_H
+#define GRPC_CORE_CLIENT_CONFIG_RESOLVER_FACTORY_H
#include "src/core/client_config/resolver.h"
#include "src/core/client_config/subchannel_factory.h"
@@ -79,4 +79,4 @@ grpc_resolver *grpc_resolver_factory_create_resolver(
char *grpc_resolver_factory_get_default_authority(
grpc_resolver_factory *factory, grpc_uri *uri);
-#endif /* GRPC_INTERNAL_CORE_CONFIG_RESOLVER_FACTORY_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_RESOLVER_FACTORY_H */
diff --git a/src/core/client_config/resolver_registry.h b/src/core/client_config/resolver_registry.h
index 5a7193b7ae..1e4cebee0b 100644
--- a/src/core/client_config/resolver_registry.h
+++ b/src/core/client_config/resolver_registry.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H
+#define GRPC_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H
#include "src/core/client_config/resolver_factory.h"
@@ -62,4 +62,4 @@ grpc_resolver *grpc_resolver_create(
representing the default authority to pass from a client. */
char *grpc_get_default_authority(const char *target);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_RESOLVER_REGISTRY_H */
diff --git a/src/core/client_config/resolvers/dns_resolver.h b/src/core/client_config/resolvers/dns_resolver.h
index a3ef3161a6..b24280b507 100644
--- a/src/core/client_config/resolvers/dns_resolver.h
+++ b/src/core/client_config/resolvers/dns_resolver.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,12 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H
+#define GRPC_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H
#include "src/core/client_config/resolver_factory.h"
/** Create a dns resolver factory */
grpc_resolver_factory *grpc_dns_resolver_factory_create(void);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_RESOLVERS_DNS_RESOLVER_H */
diff --git a/src/core/client_config/resolvers/sockaddr_resolver.h b/src/core/client_config/resolvers/sockaddr_resolver.h
index 1b7a18f9c2..f050329431 100644
--- a/src/core/client_config/resolvers/sockaddr_resolver.h
+++ b/src/core/client_config/resolvers/sockaddr_resolver.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_UNIX_RESOLVER_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_UNIX_RESOLVER_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_RESOLVERS_SOCKADDR_RESOLVER_H
+#define GRPC_CORE_CLIENT_CONFIG_RESOLVERS_SOCKADDR_RESOLVER_H
#include <grpc/support/port_platform.h>
@@ -47,4 +47,4 @@ grpc_resolver_factory *grpc_ipv6_resolver_factory_create(void);
grpc_resolver_factory *grpc_unix_resolver_factory_create(void);
#endif
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_UNIX_RESOLVER_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_RESOLVERS_SOCKADDR_RESOLVER_H */
diff --git a/src/core/client_config/resolvers/zookeeper_resolver.h b/src/core/client_config/resolvers/zookeeper_resolver.h
index a6f002dd6d..04bd3ca875 100644
--- a/src/core/client_config/resolvers/zookeeper_resolver.h
+++ b/src/core/client_config/resolvers/zookeeper_resolver.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,12 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_ZOOKEEPER_RESOLVER_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_ZOOKEEPER_RESOLVER_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_RESOLVERS_ZOOKEEPER_RESOLVER_H
+#define GRPC_CORE_CLIENT_CONFIG_RESOLVERS_ZOOKEEPER_RESOLVER_H
#include "src/core/client_config/resolver_factory.h"
/** Create a zookeeper resolver factory */
grpc_resolver_factory *grpc_zookeeper_resolver_factory_create(void);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_RESOLVERS_ZOOKEEPER_RESOLVER_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_RESOLVERS_ZOOKEEPER_RESOLVER_H */
diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c
index 5dea215668..8f150a8d81 100644
--- a/src/core/client_config/subchannel.c
+++ b/src/core/client_config/subchannel.c
@@ -47,6 +47,7 @@
#include "src/core/profiling/timers.h"
#include "src/core/support/backoff.h"
#include "src/core/surface/channel.h"
+#include "src/core/surface/channel_init.h"
#include "src/core/transport/connectivity_state.h"
#define INTERNAL_REF_BITS 16
@@ -521,32 +522,15 @@ void grpc_connected_subchannel_ping(grpc_exec_ctx *exec_ctx,
static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
grpc_subchannel *c) {
- size_t channel_stack_size;
grpc_connected_subchannel *con;
grpc_channel_stack *stk;
- size_t num_filters;
- const grpc_channel_filter **filters;
state_watcher *sw_subchannel;
- /* build final filter list */
- num_filters = c->num_filters + c->connecting_result.num_filters + 1;
- filters = gpr_malloc(sizeof(*filters) * num_filters);
- if (c->num_filters > 0) {
- memcpy((void *)filters, c->filters, sizeof(*filters) * c->num_filters);
- }
- memcpy((void *)(filters + c->num_filters), c->connecting_result.filters,
- sizeof(*filters) * c->connecting_result.num_filters);
- filters[num_filters - 1] = &grpc_connected_channel_filter;
-
/* construct channel stack */
- channel_stack_size = grpc_channel_stack_size(filters, num_filters);
- con = gpr_malloc(channel_stack_size);
+ con = grpc_channel_init_create_stack(
+ exec_ctx, GRPC_CLIENT_SUBCHANNEL, 0, c->connecting_result.channel_args, 1,
+ connection_destroy, NULL, c->connecting_result.transport);
stk = CHANNEL_STACK_FROM_CONNECTION(con);
- grpc_channel_stack_init(exec_ctx, 1, connection_destroy, con, filters,
- num_filters, c->connecting_result.channel_args,
- "CONNECTED_SUBCHANNEL", stk);
- grpc_connected_channel_bind_transport(stk, c->connecting_result.transport);
- gpr_free((void *)c->connecting_result.filters);
memset(&c->connecting_result, 0, sizeof(c->connecting_result));
/* initialize state watcher */
@@ -557,9 +541,7 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
sw_subchannel);
if (c->disconnected) {
- gpr_mu_unlock(&c->mu);
gpr_free(sw_subchannel);
- gpr_free((void *)filters);
grpc_channel_stack_destroy(exec_ctx, stk);
gpr_free(con);
GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
@@ -587,8 +569,6 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
/* signal completion */
grpc_connectivity_state_set(exec_ctx, &c->state_tracker, GRPC_CHANNEL_READY,
"connected");
-
- gpr_free((void *)filters);
}
static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, bool iomgr_success) {
diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h
index 313e63c75c..ef9f2f1d1e 100644
--- a/src/core/client_config/subchannel.h
+++ b/src/core/client_config/subchannel.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_H
+#define GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_H
#include "src/core/channel/channel_stack.h"
#include "src/core/client_config/connector.h"
@@ -171,4 +171,4 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
grpc_connector *connector,
grpc_subchannel_args *args);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_H */
diff --git a/src/core/client_config/subchannel_factory.h b/src/core/client_config/subchannel_factory.h
index c6d8cc90be..c638f377a6 100644
--- a/src/core/client_config/subchannel_factory.h
+++ b/src/core/client_config/subchannel_factory.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H
+#define GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H
#include "src/core/channel/channel_stack.h"
#include "src/core/client_config/subchannel.h"
@@ -63,4 +63,4 @@ grpc_subchannel *grpc_subchannel_factory_create_subchannel(
grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *factory,
grpc_subchannel_args *args);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_FACTORY_H */
diff --git a/src/core/client_config/subchannel_index.c b/src/core/client_config/subchannel_index.c
index 3f948998f9..24cc76cf22 100644
--- a/src/core/client_config/subchannel_index.c
+++ b/src/core/client_config/subchannel_index.c
@@ -108,6 +108,7 @@ static int subchannel_key_compare(grpc_subchannel_key *a,
if (c != 0) return c;
c = memcmp(a->args.filters, b->args.filters,
a->args.filter_count * sizeof(*a->args.filters));
+ if (c != 0) return c;
return grpc_channel_args_compare(a->args.args, b->args.args);
}
diff --git a/src/core/client_config/subchannel_index.h b/src/core/client_config/subchannel_index.h
index 095ef17819..3cd5d12349 100644
--- a/src/core/client_config/subchannel_index.h
+++ b/src/core/client_config/subchannel_index.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_INDEX_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_INDEX_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_INDEX_H
+#define GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_INDEX_H
#include "src/core/client_config/connector.h"
#include "src/core/client_config/subchannel.h"
@@ -74,4 +74,4 @@ void grpc_subchannel_index_init(void);
/** Shutdown the subchannel index (global) */
void grpc_subchannel_index_shutdown(void);
-#endif /* GRPC_INTERNAL_CORE_CLIENT_CONFIG_SUBCHANNEL_INDEX_H */
+#endif /* GRPC_CORE_CLIENT_CONFIG_SUBCHANNEL_INDEX_H */
diff --git a/src/core/client_config/uri_parser.h b/src/core/client_config/uri_parser.h
index b8daa13bd4..af013d8cac 100644
--- a/src/core/client_config/uri_parser.h
+++ b/src/core/client_config/uri_parser.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CLIENT_CONFIG_URI_PARSER_H
-#define GRPC_INTERNAL_CORE_CLIENT_CONFIG_URI_PARSER_H
+#ifndef GRPC_CORE_CLIENT_CONFIG_URI_PARSER_H
+#define GRPC_CORE_CLIENT_CONFIG_URI_PARSER_H
typedef struct {
char *scheme;
@@ -48,4 +48,4 @@ grpc_uri *grpc_uri_parse(const char *uri_text, int suppress_errors);
/** destroy a uri */
void grpc_uri_destroy(grpc_uri *uri);
-#endif
+#endif /* GRPC_CORE_CLIENT_CONFIG_URI_PARSER_H */
diff --git a/src/core/compression/algorithm_metadata.h b/src/core/compression/algorithm_metadata.h
index 882633c307..34abf1dba2 100644
--- a/src/core/compression/algorithm_metadata.h
+++ b/src/core/compression/algorithm_metadata.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_METADATA_H
-#define GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_METADATA_H
+#ifndef GRPC_CORE_COMPRESSION_ALGORITHM_METADATA_H
+#define GRPC_CORE_COMPRESSION_ALGORITHM_METADATA_H
#include <grpc/compression.h>
#include "src/core/transport/metadata.h"
@@ -50,4 +50,4 @@ grpc_mdelem *grpc_compression_encoding_mdelem(
grpc_compression_algorithm grpc_compression_algorithm_from_mdstr(
grpc_mdstr *str);
-#endif /* GRPC_INTERNAL_CORE_COMPRESSION_ALGORITHM_METADATA_H */
+#endif /* GRPC_CORE_COMPRESSION_ALGORITHM_METADATA_H */
diff --git a/src/core/compression/compression_algorithm.c b/src/core/compression/compression_algorithm.c
index 6f3a8eb28e..2810a38b68 100644
--- a/src/core/compression/compression_algorithm.c
+++ b/src/core/compression/compression_algorithm.c
@@ -128,20 +128,57 @@ grpc_mdelem *grpc_compression_encoding_mdelem(
/* TODO(dgq): Add the ability to specify parameters to the individual
* compression algorithms */
grpc_compression_algorithm grpc_compression_algorithm_for_level(
- grpc_compression_level level) {
+ grpc_compression_level level, uint32_t accepted_encodings) {
GRPC_API_TRACE("grpc_compression_algorithm_for_level(level=%d)", 1,
((int)level));
+ if (level > GRPC_COMPRESS_LEVEL_HIGH) {
+ gpr_log(GPR_ERROR, "Unknown compression level %d.", (int)level);
+ abort();
+ }
+
+ const size_t num_supported =
+ GPR_BITCOUNT(accepted_encodings) - 1; /* discard NONE */
+ if (level == GRPC_COMPRESS_LEVEL_NONE || num_supported == 0) {
+ return GRPC_COMPRESS_NONE;
+ }
+
+ GPR_ASSERT(level > 0);
+
+ /* Establish a "ranking" or compression algorithms in increasing order of
+ * compression.
+ * This is simplistic and we will probably want to introduce other dimensions
+ * in the future (cpu/memory cost, etc). */
+ const grpc_compression_algorithm algos_ranking[] = {GRPC_COMPRESS_GZIP,
+ GRPC_COMPRESS_DEFLATE};
+
+ /* intersect algos_ranking with the supported ones keeping the ranked order */
+ grpc_compression_algorithm
+ sorted_supported_algos[GRPC_COMPRESS_ALGORITHMS_COUNT];
+ size_t algos_supported_idx = 0;
+ for (size_t i = 0; i < GPR_ARRAY_SIZE(algos_ranking); i++) {
+ const grpc_compression_algorithm alg = algos_ranking[i];
+ for (size_t j = 0; j < num_supported; j++) {
+ if (GPR_BITGET(accepted_encodings, alg) == 1) {
+ /* if \a alg in supported */
+ sorted_supported_algos[algos_supported_idx++] = alg;
+ break;
+ }
+ }
+ if (algos_supported_idx == num_supported) break;
+ }
+
switch (level) {
case GRPC_COMPRESS_LEVEL_NONE:
- return GRPC_COMPRESS_NONE;
+ abort(); /* should have been handled already */
case GRPC_COMPRESS_LEVEL_LOW:
+ return sorted_supported_algos[0];
case GRPC_COMPRESS_LEVEL_MED:
+ return sorted_supported_algos[num_supported / 2];
case GRPC_COMPRESS_LEVEL_HIGH:
- return GRPC_COMPRESS_DEFLATE;
+ return sorted_supported_algos[num_supported - 1];
default:
- gpr_log(GPR_ERROR, "Unknown compression level %d.", (int)level);
abort();
- }
+ };
}
void grpc_compression_options_init(grpc_compression_options *opts) {
diff --git a/src/core/compression/message_compress.h b/src/core/compression/message_compress.h
index 14652004b8..20b78c063b 100644
--- a/src/core/compression/message_compress.h
+++ b/src/core/compression/message_compress.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_COMPRESSION_MESSAGE_COMPRESS_H
-#define GRPC_INTERNAL_CORE_COMPRESSION_MESSAGE_COMPRESS_H
+#ifndef GRPC_CORE_COMPRESSION_MESSAGE_COMPRESS_H
+#define GRPC_CORE_COMPRESSION_MESSAGE_COMPRESS_H
#include <grpc/compression.h>
#include <grpc/support/slice_buffer.h>
@@ -49,4 +49,4 @@ int grpc_msg_compress(grpc_compression_algorithm algorithm,
int grpc_msg_decompress(grpc_compression_algorithm algorithm,
gpr_slice_buffer* input, gpr_slice_buffer* output);
-#endif /* GRPC_INTERNAL_CORE_COMPRESSION_MESSAGE_COMPRESS_H */
+#endif /* GRPC_CORE_COMPRESSION_MESSAGE_COMPRESS_H */
diff --git a/src/core/debug/trace.h b/src/core/debug/trace.h
index dc5875976e..91ec14052e 100644
--- a/src/core/debug/trace.h
+++ b/src/core/debug/trace.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_DEBUG_TRACE_H
-#define GRPC_INTERNAL_CORE_DEBUG_TRACE_H
+#ifndef GRPC_CORE_DEBUG_TRACE_H
+#define GRPC_CORE_DEBUG_TRACE_H
#include <grpc/support/port_platform.h>
@@ -40,4 +40,4 @@ void grpc_register_tracer(const char *name, int *flag);
void grpc_tracer_init(const char *env_var_name);
void grpc_tracer_shutdown(void);
-#endif /* GRPC_INTERNAL_CORE_DEBUG_TRACE_H */
+#endif /* GRPC_CORE_DEBUG_TRACE_H */
diff --git a/src/core/httpcli/format_request.h b/src/core/httpcli/format_request.h
index c8dc8f7d4e..eb47cc90ca 100644
--- a/src/core/httpcli/format_request.h
+++ b/src/core/httpcli/format_request.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_HTTPCLI_FORMAT_REQUEST_H
-#define GRPC_INTERNAL_CORE_HTTPCLI_FORMAT_REQUEST_H
+#ifndef GRPC_CORE_HTTPCLI_FORMAT_REQUEST_H
+#define GRPC_CORE_HTTPCLI_FORMAT_REQUEST_H
#include "src/core/httpcli/httpcli.h"
#include <grpc/support/slice.h>
@@ -42,4 +42,4 @@ gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
const char *body_bytes,
size_t body_size);
-#endif /* GRPC_INTERNAL_CORE_HTTPCLI_FORMAT_REQUEST_H */
+#endif /* GRPC_CORE_HTTPCLI_FORMAT_REQUEST_H */
diff --git a/src/core/httpcli/httpcli.h b/src/core/httpcli/httpcli.h
index c9cd987c79..1fe5782657 100644
--- a/src/core/httpcli/httpcli.h
+++ b/src/core/httpcli/httpcli.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_H
-#define GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_H
+#ifndef GRPC_CORE_HTTPCLI_HTTPCLI_H
+#define GRPC_CORE_HTTPCLI_HTTPCLI_H
#include <stddef.h>
@@ -160,4 +160,4 @@ typedef int (*grpc_httpcli_post_override)(
void grpc_httpcli_set_override(grpc_httpcli_get_override get,
grpc_httpcli_post_override post);
-#endif /* GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_H */
+#endif /* GRPC_CORE_HTTPCLI_HTTPCLI_H */
diff --git a/src/core/httpcli/parser.h b/src/core/httpcli/parser.h
index cd0383637f..cd4a737245 100644
--- a/src/core/httpcli/parser.h
+++ b/src/core/httpcli/parser.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_HTTPCLI_PARSER_H
-#define GRPC_INTERNAL_CORE_HTTPCLI_PARSER_H
+#ifndef GRPC_CORE_HTTPCLI_PARSER_H
+#define GRPC_CORE_HTTPCLI_PARSER_H
#include "src/core/httpcli/httpcli.h"
#include <grpc/support/port_platform.h>
@@ -61,4 +61,4 @@ void grpc_httpcli_parser_destroy(grpc_httpcli_parser* parser);
int grpc_httpcli_parser_parse(grpc_httpcli_parser* parser, gpr_slice slice);
int grpc_httpcli_parser_eof(grpc_httpcli_parser* parser);
-#endif /* GRPC_INTERNAL_CORE_HTTPCLI_PARSER_H */
+#endif /* GRPC_CORE_HTTPCLI_PARSER_H */
diff --git a/src/core/iomgr/closure.h b/src/core/iomgr/closure.h
index ea96c19c71..d5e1f455b9 100644
--- a/src/core/iomgr/closure.h
+++ b/src/core/iomgr/closure.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H
-#define GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H
+#ifndef GRPC_CORE_IOMGR_CLOSURE_H
+#define GRPC_CORE_IOMGR_CLOSURE_H
#include <grpc/support/port_platform.h>
#include <stdbool.h>
@@ -95,4 +95,4 @@ bool grpc_closure_list_empty(grpc_closure_list list);
/** return the next pointer for a queued closure list */
grpc_closure *grpc_closure_next(grpc_closure *closure);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_CLOSURE_H */
+#endif /* GRPC_CORE_IOMGR_CLOSURE_H */
diff --git a/src/core/iomgr/endpoint.h b/src/core/iomgr/endpoint.h
index cbdc947abb..788f3ac5bc 100644
--- a/src/core/iomgr/endpoint.h
+++ b/src/core/iomgr/endpoint.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H
-#define GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H
+#ifndef GRPC_CORE_IOMGR_ENDPOINT_H
+#define GRPC_CORE_IOMGR_ENDPOINT_H
#include "src/core/iomgr/pollset.h"
#include "src/core/iomgr/pollset_set.h"
@@ -99,4 +99,4 @@ struct grpc_endpoint {
const grpc_endpoint_vtable *vtable;
};
-#endif /* GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_H */
+#endif /* GRPC_CORE_IOMGR_ENDPOINT_H */
diff --git a/src/core/iomgr/endpoint_pair.h b/src/core/iomgr/endpoint_pair.h
index 095ec5fcc9..59015d8ffb 100644
--- a/src/core/iomgr/endpoint_pair.h
+++ b/src/core/iomgr/endpoint_pair.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_PAIR_H
-#define GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_PAIR_H
+#ifndef GRPC_CORE_IOMGR_ENDPOINT_PAIR_H
+#define GRPC_CORE_IOMGR_ENDPOINT_PAIR_H
#include "src/core/iomgr/endpoint.h"
@@ -44,4 +44,4 @@ typedef struct {
grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name,
size_t read_slice_size);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_ENDPOINT_PAIR_H */
+#endif /* GRPC_CORE_IOMGR_ENDPOINT_PAIR_H */
diff --git a/src/core/iomgr/exec_ctx.h b/src/core/iomgr/exec_ctx.h
index 1b627a5dcf..07b54a0ab8 100644
--- a/src/core/iomgr/exec_ctx.h
+++ b/src/core/iomgr/exec_ctx.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_EXEC_CTX_H
-#define GRPC_INTERNAL_CORE_IOMGR_EXEC_CTX_H
+#ifndef GRPC_CORE_IOMGR_EXEC_CTX_H
+#define GRPC_CORE_IOMGR_EXEC_CTX_H
#include "src/core/iomgr/closure.h"
@@ -95,4 +95,4 @@ void grpc_exec_ctx_enqueue_list(grpc_exec_ctx *exec_ctx,
void grpc_exec_ctx_global_init(void);
void grpc_exec_ctx_global_shutdown(void);
-#endif
+#endif /* GRPC_CORE_IOMGR_EXEC_CTX_H */
diff --git a/src/core/iomgr/executor.h b/src/core/iomgr/executor.h
index aac057ddf5..f66b3560e3 100644
--- a/src/core/iomgr/executor.h
+++ b/src/core/iomgr/executor.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_EXECUTOR_H
-#define GRPC_INTERNAL_CORE_IOMGR_EXECUTOR_H
+#ifndef GRPC_CORE_IOMGR_EXECUTOR_H
+#define GRPC_CORE_IOMGR_EXECUTOR_H
#include "src/core/iomgr/closure.h"
@@ -50,4 +50,4 @@ void grpc_executor_enqueue(grpc_closure *closure, bool success);
/** Shutdown the executor, running all pending work as part of the call */
void grpc_executor_shutdown();
-#endif /* GRPC_INTERNAL_CORE_IOMGR_EXECUTOR_H */
+#endif /* GRPC_CORE_IOMGR_EXECUTOR_H */
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 4ba7c5df94..3edafa0b07 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -72,6 +72,9 @@ static grpc_fd *fd_freelist = NULL;
static gpr_mu fd_freelist_mu;
static void freelist_fd(grpc_fd *fd) {
+ // Note that this function must be called after a release store (or
+ // full-barrier operation) on refst so that prior actions on the fd are
+ // ordered before the fd becomes visible to the freelist
gpr_mu_lock(&fd_freelist_mu);
fd->freelist_next = fd_freelist;
fd_freelist = fd;
@@ -92,7 +95,6 @@ static grpc_fd *alloc_fd(int fd) {
gpr_mu_init(&r->mu);
}
- gpr_atm_rel_store(&r->refst, 1);
r->shutdown = 0;
r->read_closure = CLOSURE_NOT_READY;
r->write_closure = CLOSURE_NOT_READY;
@@ -104,6 +106,11 @@ static grpc_fd *alloc_fd(int fd) {
r->on_done_closure = NULL;
r->closed = 0;
r->released = 0;
+ // The last operation on r before returning it should be a release-store
+ // so that all the above fields are globally visible before the value of
+ // r could escape to another thread. Our refcount itself needs a release-store
+ // so use this
+ gpr_atm_rel_store(&r->refst, 1);
return r;
}
diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h
index 17e7de88ff..a5c8ff1d9a 100644
--- a/src/core/iomgr/fd_posix.h
+++ b/src/core/iomgr/fd_posix.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_FD_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_FD_POSIX_H
+#ifndef GRPC_CORE_IOMGR_FD_POSIX_H
+#define GRPC_CORE_IOMGR_FD_POSIX_H
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/pollset.h"
@@ -189,4 +189,4 @@ void grpc_fd_unref(grpc_fd *fd);
void grpc_fd_global_init(void);
void grpc_fd_global_shutdown(void);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_FD_POSIX_H */
+#endif /* GRPC_CORE_IOMGR_FD_POSIX_H */
diff --git a/src/core/iomgr/iocp_windows.h b/src/core/iomgr/iocp_windows.h
index 8b2b1aeb5c..570b8925aa 100644
--- a/src/core/iomgr/iocp_windows.h
+++ b/src/core/iomgr/iocp_windows.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_IOCP_WINDOWS_H
-#define GRPC_INTERNAL_CORE_IOMGR_IOCP_WINDOWS_H
+#ifndef GRPC_CORE_IOMGR_IOCP_WINDOWS_H
+#define GRPC_CORE_IOMGR_IOCP_WINDOWS_H
#include <grpc/support/sync.h>
@@ -60,4 +60,4 @@ void grpc_socket_notify_on_read(grpc_exec_ctx *exec_ctx,
grpc_winsocket *winsocket,
grpc_closure *closure);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_IOCP_WINDOWS_H */
+#endif /* GRPC_CORE_IOMGR_IOCP_WINDOWS_H */
diff --git a/src/core/iomgr/iomgr.h b/src/core/iomgr/iomgr.h
index c9ea84c605..e1237a4533 100644
--- a/src/core/iomgr/iomgr.h
+++ b/src/core/iomgr/iomgr.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_IOMGR_H
-#define GRPC_INTERNAL_CORE_IOMGR_IOMGR_H
+#ifndef GRPC_CORE_IOMGR_IOMGR_H
+#define GRPC_CORE_IOMGR_IOMGR_H
/** Initializes the iomgr. */
void grpc_iomgr_init(void);
@@ -40,4 +40,4 @@ void grpc_iomgr_init(void);
/** Signals the intention to shutdown the iomgr. */
void grpc_iomgr_shutdown(void);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_H */
+#endif /* GRPC_CORE_IOMGR_IOMGR_H */
diff --git a/src/core/iomgr/iomgr_internal.h b/src/core/iomgr/iomgr_internal.h
index ac2c46ebe6..d06b068b1c 100644
--- a/src/core/iomgr/iomgr_internal.h
+++ b/src/core/iomgr/iomgr_internal.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_IOMGR_INTERNAL_H
-#define GRPC_INTERNAL_CORE_IOMGR_IOMGR_INTERNAL_H
+#ifndef GRPC_CORE_IOMGR_IOMGR_INTERNAL_H
+#define GRPC_CORE_IOMGR_IOMGR_INTERNAL_H
#include <stdbool.h>
@@ -59,4 +59,4 @@ void grpc_iomgr_platform_shutdown(void);
bool grpc_iomgr_abort_on_leaks(void);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_INTERNAL_H */
+#endif /* GRPC_CORE_IOMGR_IOMGR_INTERNAL_H */
diff --git a/src/core/iomgr/iomgr_posix.h b/src/core/iomgr/iomgr_posix.h
index 068a5c6d7c..698fb6aee7 100644
--- a/src/core/iomgr/iomgr_posix.h
+++ b/src/core/iomgr/iomgr_posix.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,9 +31,9 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_IOMGR_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_IOMGR_POSIX_H
+#ifndef GRPC_CORE_IOMGR_IOMGR_POSIX_H
+#define GRPC_CORE_IOMGR_IOMGR_POSIX_H
#include "src/core/iomgr/iomgr_internal.h"
-#endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_POSIX_H */
+#endif /* GRPC_CORE_IOMGR_IOMGR_POSIX_H */
diff --git a/src/core/iomgr/pollset.h b/src/core/iomgr/pollset.h
index ee1debfb71..9500b1a73a 100644
--- a/src/core/iomgr/pollset.h
+++ b/src/core/iomgr/pollset.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_H
-#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_H
+#ifndef GRPC_CORE_IOMGR_POLLSET_H
+#define GRPC_CORE_IOMGR_POLLSET_H
#include <grpc/support/port_platform.h>
#include <grpc/support/sync.h>
@@ -91,4 +91,4 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
void grpc_pollset_kick(grpc_pollset *pollset,
grpc_pollset_worker *specific_worker);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_H */
+#endif /* GRPC_CORE_IOMGR_POLLSET_H */
diff --git a/src/core/iomgr/pollset_posix.h b/src/core/iomgr/pollset_posix.h
index bbedb66b00..e0cfc44395 100644
--- a/src/core/iomgr/pollset_posix.h
+++ b/src/core/iomgr/pollset_posix.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H
+#ifndef GRPC_CORE_IOMGR_POLLSET_POSIX_H
+#define GRPC_CORE_IOMGR_POLLSET_POSIX_H
#include <poll.h>
@@ -150,4 +150,4 @@ typedef int (*grpc_poll_function_type)(struct pollfd *, nfds_t, int);
extern grpc_poll_function_type grpc_poll_function;
extern grpc_wakeup_fd grpc_global_wakeup_fd;
-#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_POSIX_H */
+#endif /* GRPC_CORE_IOMGR_POLLSET_POSIX_H */
diff --git a/src/core/iomgr/pollset_set.h b/src/core/iomgr/pollset_set.h
index dddcd8313f..204c625933 100644
--- a/src/core/iomgr/pollset_set.h
+++ b/src/core/iomgr/pollset_set.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_H
-#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_H
+#ifndef GRPC_CORE_IOMGR_POLLSET_SET_H
+#define GRPC_CORE_IOMGR_POLLSET_SET_H
#include "src/core/iomgr/pollset.h"
@@ -58,4 +58,4 @@ void grpc_pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx,
grpc_pollset_set *bag,
grpc_pollset_set *item);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_H */
+#endif /* GRPC_CORE_IOMGR_POLLSET_SET_H */
diff --git a/src/core/iomgr/pollset_set_posix.h b/src/core/iomgr/pollset_set_posix.h
index 7d1aaf4181..80f487718e 100644
--- a/src/core/iomgr/pollset_set_posix.h
+++ b/src/core/iomgr/pollset_set_posix.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_POSIX_H
+#ifndef GRPC_CORE_IOMGR_POLLSET_SET_POSIX_H
+#define GRPC_CORE_IOMGR_POLLSET_SET_POSIX_H
#include "src/core/iomgr/fd_posix.h"
#include "src/core/iomgr/pollset_set.h"
@@ -42,4 +42,4 @@ void grpc_pollset_set_add_fd(grpc_exec_ctx *exec_ctx,
void grpc_pollset_set_del_fd(grpc_exec_ctx *exec_ctx,
grpc_pollset_set *pollset_set, grpc_fd *fd);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */
+#endif /* GRPC_CORE_IOMGR_POLLSET_SET_POSIX_H */
diff --git a/src/core/iomgr/pollset_set_windows.h b/src/core/iomgr/pollset_set_windows.h
index 9661cd2c39..0f040fef82 100644
--- a/src/core/iomgr/pollset_set_windows.h
+++ b/src/core/iomgr/pollset_set_windows.h
@@ -31,9 +31,9 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_WINDOWS_H
-#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_SET_WINDOWS_H
+#ifndef GRPC_CORE_IOMGR_POLLSET_SET_WINDOWS_H
+#define GRPC_CORE_IOMGR_POLLSET_SET_WINDOWS_H
#include "src/core/iomgr/pollset_set.h"
-#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */
+#endif /* GRPC_CORE_IOMGR_POLLSET_SET_WINDOWS_H */
diff --git a/src/core/iomgr/pollset_windows.h b/src/core/iomgr/pollset_windows.h
index dc0b7a4104..f1d1585922 100644
--- a/src/core/iomgr/pollset_windows.h
+++ b/src/core/iomgr/pollset_windows.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H
-#define GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H
+#ifndef GRPC_CORE_IOMGR_POLLSET_WINDOWS_H
+#define GRPC_CORE_IOMGR_POLLSET_WINDOWS_H
#include <grpc/support/sync.h>
@@ -72,4 +72,4 @@ struct grpc_pollset {
grpc_closure *on_shutdown;
};
-#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */
+#endif /* GRPC_CORE_IOMGR_POLLSET_WINDOWS_H */
diff --git a/src/core/iomgr/resolve_address.h b/src/core/iomgr/resolve_address.h
index b059630457..aa0d7d194b 100644
--- a/src/core/iomgr/resolve_address.h
+++ b/src/core/iomgr/resolve_address.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_RESOLVE_ADDRESS_H
-#define GRPC_INTERNAL_CORE_IOMGR_RESOLVE_ADDRESS_H
+#ifndef GRPC_CORE_IOMGR_RESOLVE_ADDRESS_H
+#define GRPC_CORE_IOMGR_RESOLVE_ADDRESS_H
#include <stddef.h>
#include "src/core/iomgr/exec_ctx.h"
@@ -69,4 +69,4 @@ void grpc_resolved_addresses_destroy(grpc_resolved_addresses *addresses);
extern grpc_resolved_addresses *(*grpc_blocking_resolve_address)(
const char *name, const char *default_port);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_RESOLVE_ADDRESS_H */
+#endif /* GRPC_CORE_IOMGR_RESOLVE_ADDRESS_H */
diff --git a/src/core/iomgr/sockaddr.h b/src/core/iomgr/sockaddr.h
index e41e1ec6b4..68241bdd55 100644
--- a/src/core/iomgr/sockaddr.h
+++ b/src/core/iomgr/sockaddr.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_H
-#define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_H
+#ifndef GRPC_CORE_IOMGR_SOCKADDR_H
+#define GRPC_CORE_IOMGR_SOCKADDR_H
#include <grpc/support/port_platform.h>
@@ -44,4 +44,4 @@
#include "src/core/iomgr/sockaddr_posix.h"
#endif
-#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_H */
+#endif /* GRPC_CORE_IOMGR_SOCKADDR_H */
diff --git a/src/core/iomgr/sockaddr_posix.h b/src/core/iomgr/sockaddr_posix.h
index 388abb3306..e4425ed735 100644
--- a/src/core/iomgr/sockaddr_posix.h
+++ b/src/core/iomgr/sockaddr_posix.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_POSIX_H
+#ifndef GRPC_CORE_IOMGR_SOCKADDR_POSIX_H
+#define GRPC_CORE_IOMGR_SOCKADDR_POSIX_H
#include <arpa/inet.h>
#include <sys/socket.h>
@@ -41,4 +41,4 @@
#include <netdb.h>
#include <unistd.h>
-#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_POSIX_H */
+#endif /* GRPC_CORE_IOMGR_SOCKADDR_POSIX_H */
diff --git a/src/core/iomgr/sockaddr_utils.h b/src/core/iomgr/sockaddr_utils.h
index 6f7a279900..43dc7a45ec 100644
--- a/src/core/iomgr/sockaddr_utils.h
+++ b/src/core/iomgr/sockaddr_utils.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_UTILS_H
-#define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_UTILS_H
+#ifndef GRPC_CORE_IOMGR_SOCKADDR_UTILS_H
+#define GRPC_CORE_IOMGR_SOCKADDR_UTILS_H
#include "src/core/iomgr/sockaddr.h"
@@ -86,4 +86,4 @@ int grpc_sockaddr_to_string(char **out, const struct sockaddr *addr,
char *grpc_sockaddr_to_uri(const struct sockaddr *addr);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_UTILS_H */
+#endif /* GRPC_CORE_IOMGR_SOCKADDR_UTILS_H */
diff --git a/src/core/iomgr/sockaddr_win32.h b/src/core/iomgr/sockaddr_win32.h
index 8e3946a7d8..7acb8f7f57 100644
--- a/src/core/iomgr/sockaddr_win32.h
+++ b/src/core/iomgr/sockaddr_win32.h
@@ -31,11 +31,11 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H
-#define GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H
+#ifndef GRPC_CORE_IOMGR_SOCKADDR_WIN32_H
+#define GRPC_CORE_IOMGR_SOCKADDR_WIN32_H
#include <winsock2.h>
#include <ws2tcpip.h>
#include <mswsock.h>
-#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKADDR_WIN32_H */
+#endif /* GRPC_CORE_IOMGR_SOCKADDR_WIN32_H */
diff --git a/src/core/iomgr/socket_utils_posix.h b/src/core/iomgr/socket_utils_posix.h
index d330d1986e..b01e28b6f2 100644
--- a/src/core/iomgr/socket_utils_posix.h
+++ b/src/core/iomgr/socket_utils_posix.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKET_UTILS_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_SOCKET_UTILS_POSIX_H
+#ifndef GRPC_CORE_IOMGR_SOCKET_UTILS_POSIX_H
+#define GRPC_CORE_IOMGR_SOCKET_UTILS_POSIX_H
#include <unistd.h>
#include <sys/socket.h>
@@ -110,4 +110,4 @@ extern int grpc_forbid_dualstack_sockets_for_testing;
int grpc_create_dualstack_socket(const struct sockaddr *addr, int type,
int protocol, grpc_dualstack_mode *dsmode);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKET_UTILS_POSIX_H */
+#endif /* GRPC_CORE_IOMGR_SOCKET_UTILS_POSIX_H */
diff --git a/src/core/iomgr/socket_windows.h b/src/core/iomgr/socket_windows.h
index dfbfabe1f9..8e50e7a953 100644
--- a/src/core/iomgr/socket_windows.h
+++ b/src/core/iomgr/socket_windows.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H
-#define GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H
+#ifndef GRPC_CORE_IOMGR_SOCKET_WINDOWS_H
+#define GRPC_CORE_IOMGR_SOCKET_WINDOWS_H
#include <grpc/support/port_platform.h>
#include <winsock2.h>
@@ -108,4 +108,4 @@ void grpc_winsocket_shutdown(grpc_winsocket *socket);
/* Destroy a socket. Should only be called if there's no pending operation. */
void grpc_winsocket_destroy(grpc_winsocket *socket);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_SOCKET_WINDOWS_H */
+#endif /* GRPC_CORE_IOMGR_SOCKET_WINDOWS_H */
diff --git a/src/core/iomgr/tcp_client.h b/src/core/iomgr/tcp_client.h
index 5e18e71ca2..2e29833b70 100644
--- a/src/core/iomgr/tcp_client.h
+++ b/src/core/iomgr/tcp_client.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H
-#define GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H
+#ifndef GRPC_CORE_IOMGR_TCP_CLIENT_H
+#define GRPC_CORE_IOMGR_TCP_CLIENT_H
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/pollset_set.h"
@@ -50,4 +50,4 @@ void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_connect,
const struct sockaddr *addr, size_t addr_len,
gpr_timespec deadline);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_CLIENT_H */
+#endif /* GRPC_CORE_IOMGR_TCP_CLIENT_H */
diff --git a/src/core/iomgr/tcp_posix.h b/src/core/iomgr/tcp_posix.h
index 2a40cdd385..d846ec570f 100644
--- a/src/core/iomgr/tcp_posix.h
+++ b/src/core/iomgr/tcp_posix.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_TCP_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_TCP_POSIX_H
+#ifndef GRPC_CORE_IOMGR_TCP_POSIX_H
+#define GRPC_CORE_IOMGR_TCP_POSIX_H
/*
Low level TCP "bottom half" implementation, for use by transports built on
top of a TCP connection.
@@ -68,4 +68,4 @@ int grpc_tcp_fd(grpc_endpoint *ep);
void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
int *fd, grpc_closure *done);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_POSIX_H */
+#endif /* GRPC_CORE_IOMGR_TCP_POSIX_H */
diff --git a/src/core/iomgr/tcp_server.h b/src/core/iomgr/tcp_server.h
index a39dd3bafc..93247e9e4e 100644
--- a/src/core/iomgr/tcp_server.h
+++ b/src/core/iomgr/tcp_server.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_TCP_SERVER_H
-#define GRPC_INTERNAL_CORE_IOMGR_TCP_SERVER_H
+#ifndef GRPC_CORE_IOMGR_TCP_SERVER_H
+#define GRPC_CORE_IOMGR_TCP_SERVER_H
#include "src/core/iomgr/closure.h"
#include "src/core/iomgr/endpoint.h"
@@ -100,4 +100,4 @@ void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server *s,
a call (exec_ctx!=NULL) to shutdown_complete. */
void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_SERVER_H */
+#endif /* GRPC_CORE_IOMGR_TCP_SERVER_H */
diff --git a/src/core/iomgr/tcp_windows.h b/src/core/iomgr/tcp_windows.h
index deb3e48293..78bc13389a 100644
--- a/src/core/iomgr/tcp_windows.h
+++ b/src/core/iomgr/tcp_windows.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_TCP_WINDOWS_H
-#define GRPC_INTERNAL_CORE_IOMGR_TCP_WINDOWS_H
+#ifndef GRPC_CORE_IOMGR_TCP_WINDOWS_H
+#define GRPC_CORE_IOMGR_TCP_WINDOWS_H
/*
Low level TCP "bottom half" implementation, for use by transports built on
top of a TCP connection.
@@ -54,4 +54,4 @@ grpc_endpoint *grpc_tcp_create(grpc_winsocket *socket, char *peer_string);
int grpc_tcp_prepare_socket(SOCKET sock);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_TCP_WINDOWS_H */
+#endif /* GRPC_CORE_IOMGR_TCP_WINDOWS_H */
diff --git a/src/core/iomgr/time_averaged_stats.h b/src/core/iomgr/time_averaged_stats.h
index 4e9e3956c2..048e244bcc 100644
--- a/src/core/iomgr/time_averaged_stats.h
+++ b/src/core/iomgr/time_averaged_stats.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_TIME_AVERAGED_STATS_H
-#define GRPC_INTERNAL_CORE_IOMGR_TIME_AVERAGED_STATS_H
+#ifndef GRPC_CORE_IOMGR_TIME_AVERAGED_STATS_H
+#define GRPC_CORE_IOMGR_TIME_AVERAGED_STATS_H
/* This tracks a time-decaying weighted average. It works by collecting
batches of samples and then mixing their average into a time-decaying
@@ -85,4 +85,4 @@ void grpc_time_averaged_stats_add_sample(grpc_time_averaged_stats* stats,
value. */
double grpc_time_averaged_stats_update_average(grpc_time_averaged_stats* stats);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_TIME_AVERAGED_STATS_H */
+#endif /* GRPC_CORE_IOMGR_TIME_AVERAGED_STATS_H */
diff --git a/src/core/iomgr/timer.h b/src/core/iomgr/timer.h
index e239e884e7..63505df427 100644
--- a/src/core/iomgr/timer.h
+++ b/src/core/iomgr/timer.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_TIMER_H
-#define GRPC_INTERNAL_CORE_IOMGR_TIMER_H
+#ifndef GRPC_CORE_IOMGR_TIMER_H
+#define GRPC_CORE_IOMGR_TIMER_H
#include "src/core/iomgr/iomgr.h"
#include "src/core/iomgr/exec_ctx.h"
@@ -105,4 +105,4 @@ void grpc_timer_list_shutdown(grpc_exec_ctx *exec_ctx);
void grpc_kick_poller(void);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_TIMER_H */
+#endif /* GRPC_CORE_IOMGR_TIMER_H */
diff --git a/src/core/iomgr/timer_heap.h b/src/core/iomgr/timer_heap.h
index 2d220f1677..c2912ef45d 100644
--- a/src/core/iomgr/timer_heap.h
+++ b/src/core/iomgr/timer_heap.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_TIMER_HEAP_H
-#define GRPC_INTERNAL_CORE_IOMGR_TIMER_HEAP_H
+#ifndef GRPC_CORE_IOMGR_TIMER_HEAP_H
+#define GRPC_CORE_IOMGR_TIMER_HEAP_H
#include "src/core/iomgr/timer.h"
@@ -54,4 +54,4 @@ void grpc_timer_heap_pop(grpc_timer_heap *heap);
int grpc_timer_heap_is_empty(grpc_timer_heap *heap);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_TIMER_HEAP_H */
+#endif /* GRPC_CORE_IOMGR_TIMER_HEAP_H */
diff --git a/src/core/iomgr/udp_server.h b/src/core/iomgr/udp_server.h
index a9d0489edf..1e59a92392 100644
--- a/src/core/iomgr/udp_server.h
+++ b/src/core/iomgr/udp_server.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H
-#define GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H
+#ifndef GRPC_CORE_IOMGR_UDP_SERVER_H
+#define GRPC_CORE_IOMGR_UDP_SERVER_H
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/fd_posix.h"
@@ -73,4 +73,4 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server,
grpc_closure *on_done);
-#endif /* GRPC_INTERNAL_CORE_IOMGR_UDP_SERVER_H */
+#endif /* GRPC_CORE_IOMGR_UDP_SERVER_H */
diff --git a/src/core/iomgr/wakeup_fd_pipe.h b/src/core/iomgr/wakeup_fd_pipe.h
index 01a13a97c0..eb3e02b482 100644
--- a/src/core/iomgr/wakeup_fd_pipe.h
+++ b/src/core/iomgr/wakeup_fd_pipe.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,11 +31,11 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H
-#define GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H
+#ifndef GRPC_CORE_IOMGR_WAKEUP_FD_PIPE_H
+#define GRPC_CORE_IOMGR_WAKEUP_FD_PIPE_H
#include "src/core/iomgr/wakeup_fd_posix.h"
extern grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable;
-#endif /* GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_PIPE_H */
+#endif /* GRPC_CORE_IOMGR_WAKEUP_FD_PIPE_H */
diff --git a/src/core/iomgr/wakeup_fd_posix.h b/src/core/iomgr/wakeup_fd_posix.h
index ffd60d1d4e..d7e3cf4673 100644
--- a/src/core/iomgr/wakeup_fd_posix.h
+++ b/src/core/iomgr/wakeup_fd_posix.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -59,8 +59,8 @@
* 2. If the polling thread was awakened by a wakeup_fd event, call
* grpc_wakeup_fd_consume_wakeup() on it.
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_POSIX_H
+#ifndef GRPC_CORE_IOMGR_WAKEUP_FD_POSIX_H
+#define GRPC_CORE_IOMGR_WAKEUP_FD_POSIX_H
void grpc_wakeup_fd_global_init(void);
void grpc_wakeup_fd_global_destroy(void);
@@ -98,4 +98,4 @@ void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info);
* wakeup_fd_nospecial.c if no such implementation exists. */
extern const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable;
-#endif /* GRPC_INTERNAL_CORE_IOMGR_WAKEUP_FD_POSIX_H */
+#endif /* GRPC_CORE_IOMGR_WAKEUP_FD_POSIX_H */
diff --git a/src/core/iomgr/workqueue.h b/src/core/iomgr/workqueue.h
index 36dd133468..2ba1e5d9a2 100644
--- a/src/core/iomgr/workqueue.h
+++ b/src/core/iomgr/workqueue.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_WORKQUEUE_H
-#define GRPC_INTERNAL_CORE_IOMGR_WORKQUEUE_H
+#ifndef GRPC_CORE_IOMGR_WORKQUEUE_H
+#define GRPC_CORE_IOMGR_WORKQUEUE_H
#include "src/core/iomgr/iomgr.h"
#include "src/core/iomgr/pollset.h"
@@ -80,4 +80,4 @@ void grpc_workqueue_add_to_pollset(grpc_exec_ctx *exec_ctx,
void grpc_workqueue_push(grpc_workqueue *workqueue, grpc_closure *closure,
int success);
-#endif
+#endif /* GRPC_CORE_IOMGR_WORKQUEUE_H */
diff --git a/src/core/iomgr/workqueue_posix.h b/src/core/iomgr/workqueue_posix.h
index 68f195ee0d..89937b1ea8 100644
--- a/src/core/iomgr/workqueue_posix.h
+++ b/src/core/iomgr/workqueue_posix.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_WORKQUEUE_POSIX_H
-#define GRPC_INTERNAL_CORE_IOMGR_WORKQUEUE_POSIX_H
+#ifndef GRPC_CORE_IOMGR_WORKQUEUE_POSIX_H
+#define GRPC_CORE_IOMGR_WORKQUEUE_POSIX_H
#include "src/core/iomgr/wakeup_fd_posix.h"
@@ -50,4 +50,4 @@ struct grpc_workqueue {
grpc_closure read_closure;
};
-#endif /* GRPC_INTERNAL_CORE_IOMGR_WORKQUEUE_POSIX_H */
+#endif /* GRPC_CORE_IOMGR_WORKQUEUE_POSIX_H */
diff --git a/src/core/iomgr/workqueue_windows.h b/src/core/iomgr/workqueue_windows.h
index 941f195f51..7e8186921e 100644
--- a/src/core/iomgr/workqueue_windows.h
+++ b/src/core/iomgr/workqueue_windows.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,7 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_IOMGR_WORKQUEUE_WINDOWS_H
-#define GRPC_INTERNAL_CORE_IOMGR_WORKQUEUE_WINDOWS_H
+#ifndef GRPC_CORE_IOMGR_WORKQUEUE_WINDOWS_H
+#define GRPC_CORE_IOMGR_WORKQUEUE_WINDOWS_H
-#endif /* GRPC_INTERNAL_CORE_IOMGR_WORKQUEUE_WINDOWS_H */
+#endif /* GRPC_CORE_IOMGR_WORKQUEUE_WINDOWS_H */
diff --git a/src/core/json/json.h b/src/core/json/json.h
index c4df2998c3..aea9d5dadb 100644
--- a/src/core/json/json.h
+++ b/src/core/json/json.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_JSON_JSON_H
-#define GRPC_INTERNAL_CORE_JSON_JSON_H
+#ifndef GRPC_CORE_JSON_JSON_H
+#define GRPC_CORE_JSON_JSON_H
#include <stdlib.h>
@@ -85,4 +85,4 @@ char *grpc_json_dump_to_string(grpc_json *json, int indent);
grpc_json *grpc_json_create(grpc_json_type type);
void grpc_json_destroy(grpc_json *json);
-#endif /* GRPC_INTERNAL_CORE_JSON_JSON_H */
+#endif /* GRPC_CORE_JSON_JSON_H */
diff --git a/src/core/json/json_common.h b/src/core/json/json_common.h
index 481695b38b..7205a94685 100644
--- a/src/core/json/json_common.h
+++ b/src/core/json/json_common.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_JSON_JSON_COMMON_H
-#define GRPC_INTERNAL_CORE_JSON_JSON_COMMON_H
+#ifndef GRPC_CORE_JSON_JSON_COMMON_H
+#define GRPC_CORE_JSON_JSON_COMMON_H
/* The various json types. */
typedef enum {
@@ -46,4 +46,4 @@ typedef enum {
GRPC_JSON_TOP_LEVEL
} grpc_json_type;
-#endif /* GRPC_INTERNAL_CORE_JSON_JSON_COMMON_H */
+#endif /* GRPC_CORE_JSON_JSON_COMMON_H */
diff --git a/src/core/json/json_reader.h b/src/core/json/json_reader.h
index 90b9f1f9fe..f25f44b2ef 100644
--- a/src/core/json/json_reader.h
+++ b/src/core/json/json_reader.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_JSON_JSON_READER_H
-#define GRPC_INTERNAL_CORE_JSON_JSON_READER_H
+#ifndef GRPC_CORE_JSON_JSON_READER_H
+#define GRPC_CORE_JSON_JSON_READER_H
#include <grpc/support/port_platform.h>
#include "src/core/json/json_common.h"
@@ -157,4 +157,4 @@ void grpc_json_reader_init(grpc_json_reader *reader,
*/
int grpc_json_reader_is_complete(grpc_json_reader *reader);
-#endif /* GRPC_INTERNAL_CORE_JSON_JSON_READER_H */
+#endif /* GRPC_CORE_JSON_JSON_READER_H */
diff --git a/src/core/json/json_writer.h b/src/core/json/json_writer.h
index 9ef04aab01..c392126950 100644
--- a/src/core/json/json_writer.h
+++ b/src/core/json/json_writer.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -43,8 +43,8 @@
* a valid UTF-8 string overall.
*/
-#ifndef GRPC_INTERNAL_CORE_JSON_JSON_WRITER_H
-#define GRPC_INTERNAL_CORE_JSON_JSON_WRITER_H
+#ifndef GRPC_CORE_JSON_JSON_WRITER_H
+#define GRPC_CORE_JSON_JSON_WRITER_H
#include <stdlib.h>
@@ -94,4 +94,4 @@ void grpc_json_writer_value_raw_with_len(grpc_json_writer *writer,
void grpc_json_writer_value_string(grpc_json_writer *writer,
const char *string);
-#endif /* GRPC_INTERNAL_CORE_JSON_JSON_WRITER_H */
+#endif /* GRPC_CORE_JSON_JSON_WRITER_H */
diff --git a/src/core/security/auth_filters.h b/src/core/security/auth_filters.h
index c179b54bec..1154a1d914 100644
--- a/src/core/security/auth_filters.h
+++ b/src/core/security/auth_filters.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,12 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_AUTH_FILTERS_H
-#define GRPC_INTERNAL_CORE_SECURITY_AUTH_FILTERS_H
+#ifndef GRPC_CORE_SECURITY_AUTH_FILTERS_H
+#define GRPC_CORE_SECURITY_AUTH_FILTERS_H
#include "src/core/channel/channel_stack.h"
extern const grpc_channel_filter grpc_client_auth_filter;
extern const grpc_channel_filter grpc_server_auth_filter;
-#endif /* GRPC_INTERNAL_CORE_SECURITY_AUTH_FILTERS_H */
+#endif /* GRPC_CORE_SECURITY_AUTH_FILTERS_H */
diff --git a/src/core/security/b64.h b/src/core/security/b64.h
index 3e3b521120..d18f69563d 100644
--- a/src/core/security/b64.h
+++ b/src/core/security/b64.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_BASE64_H
-#define GRPC_INTERNAL_CORE_SECURITY_BASE64_H
+#ifndef GRPC_CORE_SECURITY_B64_H
+#define GRPC_CORE_SECURITY_B64_H
#include <grpc/support/slice.h>
@@ -49,4 +49,4 @@ gpr_slice grpc_base64_decode(const char *b64, int url_safe);
gpr_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len,
int url_safe);
-#endif /* GRPC_INTERNAL_CORE_SECURITY_BASE64_H */
+#endif /* GRPC_CORE_SECURITY_B64_H */
diff --git a/src/core/security/credentials.h b/src/core/security/credentials.h
index 0de4cd9468..133aa9d8d9 100644
--- a/src/core/security/credentials.h
+++ b/src/core/security/credentials.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_CREDENTIALS_H
-#define GRPC_INTERNAL_CORE_SECURITY_CREDENTIALS_H
+#ifndef GRPC_CORE_SECURITY_CREDENTIALS_H
+#define GRPC_CORE_SECURITY_CREDENTIALS_H
#include "src/core/transport/metadata_batch.h"
#include <grpc/grpc.h>
@@ -373,4 +373,4 @@ typedef struct {
grpc_credentials_md_store *plugin_md;
} grpc_plugin_credentials;
-#endif /* GRPC_INTERNAL_CORE_SECURITY_CREDENTIALS_H */
+#endif /* GRPC_CORE_SECURITY_CREDENTIALS_H */
diff --git a/src/core/security/handshake.h b/src/core/security/handshake.h
index db8b374921..4872045874 100644
--- a/src/core/security/handshake.h
+++ b/src/core/security/handshake.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_HANDSHAKE_H
-#define GRPC_INTERNAL_CORE_SECURITY_HANDSHAKE_H
+#ifndef GRPC_CORE_SECURITY_HANDSHAKE_H
+#define GRPC_CORE_SECURITY_HANDSHAKE_H
#include "src/core/iomgr/endpoint.h"
#include "src/core/security/security_connector.h"
@@ -48,4 +48,4 @@ void grpc_do_security_handshake(grpc_exec_ctx *exec_ctx,
void grpc_security_handshake_shutdown(grpc_exec_ctx *exec_ctx, void *handshake);
-#endif /* GRPC_INTERNAL_CORE_SECURITY_HANDSHAKE_H */
+#endif /* GRPC_CORE_SECURITY_HANDSHAKE_H */
diff --git a/src/core/security/json_token.h b/src/core/security/json_token.h
index 7e06864ff3..d183f9b3a3 100644
--- a/src/core/security/json_token.h
+++ b/src/core/security/json_token.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_JSON_TOKEN_H
-#define GRPC_INTERNAL_CORE_SECURITY_JSON_TOKEN_H
+#ifndef GRPC_CORE_SECURITY_JSON_TOKEN_H
+#define GRPC_CORE_SECURITY_JSON_TOKEN_H
#include <grpc/support/slice.h>
#include <openssl/rsa.h>
@@ -115,4 +115,4 @@ grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json(
/* Destructs the object. */
void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token *refresh_token);
-#endif /* GRPC_INTERNAL_CORE_SECURITY_JSON_TOKEN_H */
+#endif /* GRPC_CORE_SECURITY_JSON_TOKEN_H */
diff --git a/src/core/security/jwt_verifier.h b/src/core/security/jwt_verifier.h
index 25613f03a0..d898d2193f 100644
--- a/src/core/security/jwt_verifier.h
+++ b/src/core/security/jwt_verifier.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_JWT_VERIFIER_H
-#define GRPC_INTERNAL_CORE_SECURITY_JWT_VERIFIER_H
+#ifndef GRPC_CORE_SECURITY_JWT_VERIFIER_H
+#define GRPC_CORE_SECURITY_JWT_VERIFIER_H
#include "src/core/iomgr/pollset.h"
#include "src/core/json/json.h"
@@ -133,4 +133,4 @@ grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_json *json, gpr_slice buffer);
grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims *claims,
const char *audience);
-#endif /* GRPC_INTERNAL_CORE_SECURITY_JWT_VERIFIER_H */
+#endif /* GRPC_CORE_SECURITY_JWT_VERIFIER_H */
diff --git a/src/core/security/secure_endpoint.h b/src/core/security/secure_endpoint.h
index c563bdd9c5..5176ef2059 100644
--- a/src/core/security/secure_endpoint.h
+++ b/src/core/security/secure_endpoint.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_SECURE_ENDPOINT_H
-#define GRPC_INTERNAL_CORE_SECURITY_SECURE_ENDPOINT_H
+#ifndef GRPC_CORE_SECURITY_SECURE_ENDPOINT_H
+#define GRPC_CORE_SECURITY_SECURE_ENDPOINT_H
#include "src/core/iomgr/endpoint.h"
#include <grpc/support/slice.h>
@@ -46,4 +46,4 @@ grpc_endpoint *grpc_secure_endpoint_create(
struct tsi_frame_protector *protector, grpc_endpoint *to_wrap,
gpr_slice *leftover_slices, size_t leftover_nslices);
-#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURE_ENDPOINT_H */
+#endif /* GRPC_CORE_SECURITY_SECURE_ENDPOINT_H */
diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c
index 33c62a20c2..fbec263eed 100644
--- a/src/core/security/security_connector.c
+++ b/src/core/security/security_connector.c
@@ -492,6 +492,9 @@ grpc_auth_context *tsi_ssl_peer_to_auth_context(const tsi_peer *peer) {
peer_identity_property_name = GRPC_X509_SAN_PROPERTY_NAME;
grpc_auth_context_add_property(ctx, GRPC_X509_SAN_PROPERTY_NAME,
prop->value.data, prop->value.length);
+ } else if (strcmp(prop->name, TSI_X509_PEM_CERT_PROPERTY) == 0) {
+ grpc_auth_context_add_property(ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME,
+ prop->value.data, prop->value.length);
}
}
if (peer_identity_property_name != NULL) {
@@ -554,9 +557,9 @@ static void ssl_server_check_peer(grpc_exec_ctx *exec_ctx,
grpc_auth_context_unref(auth_context);
}
-static void add_shalow_auth_property_to_peer(tsi_peer *peer,
- const grpc_auth_property *prop,
- const char *tsi_prop_name) {
+static void add_shallow_auth_property_to_peer(tsi_peer *peer,
+ const grpc_auth_property *prop,
+ const char *tsi_prop_name) {
tsi_peer_property *tsi_prop = &peer->properties[peer->property_count++];
tsi_prop->name = (char *)tsi_prop_name;
tsi_prop->value.data = prop->value;
@@ -579,11 +582,14 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context(
it = grpc_auth_context_property_iterator(auth_context);
while ((prop = grpc_auth_property_iterator_next(&it)) != NULL) {
if (strcmp(prop->name, GRPC_X509_SAN_PROPERTY_NAME) == 0) {
- add_shalow_auth_property_to_peer(
+ add_shallow_auth_property_to_peer(
&peer, prop, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY);
} else if (strcmp(prop->name, GRPC_X509_CN_PROPERTY_NAME) == 0) {
- add_shalow_auth_property_to_peer(
+ add_shallow_auth_property_to_peer(
&peer, prop, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY);
+ } else if (strcmp(prop->name, GRPC_X509_PEM_CERT_PROPERTY_NAME) == 0) {
+ add_shallow_auth_property_to_peer(&peer, prop,
+ TSI_X509_PEM_CERT_PROPERTY);
}
}
}
diff --git a/src/core/security/security_connector.h b/src/core/security/security_connector.h
index 1e35d3f9b7..6f915ebb9d 100644
--- a/src/core/security/security_connector.h
+++ b/src/core/security/security_connector.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONNECTOR_H
-#define GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONNECTOR_H
+#ifndef GRPC_CORE_SECURITY_SECURITY_CONNECTOR_H
+#define GRPC_CORE_SECURITY_SECURITY_CONNECTOR_H
#include <grpc/grpc_security.h>
#include "src/core/iomgr/endpoint.h"
@@ -263,4 +263,4 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context(
const grpc_auth_context *auth_context);
void tsi_shallow_peer_destruct(tsi_peer *peer);
-#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONNECTOR_H */
+#endif /* GRPC_CORE_SECURITY_SECURITY_CONNECTOR_H */
diff --git a/src/core/security/security_context.h b/src/core/security/security_context.h
index 794258edbc..61601f538b 100644
--- a/src/core/security/security_context.h
+++ b/src/core/security/security_context.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H
-#define GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H
+#ifndef GRPC_CORE_SECURITY_SECURITY_CONTEXT_H
+#define GRPC_CORE_SECURITY_SECURITY_CONTEXT_H
#include "src/core/iomgr/pollset.h"
#include "src/core/security/credentials.h"
@@ -111,4 +111,4 @@ grpc_auth_context *grpc_auth_context_from_arg(const grpc_arg *arg);
grpc_auth_context *grpc_find_auth_context_in_args(
const grpc_channel_args *args);
-#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */
+#endif /* GRPC_CORE_SECURITY_SECURITY_CONTEXT_H */
diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c
index 91547eb26e..009ec95682 100644
--- a/src/core/security/server_secure_chttp2.c
+++ b/src/core/security/server_secure_chttp2.c
@@ -83,8 +83,6 @@ static void state_unref(grpc_server_secure_state *state) {
static void setup_transport(grpc_exec_ctx *exec_ctx, void *statep,
grpc_transport *transport,
grpc_auth_context *auth_context) {
- static grpc_channel_filter const *extra_filters[] = {
- &grpc_server_auth_filter, &grpc_http_server_filter};
grpc_server_secure_state *state = statep;
grpc_channel_args *args_copy;
grpc_arg args_to_add[2];
@@ -93,8 +91,7 @@ static void setup_transport(grpc_exec_ctx *exec_ctx, void *statep,
args_copy = grpc_channel_args_copy_and_add(
grpc_server_get_channel_args(state->server), args_to_add,
GPR_ARRAY_SIZE(args_to_add));
- grpc_server_setup_transport(exec_ctx, state->server, transport, extra_filters,
- GPR_ARRAY_SIZE(extra_filters), args_copy);
+ grpc_server_setup_transport(exec_ctx, state->server, transport, args_copy);
grpc_channel_args_destroy(args_copy);
}
diff --git a/src/core/statistics/census_interface.h b/src/core/statistics/census_interface.h
index c43acbd317..ce8ff92cd4 100644
--- a/src/core/statistics/census_interface.h
+++ b/src/core/statistics/census_interface.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H
-#define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H
+#ifndef GRPC_CORE_STATISTICS_CENSUS_INTERFACE_H
+#define GRPC_CORE_STATISTICS_CENSUS_INTERFACE_H
#include <grpc/support/port_platform.h>
@@ -73,4 +73,4 @@ census_op_id census_tracing_start_op(void);
/* Ends tracing. Calling this function will invalidate the input op_id. */
void census_tracing_end_op(census_op_id op_id);
-#endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_INTERFACE_H */
+#endif /* GRPC_CORE_STATISTICS_CENSUS_INTERFACE_H */
diff --git a/src/core/statistics/census_log.h b/src/core/statistics/census_log.h
index 356437c346..e7ce0d4433 100644
--- a/src/core/statistics/census_log.h
+++ b/src/core/statistics/census_log.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H
-#define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H
+#ifndef GRPC_CORE_STATISTICS_CENSUS_LOG_H
+#define GRPC_CORE_STATISTICS_CENSUS_LOG_H
#include <stddef.h>
@@ -88,4 +88,4 @@ size_t census_log_remaining_space(void);
out-of-space. */
int census_log_out_of_space_count(void);
-#endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_LOG_H */
+#endif /* GRPC_CORE_STATISTICS_CENSUS_LOG_H */
diff --git a/src/core/statistics/census_rpc_stats.h b/src/core/statistics/census_rpc_stats.h
index 8bdbc49490..4cf17d2e52 100644
--- a/src/core/statistics/census_rpc_stats.h
+++ b/src/core/statistics/census_rpc_stats.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H
-#define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H
+#ifndef GRPC_CORE_STATISTICS_CENSUS_RPC_STATS_H
+#define GRPC_CORE_STATISTICS_CENSUS_RPC_STATS_H
#include "src/core/statistics/census_interface.h"
#include <grpc/support/port_platform.h>
@@ -98,4 +98,4 @@ void census_stats_store_shutdown(void);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_RPC_STATS_H */
+#endif /* GRPC_CORE_STATISTICS_CENSUS_RPC_STATS_H */
diff --git a/src/core/statistics/census_tracing.h b/src/core/statistics/census_tracing.h
index bb3f2556d2..b611e95bf4 100644
--- a/src/core/statistics/census_tracing.h
+++ b/src/core/statistics/census_tracing.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_STATISTICS_CENSUS_TRACING_H
-#define GRPC_INTERNAL_CORE_STATISTICS_CENSUS_TRACING_H
+#ifndef GRPC_CORE_STATISTICS_CENSUS_TRACING_H
+#define GRPC_CORE_STATISTICS_CENSUS_TRACING_H
#include <grpc/support/time.h>
#include "src/core/statistics/census_rpc_stats.h"
@@ -93,4 +93,4 @@ census_trace_obj **census_get_active_ops(int *num_active_ops);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_STATISTICS_CENSUS_TRACING_H */
+#endif /* GRPC_CORE_STATISTICS_CENSUS_TRACING_H */
diff --git a/src/core/statistics/hash_table.h b/src/core/statistics/hash_table.h
index d9860a909f..f4bf2ba49a 100644
--- a/src/core/statistics/hash_table.h
+++ b/src/core/statistics/hash_table.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_STATISTICS_HASH_TABLE_H
-#define GRPC_INTERNAL_CORE_STATISTICS_HASH_TABLE_H
+#ifndef GRPC_CORE_STATISTICS_HASH_TABLE_H
+#define GRPC_CORE_STATISTICS_HASH_TABLE_H
#include <stddef.h>
@@ -128,4 +128,4 @@ typedef void (*census_ht_itr_cb)(census_ht_key key, const void *val_ptr,
should not invalidate data entries. */
uint64_t census_ht_for_all(const census_ht *ht, census_ht_itr_cb);
-#endif /* GRPC_INTERNAL_CORE_STATISTICS_HASH_TABLE_H */
+#endif /* GRPC_CORE_STATISTICS_HASH_TABLE_H */
diff --git a/src/core/statistics/window_stats.h b/src/core/statistics/window_stats.h
index f4732e96a0..774277180f 100644
--- a/src/core/statistics/window_stats.h
+++ b/src/core/statistics/window_stats.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_STATISTICS_WINDOW_STATS_H
-#define GRPC_INTERNAL_CORE_STATISTICS_WINDOW_STATS_H
+#ifndef GRPC_CORE_STATISTICS_WINDOW_STATS_H
+#define GRPC_CORE_STATISTICS_WINDOW_STATS_H
#include <grpc/support/time.h>
@@ -170,4 +170,4 @@ void census_window_stats_get_sums(const struct census_window_stats *wstats,
assertion failure). This function is thread-compatible. */
void census_window_stats_destroy(struct census_window_stats *wstats);
-#endif /* GRPC_INTERNAL_CORE_STATISTICS_WINDOW_STATS_H */
+#endif /* GRPC_CORE_STATISTICS_WINDOW_STATS_H */
diff --git a/src/core/support/backoff.h b/src/core/support/backoff.h
index 3234aa214d..f7730fde2a 100644
--- a/src/core/support/backoff.h
+++ b/src/core/support/backoff.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_BACKOFF_H
-#define GRPC_INTERNAL_CORE_SUPPORT_BACKOFF_H
+#ifndef GRPC_CORE_SUPPORT_BACKOFF_H
+#define GRPC_CORE_SUPPORT_BACKOFF_H
#include <grpc/support/time.h>
@@ -62,4 +62,4 @@ gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now);
/// Step a retry loop: returns a timespec for the NEXT retry
gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now);
-#endif // GRPC_INTERNAL_CORE_SUPPORT_BACKOFF_H
+#endif /* GRPC_CORE_SUPPORT_BACKOFF_H */
diff --git a/src/core/support/block_annotate.h b/src/core/support/block_annotate.h
index 3cd8eee272..79a18039f4 100644
--- a/src/core/support/block_annotate.h
+++ b/src/core/support/block_annotate.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H
-#define GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H
+#ifndef GRPC_CORE_SUPPORT_BLOCK_ANNOTATE_H
+#define GRPC_CORE_SUPPORT_BLOCK_ANNOTATE_H
/* These annotations identify the beginning and end of regions where
the code may block for reasons other than synchronization functions.
@@ -45,4 +45,4 @@
do { \
} while (0)
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H */
+#endif /* GRPC_CORE_SUPPORT_BLOCK_ANNOTATE_H */
diff --git a/src/core/support/env.h b/src/core/support/env.h
index 24172d8673..2902456947 100644
--- a/src/core/support/env.h
+++ b/src/core/support/env.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_ENV_H
-#define GRPC_INTERNAL_CORE_SUPPORT_ENV_H
+#ifndef GRPC_CORE_SUPPORT_ENV_H
+#define GRPC_CORE_SUPPORT_ENV_H
#include <stdio.h>
@@ -57,4 +57,4 @@ void gpr_setenv(const char *name, const char *value);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_ENV_H */
+#endif /* GRPC_CORE_SUPPORT_ENV_H */
diff --git a/src/core/support/load_file.h b/src/core/support/load_file.h
index 746319a50d..5896654e9a 100644
--- a/src/core/support/load_file.h
+++ b/src/core/support/load_file.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_LOAD_FILE_H
-#define GRPC_INTERNAL_CORE_SUPPORT_LOAD_FILE_H
+#ifndef GRPC_CORE_SUPPORT_LOAD_FILE_H
+#define GRPC_CORE_SUPPORT_LOAD_FILE_H
#include <stdio.h>
@@ -52,4 +52,4 @@ gpr_slice gpr_load_file(const char *filename, int add_null_terminator,
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_LOAD_FILE_H */
+#endif /* GRPC_CORE_SUPPORT_LOAD_FILE_H */
diff --git a/src/core/support/murmur_hash.h b/src/core/support/murmur_hash.h
index 0bf04f731a..0f0b399e5d 100644
--- a/src/core/support/murmur_hash.h
+++ b/src/core/support/murmur_hash.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H
-#define GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H
+#ifndef GRPC_CORE_SUPPORT_MURMUR_HASH_H
+#define GRPC_CORE_SUPPORT_MURMUR_HASH_H
#include <grpc/support/port_platform.h>
@@ -41,4 +41,4 @@
/* compute the hash of key (length len) */
uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed);
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_MURMUR_HASH_H */
+#endif /* GRPC_CORE_SUPPORT_MURMUR_HASH_H */
diff --git a/src/core/support/stack_lockfree.h b/src/core/support/stack_lockfree.h
index ca58dd007a..d6fd06d67c 100644
--- a/src/core/support/stack_lockfree.h
+++ b/src/core/support/stack_lockfree.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H
-#define GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H
+#ifndef GRPC_CORE_SUPPORT_STACK_LOCKFREE_H
+#define GRPC_CORE_SUPPORT_STACK_LOCKFREE_H
#include <stddef.h>
@@ -50,4 +50,4 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *, int entry);
/* Returns -1 on empty or the actual entry number */
int gpr_stack_lockfree_pop(gpr_stack_lockfree *stack);
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H */
+#endif /* GRPC_CORE_SUPPORT_STACK_LOCKFREE_H */
diff --git a/src/core/support/string.h b/src/core/support/string.h
index e6755de106..a367ed7cd8 100644
--- a/src/core/support/string.h
+++ b/src/core/support/string.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_STRING_H
-#define GRPC_INTERNAL_CORE_SUPPORT_STRING_H
+#ifndef GRPC_CORE_SUPPORT_STRING_H
+#define GRPC_CORE_SUPPORT_STRING_H
#include <stddef.h>
@@ -118,4 +118,4 @@ char *gpr_strvec_flatten(gpr_strvec *strs, size_t *total_length);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_STRING_H */
+#endif /* GRPC_CORE_SUPPORT_STRING_H */
diff --git a/src/core/support/string_win32.h b/src/core/support/string_win32.h
index e3043656fb..c9ae8d9932 100644
--- a/src/core/support/string_win32.h
+++ b/src/core/support/string_win32.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_STRING_WIN32_H
-#define GRPC_INTERNAL_CORE_SUPPORT_STRING_WIN32_H
+#ifndef GRPC_CORE_SUPPORT_STRING_WIN32_H
+#define GRPC_CORE_SUPPORT_STRING_WIN32_H
#include <grpc/support/port_platform.h>
@@ -44,4 +44,4 @@ LPSTR gpr_tchar_to_char(LPCTSTR input);
#endif /* GPR_WIN32 */
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_STRING_WIN32_H */
+#endif /* GRPC_CORE_SUPPORT_STRING_WIN32_H */
diff --git a/src/core/support/thd_internal.h b/src/core/support/thd_internal.h
index 1508c4691f..33b904e59b 100644
--- a/src/core/support/thd_internal.h
+++ b/src/core/support/thd_internal.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,9 +31,9 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_THD_INTERNAL_H
-#define GRPC_INTERNAL_CORE_SUPPORT_THD_INTERNAL_H
+#ifndef GRPC_CORE_SUPPORT_THD_INTERNAL_H
+#define GRPC_CORE_SUPPORT_THD_INTERNAL_H
/* Internal interfaces between modules within the gpr support library. */
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_THD_INTERNAL_H */
+#endif /* GRPC_CORE_SUPPORT_THD_INTERNAL_H */
diff --git a/src/core/support/time_precise.h b/src/core/support/time_precise.h
index 80c5000123..871c99a623 100644
--- a/src/core/support/time_precise.h
+++ b/src/core/support/time_precise.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,12 @@
*
*/
-#ifndef GRPC_CORE_SUPPORT_TIME_PRECISE_H_
-#define GRPC_CORE_SUPPORT_TIME_PRECISE_H_
+#ifndef GRPC_CORE_SUPPORT_TIME_PRECISE_H
+#define GRPC_CORE_SUPPORT_TIME_PRECISE_H
#include <grpc/support/time.h>
void gpr_precise_clock_init(void);
void gpr_precise_clock_now(gpr_timespec *clk);
-#endif /* GRPC_CORE_SUPPORT_TIME_PRECISE_ */
+#endif /* GRPC_CORE_SUPPORT_TIME_PRECISE_H */
diff --git a/src/core/support/tmpfile.h b/src/core/support/tmpfile.h
index cecc71e242..df6f8692bb 100644
--- a/src/core/support/tmpfile.h
+++ b/src/core/support/tmpfile.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SUPPORT_TMPFILE_H
-#define GRPC_INTERNAL_CORE_SUPPORT_TMPFILE_H
+#ifndef GRPC_CORE_SUPPORT_TMPFILE_H
+#define GRPC_CORE_SUPPORT_TMPFILE_H
#include <stdio.h>
@@ -52,4 +52,4 @@ FILE *gpr_tmpfile(const char *prefix, char **tmp_filename);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SUPPORT_TMPFILE_H */
+#endif /* GRPC_CORE_SUPPORT_TMPFILE_H */
diff --git a/src/core/surface/api_trace.h b/src/core/surface/api_trace.h
index 82bbf3b62b..29a9b2d79c 100644
--- a/src/core/surface/api_trace.h
+++ b/src/core/surface/api_trace.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_API_TRACE_H
-#define GRPC_INTERNAL_CORE_SURFACE_API_TRACE_H
+#ifndef GRPC_CORE_SURFACE_API_TRACE_H
+#define GRPC_CORE_SURFACE_API_TRACE_H
#include "src/core/debug/trace.h"
#include <grpc/support/log.h>
@@ -62,4 +62,4 @@ extern int grpc_api_trace;
gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \
}
-#endif /* GRPC_INTERNAL_CORE_SURFACE_API_TRACE_H */
+#endif /* GRPC_CORE_SURFACE_API_TRACE_H */
diff --git a/src/core/surface/call.c b/src/core/surface/call.c
index 1b117aa6b8..6f1cd1df10 100644
--- a/src/core/surface/call.c
+++ b/src/core/surface/call.c
@@ -1481,3 +1481,11 @@ void *grpc_call_context_get(grpc_call *call, grpc_context_index elem) {
}
uint8_t grpc_call_is_client(grpc_call *call) { return call->is_client; }
+
+grpc_compression_algorithm grpc_call_compression_for_level(
+ grpc_call *call, grpc_compression_level level) {
+ gpr_mu_lock(&call->mu);
+ const uint32_t accepted_encodings = call->encodings_accepted_by_peer;
+ gpr_mu_unlock(&call->mu);
+ return grpc_compression_algorithm_for_level(level, accepted_encodings);
+}
diff --git a/src/core/surface/call.h b/src/core/surface/call.h
index 0bbffb98ae..d2edf03d45 100644
--- a/src/core/surface/call.h
+++ b/src/core/surface/call.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,14 +31,16 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_CALL_H
-#define GRPC_INTERNAL_CORE_SURFACE_CALL_H
+#ifndef GRPC_CORE_SURFACE_CALL_H
+#define GRPC_CORE_SURFACE_CALL_H
#include "src/core/channel/channel_stack.h"
#include "src/core/channel/context.h"
#include "src/core/surface/api_trace.h"
#include "src/core/surface/surface_trace.h"
+
#include <grpc/grpc.h>
+#include <grpc/impl/codegen/compression_types.h>
#ifdef __cplusplus
extern "C" {
@@ -102,8 +104,13 @@ void *grpc_call_context_get(grpc_call *call, grpc_context_index elem);
uint8_t grpc_call_is_client(grpc_call *call);
+/* Return an appropriate compression algorithm for the requested compression \a
+ * level in the context of \a call. */
+grpc_compression_algorithm grpc_call_compression_for_level(
+ grpc_call *call, grpc_compression_level level);
+
#ifdef __cplusplus
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_H */
+#endif /* GRPC_CORE_SURFACE_CALL_H */
diff --git a/src/core/surface/call_test_only.h b/src/core/surface/call_test_only.h
index b57c95c64a..fdc43a383b 100644
--- a/src/core/surface/call_test_only.h
+++ b/src/core/surface/call_test_only.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_CALL_TEST_ONLY_H
-#define GRPC_INTERNAL_CORE_SURFACE_CALL_TEST_ONLY_H
+#ifndef GRPC_CORE_SURFACE_CALL_TEST_ONLY_H
+#define GRPC_CORE_SURFACE_CALL_TEST_ONLY_H
#include <grpc/grpc.h>
@@ -61,4 +61,4 @@ uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call *call);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_TEST_ONLY_H */
+#endif /* GRPC_CORE_SURFACE_CALL_TEST_ONLY_H */
diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c
index 12d8ebceb9..964ab34431 100644
--- a/src/core/surface/channel.c
+++ b/src/core/surface/channel.c
@@ -40,6 +40,7 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
+#include "src/core/surface/channel_init.h"
#include "src/core/client_config/resolver_registry.h"
#include "src/core/iomgr/iomgr.h"
#include "src/core/support/string.h"
@@ -82,24 +83,25 @@ struct grpc_channel {
static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg, bool success);
-grpc_channel *grpc_channel_create_from_filters(
- grpc_exec_ctx *exec_ctx, const char *target,
- const grpc_channel_filter **filters, size_t num_filters,
- const grpc_channel_args *args, int is_client) {
- size_t i;
- size_t size =
- sizeof(grpc_channel) + grpc_channel_stack_size(filters, num_filters);
- grpc_channel *channel = gpr_malloc(size);
+grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
+ const grpc_channel_args *args,
+ grpc_channel_stack_type channel_stack_type,
+ grpc_transport *optional_transport) {
+ bool is_client = grpc_channel_stack_type_is_client(channel_stack_type);
+
+ grpc_channel *channel = grpc_channel_init_create_stack(
+ exec_ctx, channel_stack_type, sizeof(grpc_channel), args, 1,
+ destroy_channel, NULL, optional_transport);
+
memset(channel, 0, sizeof(*channel));
channel->target = gpr_strdup(target);
- GPR_ASSERT(grpc_is_initialized() && "call grpc_init()");
channel->is_client = is_client;
gpr_mu_init(&channel->registered_call_mu);
channel->registered_calls = NULL;
channel->max_message_length = DEFAULT_MAX_MESSAGE_LENGTH;
if (args) {
- for (i = 0; i < args->num_args; i++) {
+ for (size_t i = 0; i < args->num_args; i++) {
if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_MESSAGE_LENGTH)) {
if (args->args[i].type != GRPC_ARG_INTEGER) {
gpr_log(GPR_ERROR, "%s ignored: it must be an integer",
@@ -152,11 +154,6 @@ grpc_channel *grpc_channel_create_from_filters(
gpr_free(default_authority);
}
- grpc_channel_stack_init(exec_ctx, 1, destroy_channel, channel, filters,
- num_filters, args,
- is_client ? "CLIENT_CHANNEL" : "SERVER_CHANNEL",
- CHANNEL_STACK_FROM_CHANNEL(channel));
-
return channel;
}
diff --git a/src/core/surface/channel.h b/src/core/surface/channel.h
index 00240c637f..c08988d9e7 100644
--- a/src/core/surface/channel.h
+++ b/src/core/surface/channel.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,16 +31,17 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_CHANNEL_H
-#define GRPC_INTERNAL_CORE_SURFACE_CHANNEL_H
+#ifndef GRPC_CORE_SURFACE_CHANNEL_H
+#define GRPC_CORE_SURFACE_CHANNEL_H
#include "src/core/channel/channel_stack.h"
+#include "src/core/surface/channel_stack_type.h"
#include "src/core/client_config/subchannel_factory.h"
-grpc_channel *grpc_channel_create_from_filters(
- grpc_exec_ctx *exec_ctx, const char *target,
- const grpc_channel_filter **filters, size_t count,
- const grpc_channel_args *args, int is_client);
+grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
+ const grpc_channel_args *args,
+ grpc_channel_stack_type channel_stack_type,
+ grpc_transport *optional_transport);
/** Get a (borrowed) pointer to this channels underlying channel stack */
grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel);
@@ -71,4 +72,4 @@ void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx,
grpc_channel_internal_unref(exec_ctx, channel)
#endif
-#endif /* GRPC_INTERNAL_CORE_SURFACE_CHANNEL_H */
+#endif /* GRPC_CORE_SURFACE_CHANNEL_H */
diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c
index fd7e20e9cc..123447c8ed 100644
--- a/src/core/surface/channel_create.c
+++ b/src/core/surface/channel_create.c
@@ -105,9 +105,6 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
0);
GPR_ASSERT(c->result->transport);
c->result->channel_args = c->args.channel_args;
- c->result->filters = gpr_malloc(sizeof(grpc_channel_filter *));
- c->result->filters[0] = &grpc_http_client_filter;
- c->result->num_filters = 1;
} else {
memset(c->result, 0, sizeof(*c->result));
}
@@ -190,25 +187,16 @@ grpc_channel *grpc_insecure_channel_create(const char *target,
const grpc_channel_args *args,
void *reserved) {
grpc_channel *channel = NULL;
-#define MAX_FILTERS 3
- const grpc_channel_filter *filters[MAX_FILTERS];
grpc_resolver *resolver;
subchannel_factory *f;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- size_t n = 0;
GRPC_API_TRACE(
"grpc_insecure_channel_create(target=%p, args=%p, reserved=%p)", 3,
(target, args, reserved));
GPR_ASSERT(!reserved);
- if (grpc_channel_args_is_census_enabled(args)) {
- filters[n++] = &grpc_client_census_filter;
- }
- filters[n++] = &grpc_compress_filter;
- filters[n++] = &grpc_client_channel_filter;
- GPR_ASSERT(n <= MAX_FILTERS);
channel =
- grpc_channel_create_from_filters(&exec_ctx, target, filters, n, args, 1);
+ grpc_channel_create(&exec_ctx, target, args, GRPC_CLIENT_CHANNEL, NULL);
f = gpr_malloc(sizeof(*f));
f->base.vtable = &subchannel_factory_vtable;
diff --git a/src/core/surface/channel_init.c b/src/core/surface/channel_init.c
new file mode 100644
index 0000000000..538be84696
--- /dev/null
+++ b/src/core/surface/channel_init.c
@@ -0,0 +1,148 @@
+/*
+ *
+ * Copyright 2016, 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.
+ *
+ */
+
+#include "src/core/surface/channel_init.h"
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/useful.h>
+
+typedef struct stage_slot {
+ grpc_channel_init_stage fn;
+ void *arg;
+ int priority;
+ size_t insertion_order;
+} stage_slot;
+
+typedef struct stage_slots {
+ stage_slot *slots;
+ size_t num_slots;
+ size_t cap_slots;
+} stage_slots;
+
+static stage_slots g_slots[GRPC_NUM_CHANNEL_STACK_TYPES];
+static bool g_finalized;
+
+void grpc_channel_init_init(void) {
+ for (int i = 0; i < GRPC_NUM_CHANNEL_STACK_TYPES; i++) {
+ g_slots[i].slots = NULL;
+ g_slots[i].num_slots = 0;
+ g_slots[i].cap_slots = 0;
+ }
+ g_finalized = false;
+}
+
+void grpc_channel_init_register_stage(grpc_channel_stack_type type,
+ int priority,
+ grpc_channel_init_stage stage,
+ void *stage_arg) {
+ GPR_ASSERT(!g_finalized);
+ if (g_slots[type].cap_slots == g_slots[type].num_slots) {
+ g_slots[type].cap_slots = GPR_MAX(8, 3 * g_slots[type].cap_slots / 2);
+ g_slots[type].slots =
+ gpr_realloc(g_slots[type].slots,
+ g_slots[type].cap_slots * sizeof(*g_slots[type].slots));
+ }
+ stage_slot *s = &g_slots[type].slots[g_slots[type].num_slots++];
+ s->insertion_order = g_slots[type].num_slots;
+ s->priority = priority;
+ s->fn = stage;
+ s->arg = stage_arg;
+}
+
+static int compare_slots(const void *a, const void *b) {
+ const stage_slot *sa = a;
+ const stage_slot *sb = b;
+
+ int c = GPR_ICMP(sa->priority, sb->priority);
+ if (c != 0) return c;
+ return GPR_ICMP(sa->insertion_order, sb->insertion_order);
+}
+
+void grpc_channel_init_finalize(void) {
+ GPR_ASSERT(!g_finalized);
+ for (int i = 0; i < GRPC_NUM_CHANNEL_STACK_TYPES; i++) {
+ qsort(g_slots[i].slots, g_slots[i].num_slots, sizeof(*g_slots[i].slots),
+ compare_slots);
+ }
+ g_finalized = true;
+}
+
+void grpc_channel_init_shutdown(void) {
+ for (int i = 0; i < GRPC_NUM_CHANNEL_STACK_TYPES; i++) {
+ gpr_free(g_slots[i].slots);
+ g_slots[i].slots = (void *)(uintptr_t)0xdeadbeef;
+ }
+}
+
+static const char *name_for_type(grpc_channel_stack_type type) {
+ switch (type) {
+ case GRPC_CLIENT_CHANNEL:
+ return "CLIENT_CHANNEL";
+ case GRPC_CLIENT_SUBCHANNEL:
+ return "CLIENT_SUBCHANNEL";
+ case GRPC_SERVER_CHANNEL:
+ return "SERVER_CHANNEL";
+ case GRPC_CLIENT_UCHANNEL:
+ return "CLIENT_UCHANNEL";
+ case GRPC_CLIENT_LAME_CHANNEL:
+ return "CLIENT_LAME_CHANNEL";
+ case GRPC_CLIENT_DIRECT_CHANNEL:
+ return "CLIENT_DIRECT_CHANNEL";
+ case GRPC_NUM_CHANNEL_STACK_TYPES:
+ break;
+ }
+ GPR_UNREACHABLE_CODE(return "UNKNOWN");
+}
+
+void *grpc_channel_init_create_stack(
+ grpc_exec_ctx *exec_ctx, grpc_channel_stack_type type, size_t prefix_bytes,
+ const grpc_channel_args *args, int initial_refs, grpc_iomgr_cb_func destroy,
+ void *destroy_arg, grpc_transport *transport) {
+ GPR_ASSERT(g_finalized);
+
+ grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
+ grpc_channel_stack_builder_set_name(builder, name_for_type(type));
+ grpc_channel_stack_builder_set_channel_arguments(builder, args);
+ grpc_channel_stack_builder_set_transport(builder, transport);
+
+ for (size_t i = 0; i < g_slots[type].num_slots; i++) {
+ const stage_slot *slot = &g_slots[type].slots[i];
+ if (!slot->fn(builder, slot->arg)) {
+ grpc_channel_stack_builder_destroy(builder);
+ return NULL;
+ }
+ }
+
+ return grpc_channel_stack_builder_finish(exec_ctx, builder, prefix_bytes,
+ initial_refs, destroy, destroy_arg);
+}
diff --git a/src/core/surface/channel_init.h b/src/core/surface/channel_init.h
new file mode 100644
index 0000000000..06faef6ddb
--- /dev/null
+++ b/src/core/surface/channel_init.h
@@ -0,0 +1,86 @@
+/*
+ *
+ * Copyright 2016, 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_CORE_SURFACE_CHANNEL_INIT_H
+#define GRPC_CORE_SURFACE_CHANNEL_INIT_H
+
+#include "src/core/channel/channel_stack_builder.h"
+#include "src/core/surface/channel_stack_type.h"
+#include "src/core/transport/transport.h"
+
+/// This module provides a way for plugins (and the grpc core library itself)
+/// to register mutators for channel stacks.
+/// It also provides a universal entry path to run those mutators to build
+/// a channel stack for various subsystems.
+
+/// One stage of mutation: call functions against \a builder to influence the
+/// finally constructed channel stack
+typedef bool (*grpc_channel_init_stage)(grpc_channel_stack_builder *builder,
+ void *arg);
+
+/// Global initialization of the system
+void grpc_channel_init_init(void);
+
+/// Register one stage of mutators.
+/// Stages are run in priority order (lowest to highest), and then in
+/// registration order (in the case of a tie).
+/// Stages are registered against one of the pre-determined channel stack
+/// types.
+void grpc_channel_init_register_stage(grpc_channel_stack_type type,
+ int priority,
+ grpc_channel_init_stage stage_fn,
+ void *stage_arg);
+
+/// Finalize registration. No more calls to grpc_channel_init_register_stage are
+/// allowed.
+void grpc_channel_init_finalize(void);
+/// Shutdown the channel init system
+void grpc_channel_init_shutdown(void);
+
+/// Construct a channel stack of some sort: see channel_stack.h for details
+/// \a type is the type of channel stack to create
+/// \a prefix_bytes is the number of bytes before the channel stack to allocate
+/// \a args are configuration arguments for the channel stack
+/// \a initial_refs is the initial refcount to give the channel stack
+/// \a destroy and \a destroy_arg specify how to destroy the channel stack
+/// if destroy_arg is NULL, the returned value from this function will be
+/// substituted
+/// \a optional_transport is either NULL or a constructed transport object
+/// Returns a pointer to the base of the memory allocated (the actual channel
+/// stack object will be prefix_bytes past that pointer)
+void *grpc_channel_init_create_stack(
+ grpc_exec_ctx *exec_ctx, grpc_channel_stack_type type, size_t prefix_bytes,
+ const grpc_channel_args *args, int initial_refs, grpc_iomgr_cb_func destroy,
+ void *destroy_arg, grpc_transport *optional_transport);
+
+#endif /* GRPC_CORE_SURFACE_CHANNEL_INIT_H */
diff --git a/src/core/surface/channel_stack_type.c b/src/core/surface/channel_stack_type.c
new file mode 100644
index 0000000000..6fd33d411d
--- /dev/null
+++ b/src/core/surface/channel_stack_type.c
@@ -0,0 +1,56 @@
+/*
+ *
+ * Copyright 2016, 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.
+ *
+ */
+
+#include <grpc/support/port_platform.h>
+#include "src/core/surface/channel_stack_type.h"
+#include <grpc/support/log.h>
+
+bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type) {
+ switch (type) {
+ case GRPC_CLIENT_CHANNEL:
+ return true;
+ case GRPC_CLIENT_UCHANNEL:
+ return true;
+ case GRPC_CLIENT_SUBCHANNEL:
+ return true;
+ case GRPC_CLIENT_LAME_CHANNEL:
+ return true;
+ case GRPC_CLIENT_DIRECT_CHANNEL:
+ return true;
+ case GRPC_SERVER_CHANNEL:
+ return false;
+ case GRPC_NUM_CHANNEL_STACK_TYPES:
+ break;
+ }
+ GPR_UNREACHABLE_CODE(return true;);
+}
diff --git a/src/core/surface/channel_stack_type.h b/src/core/surface/channel_stack_type.h
new file mode 100644
index 0000000000..846391a68a
--- /dev/null
+++ b/src/core/surface/channel_stack_type.h
@@ -0,0 +1,61 @@
+/*
+ *
+ * Copyright 2015-2016, 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_CORE_SURFACE_CHANNEL_STACK_TYPE_H
+#define GRPC_CORE_SURFACE_CHANNEL_STACK_TYPE_H
+
+#include <stdbool.h>
+
+typedef enum {
+ // normal top-half client channel with load-balancing, connection management
+ GRPC_CLIENT_CHANNEL,
+ // abbreviated top-half client channel bound to one subchannel - for internal
+ // load balancing implementation
+ GRPC_CLIENT_UCHANNEL,
+ // bottom-half of a client channel: everything that happens post-load
+ // balancing (bound to a specific transport)
+ GRPC_CLIENT_SUBCHANNEL,
+ // a permanently broken client channel
+ GRPC_CLIENT_LAME_CHANNEL,
+ // a directly connected client channel (without load-balancing, directly talks
+ // to a transport)
+ GRPC_CLIENT_DIRECT_CHANNEL,
+ // server side channel
+ GRPC_SERVER_CHANNEL,
+ // must be last
+ GRPC_NUM_CHANNEL_STACK_TYPES
+} grpc_channel_stack_type;
+
+bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type);
+
+#endif /* GRPC_CORE_SURFACE_CHANNEL_STACK_TYPE_H */
diff --git a/src/core/surface/completion_queue.h b/src/core/surface/completion_queue.h
index 27ef90f2d5..07f6d0c8f6 100644
--- a/src/core/surface/completion_queue.h
+++ b/src/core/surface/completion_queue.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_COMPLETION_QUEUE_H
-#define GRPC_INTERNAL_CORE_SURFACE_COMPLETION_QUEUE_H
+#ifndef GRPC_CORE_SURFACE_COMPLETION_QUEUE_H
+#define GRPC_CORE_SURFACE_COMPLETION_QUEUE_H
/* Internal API for completion queues */
@@ -88,4 +88,4 @@ int grpc_cq_is_server_cq(grpc_completion_queue *cc);
void grpc_cq_global_init(void);
void grpc_cq_global_shutdown(void);
-#endif /* GRPC_INTERNAL_CORE_SURFACE_COMPLETION_QUEUE_H */
+#endif /* GRPC_CORE_SURFACE_COMPLETION_QUEUE_H */
diff --git a/src/core/surface/event_string.h b/src/core/surface/event_string.h
index 07c474e3a0..d0598cecca 100644
--- a/src/core/surface/event_string.h
+++ b/src/core/surface/event_string.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,12 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_EVENT_STRING_H
-#define GRPC_INTERNAL_CORE_SURFACE_EVENT_STRING_H
+#ifndef GRPC_CORE_SURFACE_EVENT_STRING_H
+#define GRPC_CORE_SURFACE_EVENT_STRING_H
#include <grpc/grpc.h>
/* Returns a string describing an event. Must be later freed with gpr_free() */
char *grpc_event_string(grpc_event *ev);
-#endif /* GRPC_INTERNAL_CORE_SURFACE_EVENT_STRING_H */
+#endif /* GRPC_CORE_SURFACE_EVENT_STRING_H */
diff --git a/src/core/surface/init.c b/src/core/surface/init.c
index a4a53d3ec1..b50770959f 100644
--- a/src/core/surface/init.c
+++ b/src/core/surface/init.c
@@ -33,13 +33,21 @@
#include <grpc/support/port_platform.h>
+#include <limits.h>
#include <memory.h>
-#include <grpc/census.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/time.h>
+/* TODO(ctiller): find another way? - better not to include census here */
+#include "src/core/census/grpc_plugin.h"
#include "src/core/channel/channel_stack.h"
+#include "src/core/channel/compress_filter.h"
+#include "src/core/channel/connected_channel.h"
+#include "src/core/channel/client_channel.h"
+#include "src/core/channel/client_uchannel.h"
+#include "src/core/channel/http_client_filter.h"
+#include "src/core/channel/http_server_filter.h"
#include "src/core/client_config/lb_policy_registry.h"
#include "src/core/client_config/lb_policies/pick_first.h"
#include "src/core/client_config/lb_policies/round_robin.h"
@@ -54,11 +62,15 @@
#include "src/core/profiling/timers.h"
#include "src/core/surface/api_trace.h"
#include "src/core/surface/call.h"
+#include "src/core/surface/channel_init.h"
#include "src/core/surface/completion_queue.h"
#include "src/core/surface/init.h"
+#include "src/core/surface/lame_client.h"
+#include "src/core/surface/server.h"
#include "src/core/surface/surface_trace.h"
#include "src/core/transport/chttp2_transport.h"
#include "src/core/transport/connectivity_state.h"
+#include "src/core/transport/transport_impl.h"
#ifndef GRPC_DEFAULT_NAME_PREFIX
#define GRPC_DEFAULT_NAME_PREFIX "dns:///"
@@ -72,9 +84,64 @@ static int g_initializations;
static void do_basic_init(void) {
gpr_mu_init(&g_init_mu);
+ /* TODO(ctiller): ideally remove this strict linkage */
+ grpc_register_plugin(census_grpc_plugin_init, census_grpc_plugin_destroy);
g_initializations = 0;
}
+static bool append_filter(grpc_channel_stack_builder *builder, void *arg) {
+ return grpc_channel_stack_builder_append_filter(builder, arg, NULL, NULL);
+}
+
+static bool prepend_filter(grpc_channel_stack_builder *builder, void *arg) {
+ return grpc_channel_stack_builder_prepend_filter(builder, arg, NULL, NULL);
+}
+
+static bool maybe_add_http_filter(grpc_channel_stack_builder *builder,
+ void *arg) {
+ grpc_transport *t = grpc_channel_stack_builder_get_transport(builder);
+ if (t && strstr(t->vtable->name, "http")) {
+ return grpc_channel_stack_builder_prepend_filter(builder, arg, NULL, NULL);
+ }
+ return true;
+}
+
+static void register_builtin_channel_init() {
+ grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, prepend_filter,
+ (void *)&grpc_compress_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
+ prepend_filter,
+ (void *)&grpc_compress_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_UCHANNEL, INT_MAX,
+ prepend_filter,
+ (void *)&grpc_compress_filter);
+ grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter,
+ (void *)&grpc_compress_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX,
+ maybe_add_http_filter,
+ (void *)&grpc_http_client_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX,
+ grpc_add_connected_filter, NULL);
+ grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
+ maybe_add_http_filter,
+ (void *)&grpc_http_client_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
+ grpc_add_connected_filter, NULL);
+ grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
+ maybe_add_http_filter,
+ (void *)&grpc_http_server_filter);
+ grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
+ grpc_add_connected_filter, NULL);
+ grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, append_filter,
+ (void *)&grpc_client_channel_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_UCHANNEL, INT_MAX, append_filter,
+ (void *)&grpc_client_uchannel_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_LAME_CHANNEL, INT_MAX,
+ append_filter, (void *)&grpc_lame_filter);
+ grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter,
+ (void *)&grpc_server_top_filter);
+}
+
typedef struct grpc_plugin {
void (*init)();
void (*destroy)();
@@ -85,7 +152,7 @@ static int g_number_of_plugins = 0;
void grpc_register_plugin(void (*init)(void), void (*destroy)(void)) {
GRPC_API_TRACE("grpc_register_plugin(init=%p, destroy=%p)", 2,
- ((void*)(intptr_t)init, (void*)(intptr_t)destroy));
+ ((void *)(intptr_t)init, (void *)(intptr_t)destroy));
GPR_ASSERT(g_number_of_plugins != MAX_PLUGINS);
g_all_of_the_plugins[g_number_of_plugins].init = init;
g_all_of_the_plugins[g_number_of_plugins].destroy = destroy;
@@ -100,6 +167,7 @@ void grpc_init(void) {
if (++g_initializations == 1) {
gpr_time_init();
grpc_mdctx_global_init();
+ grpc_channel_init_init();
grpc_lb_policy_registry_init(grpc_pick_first_lb_factory_create());
grpc_register_lb_policy(grpc_pick_first_lb_factory_create());
grpc_register_lb_policy(grpc_round_robin_lb_factory_create());
@@ -115,18 +183,12 @@ void grpc_init(void) {
grpc_register_tracer("http", &grpc_http_trace);
grpc_register_tracer("flowctl", &grpc_flowctl_trace);
grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace);
+ grpc_register_tracer("channel_stack_builder",
+ &grpc_trace_channel_stack_builder);
grpc_security_pre_init();
grpc_iomgr_init();
grpc_executor_init();
grpc_tracer_init("GRPC_TRACE");
- /* Only initialize census if no one else has and some features are
- * available. */
- if (census_enabled() == CENSUS_FEATURE_NONE &&
- census_supported() != CENSUS_FEATURE_NONE) {
- if (census_initialize(census_supported())) { /* enable all features. */
- gpr_log(GPR_ERROR, "Could not initialize census.");
- }
- }
gpr_timers_global_init();
grpc_cq_global_init();
grpc_subchannel_index_init();
@@ -135,6 +197,12 @@ void grpc_init(void) {
g_all_of_the_plugins[i].init();
}
}
+ /* register channel finalization AFTER all plugins, to ensure that it's run
+ * at the appropriate time */
+ grpc_register_security_filters();
+ register_builtin_channel_init();
+ /* no more changes to channel init pipelines */
+ grpc_channel_init_finalize();
}
gpr_mu_unlock(&g_init_mu);
GRPC_API_TRACE("grpc_init(void)", 0, ());
@@ -149,7 +217,6 @@ void grpc_shutdown(void) {
grpc_cq_global_shutdown();
grpc_iomgr_shutdown();
grpc_subchannel_index_shutdown();
- census_shutdown();
gpr_timers_global_destroy();
grpc_tracer_shutdown();
grpc_resolver_registry_shutdown();
@@ -159,6 +226,7 @@ void grpc_shutdown(void) {
g_all_of_the_plugins[i].destroy();
}
}
+ grpc_channel_init_shutdown();
grpc_mdctx_global_shutdown();
}
gpr_mu_unlock(&g_init_mu);
diff --git a/src/core/surface/init.h b/src/core/surface/init.h
index 771c30f412..5e358c7022 100644
--- a/src/core/surface/init.h
+++ b/src/core/surface/init.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,10 +31,11 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_INIT_H
-#define GRPC_INTERNAL_CORE_SURFACE_INIT_H
+#ifndef GRPC_CORE_SURFACE_INIT_H
+#define GRPC_CORE_SURFACE_INIT_H
+void grpc_register_security_filters(void);
void grpc_security_pre_init(void);
int grpc_is_initialized(void);
-#endif /* GRPC_INTERNAL_CORE_SURFACE_INIT_H */
+#endif /* GRPC_CORE_SURFACE_INIT_H */
diff --git a/src/core/surface/init_secure.c b/src/core/surface/init_secure.c
index fa20e91583..311dda9864 100644
--- a/src/core/surface/init_secure.c
+++ b/src/core/surface/init_secure.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,11 +32,58 @@
*/
#include "src/core/surface/init.h"
+
+#include <limits.h>
+#include <string.h>
+
+#include "src/core/surface/channel_init.h"
#include "src/core/debug/trace.h"
+#include "src/core/security/auth_filters.h"
+#include "src/core/security/credentials.h"
#include "src/core/security/secure_endpoint.h"
+#include "src/core/security/security_connector.h"
#include "src/core/tsi/transport_security_interface.h"
void grpc_security_pre_init(void) {
grpc_register_tracer("secure_endpoint", &grpc_trace_secure_endpoint);
grpc_register_tracer("transport_security", &tsi_tracing_enabled);
}
+
+static bool maybe_prepend_client_auth_filter(
+ grpc_channel_stack_builder *builder, void *arg) {
+ const grpc_channel_args *args =
+ grpc_channel_stack_builder_get_channel_arguments(builder);
+ if (args) {
+ for (size_t i = 0; i < args->num_args; i++) {
+ if (0 == strcmp(GRPC_SECURITY_CONNECTOR_ARG, args->args[i].key)) {
+ return grpc_channel_stack_builder_prepend_filter(
+ builder, &grpc_client_auth_filter, NULL, NULL);
+ }
+ }
+ }
+ return true;
+}
+
+static bool maybe_prepend_server_auth_filter(
+ grpc_channel_stack_builder *builder, void *arg) {
+ const grpc_channel_args *args =
+ grpc_channel_stack_builder_get_channel_arguments(builder);
+ if (args) {
+ for (size_t i = 0; i < args->num_args; i++) {
+ if (0 == strcmp(GRPC_SERVER_CREDENTIALS_ARG, args->args[i].key)) {
+ return grpc_channel_stack_builder_prepend_filter(
+ builder, &grpc_server_auth_filter, NULL, NULL);
+ }
+ }
+ }
+ return true;
+}
+
+void grpc_register_security_filters(void) {
+ grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX,
+ maybe_prepend_client_auth_filter, NULL);
+ grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
+ maybe_prepend_client_auth_filter, NULL);
+ grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
+ maybe_prepend_server_auth_filter, NULL);
+}
diff --git a/src/core/surface/init_unsecure.c b/src/core/surface/init_unsecure.c
index 630d564a7d..278fcc83ac 100644
--- a/src/core/surface/init_unsecure.c
+++ b/src/core/surface/init_unsecure.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,3 +34,5 @@
#include "src/core/surface/init.h"
void grpc_security_pre_init(void) {}
+
+void grpc_register_security_filters(void) {}
diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c
index 537069e984..58f89946d2 100644
--- a/src/core/surface/lame_client.c
+++ b/src/core/surface/lame_client.c
@@ -31,6 +31,8 @@
*
*/
+#include "src/core/surface/lame_client.h"
+
#include <grpc/grpc.h>
#include <string.h>
@@ -115,7 +117,7 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {}
-static const grpc_channel_filter lame_filter = {
+const grpc_channel_filter grpc_lame_filter = {
lame_start_transport_stream_op, lame_start_transport_op, sizeof(call_data),
init_call_elem, grpc_call_stack_ignore_set_pollset, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
@@ -127,19 +129,17 @@ static const grpc_channel_filter lame_filter = {
grpc_channel *grpc_lame_client_channel_create(const char *target,
grpc_status_code error_code,
const char *error_message) {
- grpc_channel *channel;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_channel_element *elem;
channel_data *chand;
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- static const grpc_channel_filter *filters[] = {&lame_filter};
- channel =
- grpc_channel_create_from_filters(&exec_ctx, target, filters, 1, NULL, 1);
+ grpc_channel *channel = grpc_channel_create(&exec_ctx, target, NULL,
+ GRPC_CLIENT_LAME_CHANNEL, NULL);
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
GRPC_API_TRACE(
"grpc_lame_client_channel_create(target=%s, error_code=%d, "
"error_message=%s)",
3, (target, (int)error_code, error_message));
- GPR_ASSERT(elem->filter == &lame_filter);
+ GPR_ASSERT(elem->filter == &grpc_lame_filter);
chand = (channel_data *)elem->channel_data;
chand->error_code = error_code;
chand->error_message = error_message;
diff --git a/src/core/surface/lame_client.h b/src/core/surface/lame_client.h
new file mode 100644
index 0000000000..3f3abd2ffe
--- /dev/null
+++ b/src/core/surface/lame_client.h
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright 2016, 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_CORE_SURFACE_LAME_CLIENT_H
+#define GRPC_CORE_SURFACE_LAME_CLIENT_H
+
+#include "src/core/channel/channel_stack.h"
+
+extern const grpc_channel_filter grpc_lame_filter;
+
+#endif /* GRPC_CORE_SURFACE_LAME_CLIENT_H */
diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c
index aadfac4c91..cc752227ee 100644
--- a/src/core/surface/secure_channel_create.c
+++ b/src/core/surface/secure_channel_create.c
@@ -40,11 +40,8 @@
#include <grpc/support/slice.h>
#include <grpc/support/slice_buffer.h>
-#include "src/core/census/grpc_filter.h"
#include "src/core/channel/channel_args.h"
#include "src/core/channel/client_channel.h"
-#include "src/core/channel/compress_filter.h"
-#include "src/core/channel/http_client_filter.h"
#include "src/core/client_config/resolver_registry.h"
#include "src/core/iomgr/tcp_client.h"
#include "src/core/security/auth_filters.h"
@@ -115,10 +112,6 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
args_copy = grpc_channel_args_copy_and_add(c->args.channel_args,
&auth_context_arg, 1);
c->result->channel_args = args_copy;
- c->result->filters = gpr_malloc(sizeof(grpc_channel_filter *) * 2);
- c->result->filters[0] = &grpc_http_client_filter;
- c->result->filters[1] = &grpc_client_auth_filter;
- c->result->num_filters = 2;
}
notify = c->notify;
c->notify = NULL;
@@ -262,10 +255,7 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
grpc_channel_security_connector *security_connector;
grpc_resolver *resolver;
subchannel_factory *f;
-#define MAX_FILTERS 3
- const grpc_channel_filter *filters[MAX_FILTERS];
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- size_t n = 0;
GRPC_API_TRACE(
"grpc_secure_channel_create(creds=%p, target=%s, args=%p, "
@@ -294,15 +284,9 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
args_copy = grpc_channel_args_copy_and_add(
new_args_from_connector != NULL ? new_args_from_connector : args,
&connector_arg, 1);
- if (grpc_channel_args_is_census_enabled(args)) {
- filters[n++] = &grpc_client_census_filter;
- }
- filters[n++] = &grpc_compress_filter;
- filters[n++] = &grpc_client_channel_filter;
- GPR_ASSERT(n <= MAX_FILTERS);
- channel = grpc_channel_create_from_filters(&exec_ctx, target, filters, n,
- args_copy, 1);
+ channel = grpc_channel_create(&exec_ctx, target, args_copy,
+ GRPC_CLIENT_CHANNEL, NULL);
f = gpr_malloc(sizeof(*f));
f->base.vtable = &subchannel_factory_vtable;
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index 5b13d4ba52..da93474b26 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -42,7 +42,6 @@
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
-#include "src/core/census/grpc_filter.h"
#include "src/core/channel/channel_args.h"
#include "src/core/channel/connected_channel.h"
#include "src/core/iomgr/iomgr.h"
@@ -182,8 +181,6 @@ typedef struct {
} channel_broadcaster;
struct grpc_server {
- size_t channel_filter_count;
- grpc_channel_filter const **channel_filters;
grpc_channel_args *channel_args;
grpc_completion_queue **cqs;
@@ -355,7 +352,6 @@ static void server_delete(grpc_exec_ctx *exec_ctx, grpc_server *server) {
grpc_channel_args_destroy(server->channel_args);
gpr_mu_destroy(&server->mu_global);
gpr_mu_destroy(&server->mu_call);
- gpr_free((void *)server->channel_filters);
while ((rm = server->registered_methods) != NULL) {
server->registered_methods = rm->next;
request_matcher_destroy(&rm->request_matcher);
@@ -757,7 +753,7 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
}
}
-static const grpc_channel_filter server_surface_filter = {
+const grpc_channel_filter grpc_server_top_filter = {
server_start_transport_stream_op, grpc_channel_next_op, sizeof(call_data),
init_call_elem, grpc_call_stack_ignore_set_pollset, destroy_call_elem,
sizeof(channel_data), init_channel_elem, destroy_channel_elem,
@@ -783,11 +779,10 @@ void grpc_server_register_completion_queue(grpc_server *server,
server->cqs[n] = cq;
}
-grpc_server *grpc_server_create_from_filters(
- const grpc_channel_filter **filters, size_t filter_count,
- const grpc_channel_args *args) {
+grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
size_t i;
- int census_enabled = grpc_channel_args_is_census_enabled(args);
+
+ GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
grpc_server *server = gpr_malloc(sizeof(grpc_server));
@@ -815,23 +810,6 @@ grpc_server *grpc_server_create_from_filters(
server->requested_calls = gpr_malloc(server->max_requested_calls *
sizeof(*server->requested_calls));
- /* Server filter stack is:
-
- server_surface_filter - for making surface API calls
- grpc_server_census_filter (optional) - for stats collection and tracing
- {passed in filter stack}
- grpc_connected_channel_filter - for interfacing with transports */
- server->channel_filter_count = filter_count + 1u + (census_enabled ? 1u : 0u);
- server->channel_filters =
- gpr_malloc(server->channel_filter_count * sizeof(grpc_channel_filter *));
- server->channel_filters[0] = &server_surface_filter;
- if (census_enabled) {
- server->channel_filters[1] = &grpc_server_census_filter;
- }
- for (i = 0; i < filter_count; i++) {
- server->channel_filters[i + 1u + (census_enabled ? 1u : 0u)] = filters[i];
- }
-
server->channel_args = grpc_channel_args_copy(args);
return server;
@@ -892,12 +870,7 @@ void grpc_server_start(grpc_server *server) {
void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
grpc_transport *transport,
- grpc_channel_filter const **extra_filters,
- size_t num_extra_filters,
const grpc_channel_args *args) {
- size_t num_filters = s->channel_filter_count + num_extra_filters + 1;
- grpc_channel_filter const **filters =
- gpr_malloc(sizeof(grpc_channel_filter *) * num_filters);
size_t i;
size_t num_registered_methods;
size_t alloc;
@@ -913,22 +886,14 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
uint32_t max_probes = 0;
grpc_transport_op op;
- for (i = 0; i < s->channel_filter_count; i++) {
- filters[i] = s->channel_filters[i];
- }
- for (; i < s->channel_filter_count + num_extra_filters; i++) {
- filters[i] = extra_filters[i - s->channel_filter_count];
- }
- filters[i] = &grpc_connected_channel_filter;
-
for (i = 0; i < s->cq_count; i++) {
memset(&op, 0, sizeof(op));
op.bind_pollset = grpc_cq_pollset(s->cqs[i]);
grpc_transport_perform_op(exec_ctx, transport, &op);
}
- channel = grpc_channel_create_from_filters(exec_ctx, NULL, filters,
- num_filters, args, 0);
+ channel =
+ grpc_channel_create(exec_ctx, NULL, args, GRPC_SERVER_CHANNEL, transport);
chand = (channel_data *)grpc_channel_stack_element(
grpc_channel_get_channel_stack(channel), 0)->channel_data;
chand->server = s;
@@ -965,17 +930,12 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s,
chand->registered_method_max_probes = max_probes;
}
- grpc_connected_channel_bind_transport(grpc_channel_get_channel_stack(channel),
- transport);
-
gpr_mu_lock(&s->mu_global);
chand->next = &s->root_channel_data;
chand->prev = chand->next->prev;
chand->next->prev = chand->prev->next = chand;
gpr_mu_unlock(&s->mu_global);
- gpr_free((void *)filters);
-
GRPC_CHANNEL_INTERNAL_REF(channel, "connectivity");
memset(&op, 0, sizeof(op));
op.set_accept_stream = true;
diff --git a/src/core/surface/server.h b/src/core/surface/server.h
index a957fdb360..cd62eadd7f 100644
--- a/src/core/surface/server.h
+++ b/src/core/surface/server.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,17 +31,14 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_SERVER_H
-#define GRPC_INTERNAL_CORE_SURFACE_SERVER_H
+#ifndef GRPC_CORE_SURFACE_SERVER_H
+#define GRPC_CORE_SURFACE_SERVER_H
-#include "src/core/channel/channel_stack.h"
#include <grpc/grpc.h>
+#include "src/core/channel/channel_stack.h"
#include "src/core/transport/transport.h"
-/* Create a server */
-grpc_server *grpc_server_create_from_filters(
- const grpc_channel_filter **filters, size_t filter_count,
- const grpc_channel_args *args);
+extern const grpc_channel_filter grpc_server_top_filter;
/* Add a listener to the server: when the server starts, it will call start,
and when it shuts down, it will call destroy */
@@ -56,12 +53,10 @@ void grpc_server_add_listener(
server */
void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *server,
grpc_transport *transport,
- grpc_channel_filter const **extra_filters,
- size_t num_extra_filters,
const grpc_channel_args *args);
const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server);
int grpc_server_has_open_connections(grpc_server *server);
-#endif /* GRPC_INTERNAL_CORE_SURFACE_SERVER_H */
+#endif /* GRPC_CORE_SURFACE_SERVER_H */
diff --git a/src/core/surface/server_chttp2.c b/src/core/surface/server_chttp2.c
index ce970dfe73..ff2840f655 100644
--- a/src/core/surface/server_chttp2.c
+++ b/src/core/surface/server_chttp2.c
@@ -45,10 +45,7 @@
static void setup_transport(grpc_exec_ctx *exec_ctx, void *server,
grpc_transport *transport) {
- static grpc_channel_filter const *extra_filters[] = {
- &grpc_http_server_filter};
- grpc_server_setup_transport(exec_ctx, server, transport, extra_filters,
- GPR_ARRAY_SIZE(extra_filters),
+ grpc_server_setup_transport(exec_ctx, server, transport,
grpc_server_get_channel_args(server));
}
diff --git a/src/core/surface/surface_trace.h b/src/core/surface/surface_trace.h
index 93b2859ac5..ed820ebd05 100644
--- a/src/core/surface/surface_trace.h
+++ b/src/core/surface/surface_trace.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_SURFACE_SURFACE_TRACE_H
-#define GRPC_INTERNAL_CORE_SURFACE_SURFACE_TRACE_H
+#ifndef GRPC_CORE_SURFACE_SURFACE_TRACE_H
+#define GRPC_CORE_SURFACE_SURFACE_TRACE_H
#include "src/core/debug/trace.h"
#include "src/core/surface/api_trace.h"
@@ -45,4 +45,4 @@
gpr_free(_ev); \
}
-#endif /* GRPC_INTERNAL_CORE_SURFACE_SURFACE_TRACE_H */
+#endif /* GRPC_CORE_SURFACE_SURFACE_TRACE_H */
diff --git a/src/core/transport/byte_stream.h b/src/core/transport/byte_stream.h
index d2e51e7b45..b8d0ade2b5 100644
--- a/src/core/transport/byte_stream.h
+++ b/src/core/transport/byte_stream.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_BYTE_STREAM_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_BYTE_STREAM_H
+#ifndef GRPC_CORE_TRANSPORT_BYTE_STREAM_H
+#define GRPC_CORE_TRANSPORT_BYTE_STREAM_H
#include "src/core/iomgr/exec_ctx.h"
#include <grpc/support/slice_buffer.h>
@@ -86,4 +86,4 @@ void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream *stream,
gpr_slice_buffer *slice_buffer,
uint32_t flags);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_BYTE_STREAM_H */
+#endif /* GRPC_CORE_TRANSPORT_BYTE_STREAM_H */
diff --git a/src/core/transport/chttp2/alpn.h b/src/core/transport/chttp2/alpn.h
index f38b4c3167..68010e3155 100644
--- a/src/core/transport/chttp2/alpn.h
+++ b/src/core/transport/chttp2/alpn.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_ALPN_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_ALPN_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_ALPN_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_ALPN_H
#include <string.h>
@@ -46,4 +46,4 @@ size_t grpc_chttp2_num_alpn_versions(void);
* grpc_chttp2_num_alpn_versions()) */
const char *grpc_chttp2_get_alpn_version_index(size_t i);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_ALPN_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_ALPN_H */
diff --git a/src/core/transport/chttp2/bin_encoder.h b/src/core/transport/chttp2/bin_encoder.h
index 036fddf998..edb6f2dad1 100644
--- a/src/core/transport/chttp2/bin_encoder.h
+++ b/src/core/transport/chttp2/bin_encoder.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H
#include <grpc/support/slice.h>
@@ -51,4 +51,4 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input);
return y; */
gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_BIN_ENCODER_H */
diff --git a/src/core/transport/chttp2/frame.h b/src/core/transport/chttp2/frame.h
index 879ee036fa..560a6675af 100644
--- a/src/core/transport/chttp2/frame.h
+++ b/src/core/transport/chttp2/frame.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_FRAME_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_FRAME_H
#include <grpc/support/port_platform.h>
#include <grpc/support/slice.h>
@@ -66,4 +66,4 @@ typedef struct grpc_chttp2_transport_parsing grpc_chttp2_transport_parsing;
#define GRPC_CHTTP2_DATA_FLAG_PADDED 8
#define GRPC_CHTTP2_FLAG_HAS_PRIORITY 0x20
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_FRAME_H */
diff --git a/src/core/transport/chttp2/frame_data.h b/src/core/transport/chttp2/frame_data.h
index 936b7a2589..92929d5c97 100644
--- a/src/core/transport/chttp2/frame_data.h
+++ b/src/core/transport/chttp2/frame_data.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H
/* Parser for GRPC streams embedded in DATA frames */
@@ -98,4 +98,4 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
uint32_t write_bytes, int is_eof,
gpr_slice_buffer *outbuf);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_FRAME_DATA_H */
diff --git a/src/core/transport/chttp2/frame_goaway.h b/src/core/transport/chttp2/frame_goaway.h
index e1a72b4013..616287e9ee 100644
--- a/src/core/transport/chttp2/frame_goaway.h
+++ b/src/core/transport/chttp2/frame_goaway.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H
#include "src/core/iomgr/exec_ctx.h"
#include "src/core/transport/chttp2/frame.h"
@@ -74,4 +74,4 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
gpr_slice debug_data,
gpr_slice_buffer *slice_buffer);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_FRAME_GOAWAY_H */
diff --git a/src/core/transport/chttp2/frame_ping.h b/src/core/transport/chttp2/frame_ping.h
index 16d7a72618..fc4dd7ac58 100644
--- a/src/core/transport/chttp2/frame_ping.h
+++ b/src/core/transport/chttp2/frame_ping.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_FRAME_PING_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_FRAME_PING_H
#include "src/core/iomgr/exec_ctx.h"
#include <grpc/support/slice.h>
@@ -53,4 +53,4 @@ grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_FRAME_PING_H */
diff --git a/src/core/transport/chttp2/frame_rst_stream.h b/src/core/transport/chttp2/frame_rst_stream.h
index 72ca654c32..d563a22e24 100644
--- a/src/core/transport/chttp2/frame_rst_stream.h
+++ b/src/core/transport/chttp2/frame_rst_stream.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H
#include <grpc/support/slice.h>
#include "src/core/transport/chttp2/frame.h"
@@ -52,4 +52,4 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H */
diff --git a/src/core/transport/chttp2/frame_settings.h b/src/core/transport/chttp2/frame_settings.h
index 3c918e3a2a..e3c10d3cc5 100644
--- a/src/core/transport/chttp2/frame_settings.h
+++ b/src/core/transport/chttp2/frame_settings.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H
#include <grpc/support/port_platform.h>
#include <grpc/support/slice.h>
@@ -100,4 +100,4 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H */
diff --git a/src/core/transport/chttp2/frame_window_update.h b/src/core/transport/chttp2/frame_window_update.h
index 89d835c079..0b3712b091 100644
--- a/src/core/transport/chttp2/frame_window_update.h
+++ b/src/core/transport/chttp2/frame_window_update.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H
#include "src/core/iomgr/exec_ctx.h"
#include <grpc/support/slice.h>
@@ -53,4 +53,4 @@ grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H */
diff --git a/src/core/transport/chttp2/hpack_encoder.h b/src/core/transport/chttp2/hpack_encoder.h
index 19b5cb72ae..90aaf867c5 100644
--- a/src/core/transport/chttp2/hpack_encoder.h
+++ b/src/core/transport/chttp2/hpack_encoder.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_ENCODER_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_ENCODER_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_HPACK_ENCODER_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_HPACK_ENCODER_H
#include "src/core/transport/chttp2/frame.h"
#include "src/core/transport/metadata.h"
@@ -92,4 +92,4 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, uint32_t id,
grpc_metadata_batch *metadata, int is_eof,
gpr_slice_buffer *outbuf);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_ENCODER_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_HPACK_ENCODER_H */
diff --git a/src/core/transport/chttp2/hpack_parser.h b/src/core/transport/chttp2/hpack_parser.h
index 1ad0c64fb9..6a6d136da2 100644
--- a/src/core/transport/chttp2/hpack_parser.h
+++ b/src/core/transport/chttp2/hpack_parser.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H
#include <stddef.h>
@@ -113,4 +113,4 @@ grpc_chttp2_parse_error grpc_chttp2_header_parser_parse(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H */
diff --git a/src/core/transport/chttp2/hpack_table.h b/src/core/transport/chttp2/hpack_table.h
index e7431255fc..6e1b5e66b5 100644
--- a/src/core/transport/chttp2/hpack_table.h
+++ b/src/core/transport/chttp2/hpack_table.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H
#include "src/core/transport/metadata.h"
#include <grpc/support/port_platform.h>
@@ -105,4 +105,4 @@ typedef struct {
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
const grpc_chttp2_hptbl *tbl, grpc_mdelem *md);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_HPACK_TABLE_H */
diff --git a/src/core/transport/chttp2/http2_errors.h b/src/core/transport/chttp2/http2_errors.h
index a4f309e056..4290df3d89 100644
--- a/src/core/transport/chttp2/http2_errors.h
+++ b/src/core/transport/chttp2/http2_errors.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H
/* error codes for RST_STREAM from http2 draft 14 section 7 */
typedef enum {
@@ -53,4 +53,4 @@ typedef enum {
GRPC_CHTTP2__ERROR_DO_NOT_USE = -1
} grpc_chttp2_error_code;
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_HTTP2_ERRORS_H */
diff --git a/src/core/transport/chttp2/huffsyms.h b/src/core/transport/chttp2/huffsyms.h
index a3cdba8235..9c4f09dcf6 100644
--- a/src/core/transport/chttp2/huffsyms.h
+++ b/src/core/transport/chttp2/huffsyms.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H
/* HPACK static huffman table */
@@ -45,4 +45,4 @@ typedef struct {
extern const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS];
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_HUFFSYMS_H */
diff --git a/src/core/transport/chttp2/incoming_metadata.h b/src/core/transport/chttp2/incoming_metadata.h
index ea74cfc64b..52454f348c 100644
--- a/src/core/transport/chttp2/incoming_metadata.h
+++ b/src/core/transport/chttp2/incoming_metadata.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHTTP2_INCOMING_METADATA_H
-#define GRPC_INTERNAL_CORE_CHTTP2_INCOMING_METADATA_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_INCOMING_METADATA_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_INCOMING_METADATA_H
#include "src/core/transport/transport.h"
@@ -57,4 +57,4 @@ void grpc_chttp2_incoming_metadata_buffer_add(
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline);
-#endif /* GRPC_INTERNAL_CORE_CHTTP2_INCOMING_METADATA_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_INCOMING_METADATA_H */
diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h
index b720d1ab3e..0690cb37cd 100644
--- a/src/core/transport/chttp2/internal.h
+++ b/src/core/transport/chttp2/internal.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H
-#define GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_INTERNAL_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_INTERNAL_H
#include <assert.h>
#include <stdbool.h>
@@ -777,4 +777,4 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx,
void grpc_chttp2_become_writable(grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
-#endif
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_INTERNAL_H */
diff --git a/src/core/transport/chttp2/status_conversion.h b/src/core/transport/chttp2/status_conversion.h
index 0ec5b560b8..c6e066bb5d 100644
--- a/src/core/transport/chttp2/status_conversion.h
+++ b/src/core/transport/chttp2/status_conversion.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H
#include <grpc/grpc.h>
#include "src/core/transport/chttp2/http2_errors.h"
@@ -47,4 +47,4 @@ grpc_status_code grpc_chttp2_http2_error_to_grpc_status(
grpc_status_code grpc_chttp2_http2_status_to_grpc_status(int status);
int grpc_chttp2_grpc_status_to_http2_status(grpc_status_code status);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_STATUS_CONVERSION_H */
diff --git a/src/core/transport/chttp2/stream_map.h b/src/core/transport/chttp2/stream_map.h
index 7a0e45fab2..957a58a4f2 100644
--- a/src/core/transport/chttp2/stream_map.h
+++ b/src/core/transport/chttp2/stream_map.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H
#include <grpc/support/port_platform.h>
@@ -81,4 +81,4 @@ void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map,
void *value),
void *user_data);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_STREAM_MAP_H */
diff --git a/src/core/transport/chttp2/timeout_encoding.h b/src/core/transport/chttp2/timeout_encoding.h
index 9d8756e799..81bae8e936 100644
--- a/src/core/transport/chttp2/timeout_encoding.h
+++ b/src/core/transport/chttp2/timeout_encoding.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H
#include "src/core/support/string.h"
#include <grpc/support/time.h>
@@ -44,4 +44,4 @@
void grpc_chttp2_encode_timeout(gpr_timespec timeout, char *buffer);
int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_TIMEOUT_ENCODING_H */
diff --git a/src/core/transport/chttp2/varint.h b/src/core/transport/chttp2/varint.h
index 2d92b6693e..7ab9d22ab5 100644
--- a/src/core/transport/chttp2/varint.h
+++ b/src/core/transport/chttp2/varint.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_VARINT_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_VARINT_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_VARINT_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_VARINT_H
#include <grpc/support/port_platform.h>
@@ -72,4 +72,4 @@ void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target,
} \
} while (0)
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_VARINT_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_VARINT_H */
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 03444fd4c2..b16768d06e 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -1757,8 +1757,9 @@ static char *chttp2_get_peer(grpc_exec_ctx *exec_ctx, grpc_transport *t) {
}
static const grpc_transport_vtable vtable = {
- sizeof(grpc_chttp2_stream), init_stream, set_pollset, perform_stream_op,
- perform_transport_op, destroy_stream, destroy_transport, chttp2_get_peer};
+ sizeof(grpc_chttp2_stream), "chttp2", init_stream, set_pollset,
+ perform_stream_op, perform_transport_op, destroy_stream, destroy_transport,
+ chttp2_get_peer};
grpc_transport *grpc_create_chttp2_transport(
grpc_exec_ctx *exec_ctx, const grpc_channel_args *channel_args,
diff --git a/src/core/transport/chttp2_transport.h b/src/core/transport/chttp2_transport.h
index 95520501ed..9a6cf0ed35 100644
--- a/src/core/transport/chttp2_transport.h
+++ b/src/core/transport/chttp2_transport.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TRANSPORT_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TRANSPORT_H
+#ifndef GRPC_CORE_TRANSPORT_CHTTP2_TRANSPORT_H
+#define GRPC_CORE_TRANSPORT_CHTTP2_TRANSPORT_H
#include "src/core/iomgr/endpoint.h"
#include "src/core/transport/transport.h"
@@ -48,4 +48,4 @@ void grpc_chttp2_transport_start_reading(grpc_exec_ctx *exec_ctx,
grpc_transport *transport,
gpr_slice *slices, size_t nslices);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_TRANSPORT_H */
+#endif /* GRPC_CORE_TRANSPORT_CHTTP2_TRANSPORT_H */
diff --git a/src/core/transport/connectivity_state.h b/src/core/transport/connectivity_state.h
index a4eb6652e5..b4a3ce924d 100644
--- a/src/core/transport/connectivity_state.h
+++ b/src/core/transport/connectivity_state.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_CONNECTIVITY_STATE_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_CONNECTIVITY_STATE_H
+#ifndef GRPC_CORE_TRANSPORT_CONNECTIVITY_STATE_H
+#define GRPC_CORE_TRANSPORT_CONNECTIVITY_STATE_H
#include <grpc/grpc.h>
#include "src/core/iomgr/exec_ctx.h"
@@ -82,4 +82,4 @@ int grpc_connectivity_state_notify_on_state_change(
grpc_exec_ctx *exec_ctx, grpc_connectivity_state_tracker *tracker,
grpc_connectivity_state *current, grpc_closure *notify);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CONNECTIVITY_STATE_H */
+#endif /* GRPC_CORE_TRANSPORT_CONNECTIVITY_STATE_H */
diff --git a/src/core/transport/metadata.h b/src/core/transport/metadata.h
index 8742846be7..5ab397848c 100644
--- a/src/core/transport/metadata.h
+++ b/src/core/transport/metadata.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_METADATA_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_METADATA_H
+#ifndef GRPC_CORE_TRANSPORT_METADATA_H
+#define GRPC_CORE_TRANSPORT_METADATA_H
#include <grpc/support/slice.h>
#include <grpc/support/useful.h>
@@ -153,4 +153,4 @@ int grpc_mdstr_is_bin_suffixed(grpc_mdstr *s);
void grpc_mdctx_global_init(void);
void grpc_mdctx_global_shutdown(void);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_METADATA_H */
+#endif /* GRPC_CORE_TRANSPORT_METADATA_H */
diff --git a/src/core/transport/metadata_batch.h b/src/core/transport/metadata_batch.h
index 1b0d1fda3e..9337b28328 100644
--- a/src/core/transport/metadata_batch.h
+++ b/src/core/transport/metadata_batch.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H
+#ifndef GRPC_CORE_TRANSPORT_METADATA_BATCH_H
+#define GRPC_CORE_TRANSPORT_METADATA_BATCH_H
#include <grpc/grpc.h>
#include <grpc/support/port_platform.h>
@@ -122,4 +122,4 @@ void grpc_metadata_batch_assert_ok(grpc_metadata_batch *comd);
} while (0)
#endif
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H */
+#endif /* GRPC_CORE_TRANSPORT_METADATA_BATCH_H */
diff --git a/src/core/transport/static_metadata.h b/src/core/transport/static_metadata.h
index ef72b802b5..85442f8107 100644
--- a/src/core/transport/static_metadata.h
+++ b/src/core/transport/static_metadata.h
@@ -43,8 +43,8 @@
* explanation of what's going on.
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H
+#ifndef GRPC_CORE_TRANSPORT_STATIC_METADATA_H
+#define GRPC_CORE_TRANSPORT_STATIC_METADATA_H
#include "src/core/transport/metadata.h"
@@ -405,4 +405,4 @@ extern const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT];
extern const uint8_t grpc_static_accept_encoding_metadata[8];
#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \
(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]])
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STATIC_METADATA_H */
+#endif /* GRPC_CORE_TRANSPORT_STATIC_METADATA_H */
diff --git a/src/core/transport/transport.h b/src/core/transport/transport.h
index ed6e121c9c..0f068dcb38 100644
--- a/src/core/transport/transport.h
+++ b/src/core/transport/transport.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_H
+#ifndef GRPC_CORE_TRANSPORT_TRANSPORT_H
+#define GRPC_CORE_TRANSPORT_TRANSPORT_H
#include <stddef.h>
@@ -239,4 +239,4 @@ void grpc_transport_destroy(grpc_exec_ctx *exec_ctx, grpc_transport *transport);
char *grpc_transport_get_peer(grpc_exec_ctx *exec_ctx,
grpc_transport *transport);
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_H */
+#endif /* GRPC_CORE_TRANSPORT_TRANSPORT_H */
diff --git a/src/core/transport/transport_impl.h b/src/core/transport/transport_impl.h
index 40bfb4b13a..d9ecc4d2ba 100644
--- a/src/core/transport/transport_impl.h
+++ b/src/core/transport/transport_impl.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_IMPL_H
-#define GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_IMPL_H
+#ifndef GRPC_CORE_TRANSPORT_TRANSPORT_IMPL_H
+#define GRPC_CORE_TRANSPORT_TRANSPORT_IMPL_H
#include "src/core/transport/transport.h"
@@ -41,6 +41,9 @@ typedef struct grpc_transport_vtable {
layers and initialized by the transport */
size_t sizeof_stream; /* = sizeof(transport stream) */
+ /* name of this transport implementation */
+ const char *name;
+
/* implementation of grpc_transport_init_stream */
int (*init_stream)(grpc_exec_ctx *exec_ctx, grpc_transport *self,
grpc_stream *stream, grpc_stream_refcount *refcount,
@@ -75,4 +78,4 @@ struct grpc_transport {
const grpc_transport_vtable *vtable;
};
-#endif /* GRPC_INTERNAL_CORE_TRANSPORT_TRANSPORT_IMPL_H */
+#endif /* GRPC_CORE_TRANSPORT_TRANSPORT_IMPL_H */
diff --git a/src/core/tsi/fake_transport_security.h b/src/core/tsi/fake_transport_security.h
index fe295aa536..6b8e596290 100644
--- a/src/core/tsi/fake_transport_security.h
+++ b/src/core/tsi/fake_transport_security.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TSI_FAKE_TRANSPORT_SECURITY_H
-#define GRPC_INTERNAL_CORE_TSI_FAKE_TRANSPORT_SECURITY_H
+#ifndef GRPC_CORE_TSI_FAKE_TRANSPORT_SECURITY_H
+#define GRPC_CORE_TSI_FAKE_TRANSPORT_SECURITY_H
#include "src/core/tsi/transport_security_interface.h"
@@ -58,4 +58,4 @@ tsi_frame_protector *tsi_create_fake_protector(
}
#endif
-#endif /* GRPC_INTERNAL_CORE_TSI_FAKE_TRANSPORT_SECURITY_H */
+#endif /* GRPC_CORE_TSI_FAKE_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/ssl_transport_security.c b/src/core/tsi/ssl_transport_security.c
index fcbd910f07..42d25ca929 100644
--- a/src/core/tsi/ssl_transport_security.c
+++ b/src/core/tsi/ssl_transport_security.c
@@ -293,6 +293,26 @@ static tsi_result peer_property_from_x509_common_name(
return result;
}
+/* Gets the X509 cert in PEM format as a tsi_peer_property. */
+static tsi_result add_pem_certificate(X509 *cert, tsi_peer_property *property) {
+ BIO *bio = BIO_new(BIO_s_mem());
+ if (!PEM_write_bio_X509(bio, cert)) {
+ BIO_free(bio);
+ return TSI_INTERNAL_ERROR;
+ }
+ char *contents;
+ long len = BIO_get_mem_data(bio, &contents);
+ if (len <= 0) {
+ BIO_free(bio);
+ return TSI_INTERNAL_ERROR;
+ }
+ tsi_result result = tsi_construct_string_peer_property(
+ TSI_X509_PEM_CERT_PROPERTY, (const char *)contents, (size_t)len,
+ property);
+ BIO_free(bio);
+ return result;
+}
+
/* Gets the subject SANs from an X509 cert as a tsi_peer_property. */
static tsi_result add_subject_alt_names_properties_to_peer(
tsi_peer *peer, GENERAL_NAMES *subject_alt_names,
@@ -363,7 +383,8 @@ static tsi_result peer_from_x509(X509 *cert, int include_certificate_type,
tsi_result result;
GPR_ASSERT(subject_alt_name_count >= 0);
property_count = (include_certificate_type ? (size_t)1 : 0) +
- 1 /* common name */ + (size_t)subject_alt_name_count;
+ 2 /* common name, certificate */ +
+ (size_t)subject_alt_name_count;
result = tsi_construct_peer(property_count, peer);
if (result != TSI_OK) return result;
do {
@@ -377,6 +398,10 @@ static tsi_result peer_from_x509(X509 *cert, int include_certificate_type,
cert, &peer->properties[include_certificate_type ? 1 : 0]);
if (result != TSI_OK) break;
+ result = add_pem_certificate(
+ cert, &peer->properties[include_certificate_type ? 2 : 1]);
+ if (result != TSI_OK) break;
+
if (subject_alt_name_count != 0) {
result = add_subject_alt_names_properties_to_peer(
peer, subject_alt_names, (size_t)subject_alt_name_count);
diff --git a/src/core/tsi/ssl_transport_security.h b/src/core/tsi/ssl_transport_security.h
index 4909af4c47..612f5c64cc 100644
--- a/src/core/tsi/ssl_transport_security.h
+++ b/src/core/tsi/ssl_transport_security.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TSI_SSL_TRANSPORT_SECURITY_H
-#define GRPC_INTERNAL_CORE_TSI_SSL_TRANSPORT_SECURITY_H
+#ifndef GRPC_CORE_TSI_SSL_TRANSPORT_SECURITY_H
+#define GRPC_CORE_TSI_SSL_TRANSPORT_SECURITY_H
#include "src/core/tsi/transport_security_interface.h"
@@ -48,6 +48,8 @@ extern "C" {
#define TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY \
"x509_subject_alternative_name"
+#define TSI_X509_PEM_CERT_PROPERTY "x509_pem_cert"
+
#define TSI_SSL_ALPN_SELECTED_PROTOCOL "ssl_alpn_selected_protocol"
/* --- tsi_ssl_handshaker_factory object ---
@@ -169,4 +171,4 @@ int tsi_ssl_peer_matches_name(const tsi_peer *peer, const char *name);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_TSI_SSL_TRANSPORT_SECURITY_H */
+#endif /* GRPC_CORE_TSI_SSL_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/ssl_types.h b/src/core/tsi/ssl_types.h
index 0d0225e9c7..6ea85fe6d4 100644
--- a/src/core/tsi/ssl_types.h
+++ b/src/core/tsi/ssl_types.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TSI_SSL_TYPES_H
-#define GRPC_INTERNAL_CORE_TSI_SSL_TYPES_H
+#ifndef GRPC_CORE_TSI_SSL_TYPES_H
+#define GRPC_CORE_TSI_SSL_TYPES_H
/* A collection of macros to cast between various integer types that are
* used differently between BoringSSL and OpenSSL:
@@ -52,4 +52,4 @@
#define TSI_SIZE_AS_SIZE(x) ((int)(x))
#endif
-#endif
+#endif /* GRPC_CORE_TSI_SSL_TYPES_H */
diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h
index 4077737473..ecc037193b 100644
--- a/src/core/tsi/transport_security.h
+++ b/src/core/tsi/transport_security.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_H
-#define GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_H
+#ifndef GRPC_CORE_TSI_TRANSPORT_SECURITY_H
+#define GRPC_CORE_TSI_TRANSPORT_SECURITY_H
#include "src/core/tsi/transport_security_interface.h"
@@ -108,4 +108,4 @@ char *tsi_strdup(const char *src); /* Sadly, no strdup in C89. */
}
#endif
-#endif /* GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_H */
+#endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_H */
diff --git a/src/core/tsi/transport_security_interface.h b/src/core/tsi/transport_security_interface.h
index 69ee17ae91..08501802f5 100644
--- a/src/core/tsi/transport_security_interface.h
+++ b/src/core/tsi/transport_security_interface.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H
-#define GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H
+#ifndef GRPC_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H
+#define GRPC_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H
#include <stdint.h>
#include <stdlib.h>
@@ -341,4 +341,4 @@ void tsi_handshaker_destroy(tsi_handshaker *self);
}
#endif
-#endif /* GRPC_INTERNAL_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H */
+#endif /* GRPC_CORE_TSI_TRANSPORT_SECURITY_INTERFACE_H */
diff --git a/src/cpp/README.md b/src/cpp/README.md
index 83d37aa2ed..f2935e52d9 100644
--- a/src/cpp/README.md
+++ b/src/cpp/README.md
@@ -61,7 +61,7 @@ below.
#Documentation
You can find out how to build and run our simplest gRPC C++ example in our
-[C++ quick start](https://github.com/grpc/grpc/tree/{{ site.data.config.grpc_release_branch }}/examples/cpp).
+[C++ quick start](../../examples/cpp).
For more detailed documentation on using gRPC in C++ , see our main
documentation site at [grpc.io](http://grpc.io), specifically:
@@ -79,4 +79,4 @@ documentation site at [grpc.io](http://grpc.io), specifically:
# Examples
Code examples for gRPC C++ live in this repository's
-[examples/cpp](https://github.com/grpc/grpc/tree/{{ site.data.config.grpc_release_branch }}/examples/cpp) directory.
+[examples/cpp](../../examples/cpp) directory.
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index 308455527c..c34b840f90 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -60,8 +60,7 @@ std::shared_ptr<grpc::Channel> SecureChannelCredentials::CreateChannel(
SecureCallCredentials::SecureCallCredentials(grpc_call_credentials* c_creds)
: c_creds_(c_creds) {
- internal::GrpcLibraryInitializer gli_initializer;
- gli_initializer.summon();
+ g_gli_initializer.summon();
}
bool SecureCallCredentials::ApplyToCall(grpc_call* call) {
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index eb49b21037..5d12ce2ecf 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -43,6 +43,7 @@
#include <grpc/support/log.h>
#include "src/core/channel/compress_filter.h"
+#include "src/core/surface/call.h"
#include "src/cpp/common/create_auth_context.h"
namespace grpc {
@@ -197,7 +198,7 @@ bool ServerContext::IsCancelled() const {
void ServerContext::set_compression_level(grpc_compression_level level) {
const grpc_compression_algorithm algorithm_for_level =
- grpc_compression_algorithm_for_level(level);
+ grpc_call_compression_for_level(call_, level);
set_compression_algorithm(algorithm_for_level);
}
diff --git a/src/csharp/Grpc.Core/Internal/NativeExtension.cs b/src/csharp/Grpc.Core/Internal/NativeExtension.cs
index 4c742ab6c3..282816d51e 100644
--- a/src/csharp/Grpc.Core/Internal/NativeExtension.cs
+++ b/src/csharp/Grpc.Core/Internal/NativeExtension.cs
@@ -32,6 +32,7 @@
#endregion
using System;
+using System.Globalization;
using System.IO;
using System.Reflection;
@@ -99,14 +100,30 @@ namespace Grpc.Core.Internal
// TODO: allow customizing path to native extension (possibly through exposing a GrpcEnvironment property).
var libraryFlavor = string.Format("{0}_{1}", GetPlatformString(), GetArchitectureString());
- var fullPath = Path.Combine(GetExecutingAssemblyDirectory(),
+ var fullPath = Path.Combine(Path.GetDirectoryName(GetAssemblyPath()),
NativeLibrariesDir, libraryFlavor, GetNativeLibraryFilename());
return new UnmanagedLibrary(fullPath);
}
- private static string GetExecutingAssemblyDirectory()
+ private static string GetAssemblyPath()
{
- return Path.GetDirectoryName(typeof(NativeExtension).GetTypeInfo().Assembly.Location);
+ var assembly = typeof(NativeExtension).GetTypeInfo().Assembly;
+
+ // If assembly is shadowed (e.g. in a webapp), EscapedCodeBase is pointing
+ // to the original location of the assembly, and Location is pointing
+ // to the shadow copy. We care about the original location because
+ // the native dlls don't get shadowed.
+ var escapedCodeBase = assembly.EscapedCodeBase;
+ if (IsFileUri(escapedCodeBase))
+ {
+ return new Uri(escapedCodeBase).LocalPath;
+ }
+ return assembly.Location;
+ }
+
+ private static bool IsFileUri(string uri)
+ {
+ return uri.ToLowerInvariant().StartsWith(Uri.UriSchemeFile);
}
private static string GetPlatformString()
diff --git a/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs b/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs
index 5c5b802164..d41b1b9f26 100644
--- a/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs
+++ b/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs
@@ -1,6 +1,6 @@
#region Copyright notice and license
-// Copyright 2015, Google Inc.
+// Copyright 2015-2016, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -33,12 +33,16 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
namespace Grpc.Core.Logging
{
/// <summary>Logger that logs to System.Console.</summary>
public class ConsoleLogger : ILogger
{
+ // Format similar enough to C core log format except nanosecond precision is not supported.
+ const string DateTimeFormatString = "MMdd HH:mm:ss.ffffff";
+
readonly Type forType;
readonly string forTypeString;
@@ -142,7 +146,7 @@ namespace Grpc.Core.Logging
{
Console.Error.WriteLine("{0}{1} {2}{3}",
severityString,
- DateTime.Now,
+ DateTime.Now.ToString(DateTimeFormatString, CultureInfo.InvariantCulture),
forTypeString,
message);
}
diff --git a/src/csharp/README.md b/src/csharp/README.md
index b4fa945ac9..201c5ab0b5 100644
--- a/src/csharp/README.md
+++ b/src/csharp/README.md
@@ -55,16 +55,11 @@ If you are a user of gRPC C#, go to Usage section above.
**Windows**
-- The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution. You can
- either build the native solution in `vsprojects/grpc_csharp_ext.sln` from Visual Studio manually, or you can use
- a convenience batch script that builds everything for you.
+- The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution. Open the
+ solution `vsprojects/grpc_csharp_ext.sln` in Visual Studio and build it.
- ```
- > REM From src/csharp directory
- > buildall.bat
- ```
-
-- Open Grpc.sln using Visual Studio.
+- Open `src\csharp\Grpc.sln` (path is relative to gRPC repository root)
+ using Visual Studio
**Linux**
@@ -79,7 +74,7 @@ If you are a user of gRPC C#, go to Usage section above.
**Mac OS X**
- The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution.
-
+
```sh
# from the gRPC repository root
$ tools/run_tests/run_tests.py -c dbg -l csharp --build_only
diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c
index f0bc7340ba..b7e7c26c10 100644
--- a/src/php/ext/grpc/channel.c
+++ b/src/php/ext/grpc/channel.c
@@ -110,9 +110,11 @@ void php_grpc_read_args_array(zval *args_array, grpc_channel_args *args) {
switch (Z_TYPE_P(*data)) {
case IS_LONG:
args->args[args_index].value.integer = (int)Z_LVAL_P(*data);
+ args->args[args_index].type = GRPC_ARG_INTEGER;
break;
case IS_STRING:
args->args[args_index].value.string = Z_STRVAL_P(*data);
+ args->args[args_index].type = GRPC_ARG_STRING;
break;
default:
zend_throw_exception(spl_ce_InvalidArgumentException,
diff --git a/src/python/grpcio/README.rst b/src/python/grpcio/README.rst
index 3f4c6fad02..33a462b66f 100644
--- a/src/python/grpcio/README.rst
+++ b/src/python/grpcio/README.rst
@@ -50,10 +50,43 @@ Troubleshooting
Help, I ...
* **... see a** :code:`pkg_resources.VersionConflict` **when I try to install
- grpc!**
+ grpc**
This is likely because :code:`pip` doesn't own the offending dependency,
which in turn is likely because your operating system's package manager owns
it. You'll need to force the installation of the dependency:
:code:`pip install --ignore-installed $OFFENDING_DEPENDENCY`
+
+ For example, if you get an error like the following:
+
+ ::
+
+ Traceback (most recent call last):
+ File "<string>", line 17, in <module>
+ ...
+ File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 509, in find
+ raise VersionConflict(dist, req)
+ pkg_resources.VersionConflict: (six 1.8.0 (/usr/lib/python2.7/dist-packages), Requirement.parse('six>=1.10'))
+
+ You can fix it by doing:
+
+ ::
+
+ sudo pip install --ignore-installed six
+
+* **... see the following error on some platforms**
+
+ ::
+
+ /tmp/pip-build-U8pSsr/cython/Cython/Plex/Scanners.c:4:20: fatal error: Python.h: No such file or directory
+ #include "Python.h"
+ ^
+ compilation terminated.
+
+ You can fix it by installing `python-dev` package. i.e
+
+ ::
+
+ sudo apt-get install python-dev
+
diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py
index c1f444f6f1..1d43547419 100644
--- a/src/python/grpcio/commands.py
+++ b/src/python/grpcio/commands.py
@@ -288,15 +288,9 @@ class TestLite(setuptools.Command):
sys.exit('Test failure')
def _add_eggs_to_path(self):
- """Adds all egg files under .eggs to sys.path"""
- # TODO(jtattemusch): there has to be a cleaner way to do this
- import pkg_resources
- eggs_dir = os.path.join(PYTHON_STEM, '../../../.eggs')
- eggs = [os.path.join(eggs_dir, filename)
- for filename in os.listdir(eggs_dir)
- if filename.endswith('.egg')]
- for egg in eggs:
- sys.path.insert(0, pkg_resources.normalize_path(egg))
+ """Fetch install and test requirements"""
+ self.distribution.fetch_build_eggs(self.distribution.install_requires)
+ self.distribution.fetch_build_eggs(self.distribution.tests_require)
class RunInterop(test.test):
diff --git a/src/python/grpcio/grpc/_adapter/_types.py b/src/python/grpcio/grpc/_adapter/_types.py
index 3d5ab33d00..f9e18f0bb3 100644
--- a/src/python/grpcio/grpc/_adapter/_types.py
+++ b/src/python/grpcio/grpc/_adapter/_types.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@ import abc
import collections
import enum
+import six
+
from grpc._cython import cygrpc
@@ -247,8 +249,7 @@ class Event(collections.namedtuple(
"""
-class CompletionQueue:
- __metaclass__ = abc.ABCMeta
+class CompletionQueue(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self):
@@ -262,6 +263,9 @@ class CompletionQueue:
"""
return self
+ def __next__(self):
+ return self.next()
+
@abc.abstractmethod
def next(self, deadline=float('+inf')):
"""Get the next event on this completion queue.
@@ -285,8 +289,7 @@ class CompletionQueue:
return None
-class Call:
- __metaclass__ = abc.ABCMeta
+class Call(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def start_batch(self, ops, tag):
@@ -334,8 +337,7 @@ class Call:
return None
-class Channel:
- __metaclass__ = abc.ABCMeta
+class Channel(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self, target, args, credentials=None):
@@ -399,8 +401,7 @@ class Channel:
return None
-class Server:
- __metaclass__ = abc.ABCMeta
+class Server(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def __init__(self, completion_queue, args):
diff --git a/src/python/grpcio/grpc/_cython/imports.generated.h b/src/python/grpcio/grpc/_cython/imports.generated.h
index b70dcccd17..4d18369e1f 100644
--- a/src/python/grpcio/grpc/_cython/imports.generated.h
+++ b/src/python/grpcio/grpc/_cython/imports.generated.h
@@ -166,7 +166,7 @@ extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_im
typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, char **name);
extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
#define grpc_compression_algorithm_name grpc_compression_algorithm_name_import
-typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level);
+typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level, uint32_t accepted_encodings);
extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
#define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import
typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts);
diff --git a/src/python/grpcio/grpc/_links/invocation.py b/src/python/grpcio/grpc/_links/invocation.py
index 5ca0a0ee60..672e3e4cc8 100644
--- a/src/python/grpcio/grpc/_links/invocation.py
+++ b/src/python/grpcio/grpc/_links/invocation.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,8 @@ import logging
import threading
import time
+import six
+
from grpc._adapter import _intermediary_low
from grpc._links import _constants
from grpc.beta import interfaces as beta_interfaces
@@ -372,12 +374,11 @@ class _Kernel(object):
pool.shutdown(wait=True)
-class InvocationLink(links.Link, activated.Activated):
+class InvocationLink(six.with_metaclass(abc.ABCMeta, links.Link, activated.Activated)):
"""A links.Link for use on the invocation-side of a gRPC connection.
Implementations of this interface are only valid for use when activated.
"""
- __metaclass__ = abc.ABCMeta
class _InvocationLink(InvocationLink):
diff --git a/src/python/grpcio/grpc/beta/interfaces.py b/src/python/grpcio/grpc/beta/interfaces.py
index 0663119163..e29a5b3379 100644
--- a/src/python/grpcio/grpc/beta/interfaces.py
+++ b/src/python/grpcio/grpc/beta/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
from grpc._adapter import _types
@@ -105,19 +107,17 @@ def grpc_call_options(disable_compression=False, credentials=None):
return GRPCCallOptions(disable_compression, None, credentials)
-class GRPCAuthMetadataContext(object):
+class GRPCAuthMetadataContext(six.with_metaclass(abc.ABCMeta)):
"""Provides information to call credentials metadata plugins.
Attributes:
service_url: A string URL of the service being called into.
method_name: A string of the fully qualified method name being called.
"""
- __metaclass__ = abc.ABCMeta
-class GRPCAuthMetadataPluginCallback(object):
+class GRPCAuthMetadataPluginCallback(six.with_metaclass(abc.ABCMeta)):
"""Callback object received by a metadata plugin."""
- __metaclass__ = abc.ABCMeta
def __call__(self, metadata, error):
"""Inform the gRPC runtime of the metadata to construct a CallCredentials.
@@ -130,10 +130,9 @@ class GRPCAuthMetadataPluginCallback(object):
raise NotImplementedError()
-class GRPCAuthMetadataPlugin(object):
+class GRPCAuthMetadataPlugin(six.with_metaclass(abc.ABCMeta)):
"""
"""
- __metaclass__ = abc.ABCMeta
def __call__(self, context, callback):
"""Invoke the plugin.
@@ -149,9 +148,8 @@ class GRPCAuthMetadataPlugin(object):
raise NotImplementedError()
-class GRPCServicerContext(object):
+class GRPCServicerContext(six.with_metaclass(abc.ABCMeta)):
"""Exposes gRPC-specific options and behaviors to code servicing RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def peer(self):
@@ -168,9 +166,8 @@ class GRPCServicerContext(object):
raise NotImplementedError()
-class GRPCInvocationContext(object):
+class GRPCInvocationContext(six.with_metaclass(abc.ABCMeta)):
"""Exposes gRPC-specific options and behaviors to code invoking RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def disable_next_request_compression(self):
@@ -178,9 +175,8 @@ class GRPCInvocationContext(object):
raise NotImplementedError()
-class Server(object):
+class Server(six.with_metaclass(abc.ABCMeta)):
"""Services RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_insecure_port(self, address):
diff --git a/src/python/grpcio/grpc/framework/alpha/_face_utilities.py b/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
index fb0cfe426d..c97307df16 100644
--- a/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
+++ b/src/python/grpcio/grpc/framework/alpha/_face_utilities.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,8 @@
import abc
import collections
+import six
+
# face_interfaces is referenced from specification in this module.
from grpc.framework.common import cardinality
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
@@ -45,7 +47,7 @@ def _qualified_name(service_name, method_name):
# TODO(nathaniel): This structure is getting bloated; it could be shrunk if
# implementations._Stub used a generic rather than a dynamic underlying
# face-layer stub.
-class InvocationBreakdown(object):
+class InvocationBreakdown(six.with_metaclass(abc.ABCMeta)):
"""An intermediate representation of invocation-side views of RPC methods.
Attributes:
@@ -61,7 +63,6 @@ class InvocationBreakdown(object):
to callable behavior to be used deserializing response values for the
RPC.
"""
- __metaclass__ = abc.ABCMeta
class _EasyInvocationBreakdown(
@@ -73,7 +74,7 @@ class _EasyInvocationBreakdown(
pass
-class ServiceBreakdown(object):
+class ServiceBreakdown(six.with_metaclass(abc.ABCMeta)):
"""An intermediate representation of service-side views of RPC methods.
Attributes:
@@ -84,7 +85,6 @@ class ServiceBreakdown(object):
response_serializers: A dictionary from service-qualified RPC method name
to callable behavior to be used serializing response values for the RPC.
"""
- __metaclass__ = abc.ABCMeta
class _EasyServiceBreakdown(
diff --git a/src/python/grpcio/grpc/framework/alpha/exceptions.py b/src/python/grpcio/grpc/framework/alpha/exceptions.py
index 5234d3b91c..8ec260488e 100644
--- a/src/python/grpcio/grpc/framework/alpha/exceptions.py
+++ b/src/python/grpcio/grpc/framework/alpha/exceptions.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,12 @@
Only GRPC should instantiate and raise these exceptions.
"""
-
import abc
+import six
-class RpcError(Exception):
+class RpcError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for all exceptions raised by GRPC."""
- __metaclass__ = abc.ABCMeta
class CancellationError(RpcError):
diff --git a/src/python/grpcio/grpc/framework/alpha/interfaces.py b/src/python/grpcio/grpc/framework/alpha/interfaces.py
index 8380567c97..cb6d58bb2e 100644
--- a/src/python/grpcio/grpc/framework/alpha/interfaces.py
+++ b/src/python/grpcio/grpc/framework/alpha/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
# exceptions is referenced from specification in this module.
from grpc.framework.alpha import exceptions # pylint: disable=unused-import
from grpc.framework.foundation import activated
@@ -59,15 +61,17 @@ class Abortion(enum.Enum):
SERVICER_FAILURE = 'servicer failure'
-class CancellableIterator(object):
+class CancellableIterator(six.with_metaclass(abc.ABCMeta)):
"""Implements the Iterator protocol and affords a cancel method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __iter__(self):
"""Returns the self object in accordance with the Iterator protocol."""
raise NotImplementedError()
+ def __next__(self):
+ return self.next()
+
@abc.abstractmethod
def next(self):
"""Returns a value or raises StopIteration per the Iterator protocol."""
@@ -79,9 +83,8 @@ class CancellableIterator(object):
raise NotImplementedError()
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -108,7 +111,7 @@ class RpcContext(object):
raise NotImplementedError()
-class UnaryUnarySyncAsync(object):
+class UnaryUnarySyncAsync(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC synchronously or asynchronously.
Values implementing this interface are directly callable and present an
"async" method. Both calls take a request value and a numeric timeout.
@@ -117,7 +120,6 @@ class UnaryUnarySyncAsync(object):
of a value of this type invokes its associated RPC and immediately returns a
future.Future bound to the asynchronous execution of the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -147,7 +149,7 @@ class UnaryUnarySyncAsync(object):
raise NotImplementedError()
-class StreamUnarySyncAsync(object):
+class StreamUnarySyncAsync(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC synchronously or asynchronously.
Values implementing this interface are directly callable and present an
"async" method. Both calls take an iterator of request values and a numeric
@@ -156,7 +158,6 @@ class StreamUnarySyncAsync(object):
of a value of this type invokes its associated RPC and immediately returns a
future.Future bound to the asynchronous execution of the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -191,9 +192,8 @@ class StreamUnarySyncAsync(object):
raise NotImplementedError()
-class RpcMethodDescription(object):
+class RpcMethodDescription(six.with_metaclass(abc.ABCMeta)):
"""A type for the common aspects of RPC method descriptions."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cardinality(self):
@@ -207,9 +207,8 @@ class RpcMethodDescription(object):
raise NotImplementedError()
-class RpcMethodInvocationDescription(RpcMethodDescription):
+class RpcMethodInvocationDescription(six.with_metaclass(abc.ABCMeta, RpcMethodDescription)):
"""Invocation-side description of an RPC method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def serialize_request(self, request):
@@ -240,9 +239,8 @@ class RpcMethodInvocationDescription(RpcMethodDescription):
raise NotImplementedError()
-class RpcMethodServiceDescription(RpcMethodDescription):
+class RpcMethodServiceDescription(six.with_metaclass(abc.ABCMeta, RpcMethodDescription)):
"""Service-side description of an RPC method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def deserialize_request(self, serialized_request):
@@ -345,7 +343,7 @@ class RpcMethodServiceDescription(RpcMethodDescription):
raise NotImplementedError()
-class Stub(object):
+class Stub(six.with_metaclass(abc.ABCMeta)):
"""A stub with callable RPC method names for attributes.
Instances of this type are context managers and only afford RPC invocation
@@ -369,12 +367,10 @@ class Stub(object):
exceptions.RpcError, exceptions.CancellationError,
and exceptions.ExpirationError.
"""
- __metaclass__ = abc.ABCMeta
-class Server(activated.Activated):
+class Server(six.with_metaclass(abc.ABCMeta, activated.Activated)):
"""A GRPC Server."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def port(self):
diff --git a/src/python/grpcio/grpc/framework/base/_ingestion.py b/src/python/grpcio/grpc/framework/base/_ingestion.py
index 06d5b92f0b..090cb158c9 100644
--- a/src/python/grpcio/grpc/framework/base/_ingestion.py
+++ b/src/python/grpcio/grpc/framework/base/_ingestion.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import collections
+import six
+
from grpc.framework.base import _constants
from grpc.framework.base import _interfaces
from grpc.framework.base import exceptions
@@ -72,9 +74,8 @@ class _EmptyConsumer(stream.Consumer):
"""See stream.Consumer.consume_and_terminate for specification."""
-class _ConsumerCreator(object):
+class _ConsumerCreator(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different consumer-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def create_consumer(self, requirement):
diff --git a/src/python/grpcio/grpc/framework/base/_interfaces.py b/src/python/grpcio/grpc/framework/base/_interfaces.py
index d88cf76590..c0cc866cad 100644
--- a/src/python/grpcio/grpc/framework/base/_interfaces.py
+++ b/src/python/grpcio/grpc/framework/base/_interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,14 +31,15 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.base import interfaces # pylint: disable=unused-import
from grpc.framework.foundation import stream
-class TerminationManager(object):
+class TerminationManager(six.with_metaclass(abc.ABCMeta)):
"""An object responsible for handling the termination of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
@@ -91,9 +92,8 @@ class TerminationManager(object):
raise NotImplementedError()
-class TransmissionManager(object):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for transmitting to the other end of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def inmit(self, emission, complete):
@@ -117,9 +117,8 @@ class TransmissionManager(object):
raise NotImplementedError()
-class EmissionManager(stream.Consumer):
+class EmissionManager(six.with_metaclass(abc.ABCMeta, stream.Consumer)):
"""A manager of values emitted by customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_ingestion_manager_and_expiration_manager(
@@ -166,9 +165,8 @@ class EmissionManager(stream.Consumer):
raise NotImplementedError()
-class IngestionManager(stream.Consumer):
+class IngestionManager(six.with_metaclass(abc.ABCMeta, stream.Consumer)):
"""A manager responsible for executing customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
@@ -214,9 +212,8 @@ class IngestionManager(stream.Consumer):
raise NotImplementedError()
-class ExpirationManager(object):
+class ExpirationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for aborting the operation if it runs out of time."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def change_timeout(self, timeout):
@@ -246,9 +243,8 @@ class ExpirationManager(object):
raise NotImplementedError()
-class ReceptionManager(object):
+class ReceptionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for receiving tickets from the other end."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def receive_ticket(self, ticket):
@@ -261,9 +257,8 @@ class ReceptionManager(object):
raise NotImplementedError()
-class CancellationManager(object):
+class CancellationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager of operation cancellation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
diff --git a/src/python/grpcio/grpc/framework/base/_reception.py b/src/python/grpcio/grpc/framework/base/_reception.py
index dd428964f1..2bee3947f0 100644
--- a/src/python/grpcio/grpc/framework/base/_reception.py
+++ b/src/python/grpcio/grpc/framework/base/_reception.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.base import interfaces
from grpc.framework.base import _interfaces
@@ -40,9 +42,8 @@ _INITIAL_FRONT_TO_BACK_TICKET_KINDS = (
)
-class _Receiver(object):
+class _Receiver(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different ticket-handling behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def abort_if_abortive(self, ticket):
diff --git a/src/python/grpcio/grpc/framework/base/_transmission.py b/src/python/grpcio/grpc/framework/base/_transmission.py
index 6845129234..398faaf314 100644
--- a/src/python/grpcio/grpc/framework/base/_transmission.py
+++ b/src/python/grpcio/grpc/framework/base/_transmission.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.base import _constants
from grpc.framework.base import _interfaces
from grpc.framework.base import interfaces
@@ -77,9 +79,8 @@ _ABORTION_OUTCOME_TO_BACK_TO_FRONT_TICKET_KIND = {
}
-class _Ticketizer(object):
+class _Ticketizer(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different ticket-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def ticketize(self, operation_id, sequence_number, payload, complete):
@@ -187,9 +188,8 @@ class _BackTicketizer(_Ticketizer):
operation_id, sequence_number, kind, None)
-class TransmissionManager(_interfaces.TransmissionManager):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta, _interfaces.TransmissionManager)):
"""A _interfaces.TransmissionManager on which other managers may be set."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_ingestion_and_expiration_managers(
diff --git a/src/python/grpcio/grpc/framework/base/interfaces.py b/src/python/grpcio/grpc/framework/base/interfaces.py
index e22c10d975..7c58a23ce0 100644
--- a/src/python/grpcio/grpc/framework/base/interfaces.py
+++ b/src/python/grpcio/grpc/framework/base/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
# stream is referenced from specification in this module.
from grpc.framework.foundation import stream # pylint: disable=unused-import
@@ -50,13 +52,12 @@ class Outcome(enum.Enum):
SERVICED_FAILURE = 'serviced failure'
-class OperationContext(object):
+class OperationContext(six.with_metaclass(abc.ABCMeta)):
"""Provides operation-related information and action.
Attributes:
trace_id: A uuid.UUID identifying a particular set of related operations.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -93,9 +94,8 @@ class OperationContext(object):
raise NotImplementedError()
-class Servicer(object):
+class Servicer(six.with_metaclass(abc.ABCMeta)):
"""Interface for service implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, name, context, output_consumer):
@@ -120,7 +120,7 @@ class Servicer(object):
raise NotImplementedError()
-class Operation(object):
+class Operation(six.with_metaclass(abc.ABCMeta)):
"""Representation of an in-progress operation.
Attributes:
@@ -129,7 +129,6 @@ class Operation(object):
context: An OperationContext affording information and action about the
operation.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
@@ -137,9 +136,8 @@ class Operation(object):
raise NotImplementedError()
-class ServicedIngestor(object):
+class ServicedIngestor(six.with_metaclass(abc.ABCMeta)):
"""Responsible for accepting the result of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def consumer(self, operation_context):
@@ -159,7 +157,7 @@ class ServicedIngestor(object):
raise NotImplementedError()
-class ServicedSubscription(object):
+class ServicedSubscription(six.with_metaclass(abc.ABCMeta)):
"""A sum type representing a serviced's interest in an operation.
Attributes:
@@ -167,7 +165,6 @@ class ServicedSubscription(object):
ingestor: A ServicedIngestor. Must be present if kind is Kind.FULL. Must
be None if kind is Kind.TERMINATION_ONLY or Kind.NONE.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
@@ -178,9 +175,8 @@ class ServicedSubscription(object):
NONE = 'none'
-class End(object):
+class End(six.with_metaclass(abc.ABCMeta)):
"""Common type for entry-point objects on both sides of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def operation_stats(self):
@@ -202,9 +198,8 @@ class End(object):
raise NotImplementedError()
-class Front(End):
+class Front(six.with_metaclass(abc.ABCMeta, End)):
"""Clientish objects that afford the invocation of operations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def operate(
@@ -228,9 +223,8 @@ class Front(End):
raise NotImplementedError()
-class Back(End):
+class Back(six.with_metaclass(abc.ABCMeta, End)):
"""Serverish objects that perform the work of operations."""
- __metaclass__ = abc.ABCMeta
class FrontToBackTicket(
@@ -315,9 +309,8 @@ class BackToFrontTicket(
TRANSMISSION_FAILURE = 'transmission failure'
-class ForeLink(object):
+class ForeLink(six.with_metaclass(abc.ABCMeta)):
"""Accepts back-to-front tickets and emits front-to-back tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_back_to_front_ticket(self, ticket):
@@ -334,9 +327,8 @@ class ForeLink(object):
raise NotImplementedError()
-class RearLink(object):
+class RearLink(six.with_metaclass(abc.ABCMeta)):
"""Accepts front-to-back tickets and emits back-to-front tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_front_to_back_ticket(self, ticket):
@@ -353,11 +345,9 @@ class RearLink(object):
raise NotImplementedError()
-class FrontLink(Front, ForeLink):
+class FrontLink(six.with_metaclass(abc.ABCMeta, Front, ForeLink)):
"""Clientish objects that operate by sending and receiving tickets."""
- __metaclass__ = abc.ABCMeta
-class BackLink(Back, RearLink):
+class BackLink(six.with_metaclass(abc.ABCMeta, Back, RearLink)):
"""Serverish objects that operate by sending and receiving tickets."""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/core/_end.py b/src/python/grpcio/grpc/framework/core/_end.py
index 9c615672aa..dc2f48589a 100644
--- a/src/python/grpcio/grpc/framework/core/_end.py
+++ b/src/python/grpcio/grpc/framework/core/_end.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import threading
import uuid
+import six
+
from grpc.framework.core import _operation
from grpc.framework.core import _utilities
from grpc.framework.foundation import callable_util
@@ -45,7 +47,7 @@ from grpc.framework.interfaces.links import utilities
_IDLE_ACTION_EXCEPTION_LOG_MESSAGE = 'Exception calling idle action!'
-class End(base.End, links.Link):
+class End(six.with_metaclass(abc.ABCMeta, base.End, links.Link)):
"""A bridge between base.End and links.Link.
Implementations of this interface translate arriving tickets into
@@ -53,7 +55,6 @@ class End(base.End, links.Link):
translate calls from application objects implementing base interfaces
into tickets sent to a joined link.
"""
- __metaclass__ = abc.ABCMeta
class _Cycle(object):
diff --git a/src/python/grpcio/grpc/framework/core/_ingestion.py b/src/python/grpcio/grpc/framework/core/_ingestion.py
index 4129a8ce43..1e1fd73ce4 100644
--- a/src/python/grpcio/grpc/framework/core/_ingestion.py
+++ b/src/python/grpcio/grpc/framework/core/_ingestion.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities
@@ -70,9 +72,8 @@ class _SubscriptionCreation(
ABANDONED = 'abandoned'
-class _SubscriptionCreator(object):
+class _SubscriptionCreator(six.with_metaclass(abc.ABCMeta)):
"""Common specification of subscription-creating behavior."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def create(self, group, method):
diff --git a/src/python/grpcio/grpc/framework/core/_interfaces.py b/src/python/grpcio/grpc/framework/core/_interfaces.py
index ffa686b2b7..985e5e8550 100644
--- a/src/python/grpcio/grpc/framework/core/_interfaces.py
+++ b/src/python/grpcio/grpc/framework/core/_interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,17 +31,18 @@
import abc
+import six
+
from grpc.framework.interfaces.base import base
-class TerminationManager(object):
+class TerminationManager(six.with_metaclass(abc.ABCMeta)):
"""An object responsible for handling the termination of an operation.
Attributes:
outcome: None if the operation is active or a base.Outcome value if it has
terminated.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_callback(self, callback):
@@ -105,9 +106,8 @@ class TerminationManager(object):
raise NotImplementedError()
-class TransmissionManager(object):
+class TransmissionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for transmitting to the other end of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def kick_off(
@@ -171,9 +171,8 @@ class TransmissionManager(object):
raise NotImplementedError()
-class ExpirationManager(object):
+class ExpirationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for aborting the operation if it runs out of time."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def change_timeout(self, timeout):
@@ -203,9 +202,8 @@ class ExpirationManager(object):
raise NotImplementedError()
-class ProtocolManager(object):
+class ProtocolManager(six.with_metaclass(abc.ABCMeta)):
"""A manager of protocol-specific values passing through an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_protocol_receiver(self, protocol_receiver):
@@ -228,9 +226,8 @@ class ProtocolManager(object):
raise NotImplementedError()
-class EmissionManager(base.Operator):
+class EmissionManager(six.with_metaclass(abc.ABCMeta, base.Operator)):
"""A manager of values emitted by customer code."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def advance(
@@ -254,14 +251,13 @@ class EmissionManager(base.Operator):
raise NotImplementedError()
-class IngestionManager(object):
+class IngestionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for executing customer code.
This name of this manager comes from its responsibility to pass successive
values from the other side of the operation into the code of the local
customer.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_group_and_method(self, group, method):
@@ -294,9 +290,8 @@ class IngestionManager(object):
raise NotImplementedError()
-class ReceptionManager(object):
+class ReceptionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for receiving tickets from the other end."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def receive_ticket(self, ticket):
@@ -308,7 +303,7 @@ class ReceptionManager(object):
raise NotImplementedError()
-class Operation(object):
+class Operation(six.with_metaclass(abc.ABCMeta)):
"""An ongoing operation.
Attributes:
@@ -316,7 +311,6 @@ class Operation(object):
operator: A base.Operator object for the operation for use by the customer
of the operation.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def handle_ticket(self, ticket):
diff --git a/src/python/grpcio/grpc/framework/core/_termination.py b/src/python/grpcio/grpc/framework/core/_termination.py
index 364158b2b8..e8c4ec60a3 100644
--- a/src/python/grpcio/grpc/framework/core/_termination.py
+++ b/src/python/grpcio/grpc/framework/core/_termination.py
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities
@@ -50,9 +52,8 @@ def _service_completion_predicate(
return transmission_complete and ingestion_complete
-class TerminationManager(_interfaces.TerminationManager):
+class TerminationManager(six.with_metaclass(abc.ABCMeta, _interfaces.TerminationManager)):
"""A _interfaces.TransmissionManager on which another manager may be set."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):
diff --git a/src/python/grpcio/grpc/framework/crust/_control.py b/src/python/grpcio/grpc/framework/crust/_control.py
index 5e9efdf732..c27fc9106d 100644
--- a/src/python/grpcio/grpc/framework/crust/_control.py
+++ b/src/python/grpcio/grpc/framework/crust/_control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -405,6 +405,9 @@ class Rendezvous(base.Operator, future.Future, stream.Consumer, face.Call):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while True:
diff --git a/src/python/grpcio/grpc/framework/face/_control.py b/src/python/grpcio/grpc/framework/face/_control.py
index e918907b74..ec43203a25 100644
--- a/src/python/grpcio/grpc/framework/face/_control.py
+++ b/src/python/grpcio/grpc/framework/face/_control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -120,6 +120,9 @@ class Rendezvous(stream.Consumer):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while ((self._abortion is None) and
diff --git a/src/python/grpcio/grpc/framework/face/exceptions.py b/src/python/grpcio/grpc/framework/face/exceptions.py
index f112df70bc..c272ac75ab 100644
--- a/src/python/grpcio/grpc/framework/face/exceptions.py
+++ b/src/python/grpcio/grpc/framework/face/exceptions.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
class NoSuchMethodError(Exception):
"""Raised by customer code to indicate an unrecognized RPC method name.
@@ -49,12 +51,11 @@ class NoSuchMethodError(Exception):
self.name = name
-class RpcError(Exception):
+class RpcError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for all exceptions raised by the Face layer.
Only RPC Framework should instantiate and raise these exceptions.
"""
- __metaclass__ = abc.ABCMeta
class CancellationError(RpcError):
diff --git a/src/python/grpcio/grpc/framework/face/interfaces.py b/src/python/grpcio/grpc/framework/face/interfaces.py
index b7cc4c1169..9fc18d73bc 100644
--- a/src/python/grpcio/grpc/framework/face/interfaces.py
+++ b/src/python/grpcio/grpc/framework/face/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import enum
+import six
+
# cardinality, style, exceptions, abandonment, future, and stream are
# referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
@@ -52,15 +54,17 @@ class Abortion(enum.Enum):
SERVICER_FAILURE = 'servicer failure'
-class CancellableIterator(object):
+class CancellableIterator(six.with_metaclass(abc.ABCMeta)):
"""Implements the Iterator protocol and affords a cancel method."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __iter__(self):
"""Returns the self object in accordance with the Iterator protocol."""
raise NotImplementedError()
+ def __next__(self):
+ return self.next()
+
@abc.abstractmethod
def next(self):
"""Returns a value or raises StopIteration per the Iterator protocol."""
@@ -72,9 +76,8 @@ class CancellableIterator(object):
raise NotImplementedError()
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -103,13 +106,12 @@ class RpcContext(object):
raise NotImplementedError()
-class Call(object):
+class Call(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side representation of an RPC.
Attributes:
context: An RpcContext affording information about the RPC.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def cancel(self):
@@ -117,9 +119,8 @@ class Call(object):
raise NotImplementedError()
-class UnaryUnaryMultiCallable(object):
+class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -171,9 +172,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError()
-class UnaryStreamMultiCallable(object):
+class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout):
@@ -209,9 +209,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError()
-class StreamUnaryMultiCallable(object):
+class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -264,9 +263,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError()
-class StreamStreamMultiCallable(object):
+class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request_iterator, timeout):
@@ -302,7 +300,7 @@ l Args:
raise NotImplementedError()
-class MethodImplementation(object):
+class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes an RPC method implementation.
Attributes:
@@ -347,12 +345,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT.
"""
- __metaclass__ = abc.ABCMeta
-class MultiMethodImplementation(object):
+class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many RPC methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, name, response_consumer, context):
@@ -381,9 +377,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError()
-class GenericStub(object):
+class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC methods to callers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking_value_in_value_out(self, name, request, timeout):
@@ -622,7 +617,7 @@ class GenericStub(object):
raise NotImplementedError()
-class DynamicStub(object):
+class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""A stub with RPC-method-bound multi-callable attributes.
Instances of this type responsd to attribute access as follows: if the
@@ -637,4 +632,3 @@ class DynamicStub(object):
the attribute will be a StreamStreamMultiCallable with which to invoke the
RPC method.
"""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/foundation/activated.py b/src/python/grpcio/grpc/framework/foundation/activated.py
index 426a71c705..9b49b6363c 100644
--- a/src/python/grpcio/grpc/framework/foundation/activated.py
+++ b/src/python/grpcio/grpc/framework/foundation/activated.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,14 +31,14 @@
import abc
+import six
-class Activated(object):
+class Activated(six.with_metaclass(abc.ABCMeta)):
"""Interface for objects that may be started and stopped.
Values implementing this type must also implement the context manager
protocol.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __enter__(self):
diff --git a/src/python/grpcio/grpc/framework/foundation/callable_util.py b/src/python/grpcio/grpc/framework/foundation/callable_util.py
index 32b0751a01..e0a4cab738 100644
--- a/src/python/grpcio/grpc/framework/foundation/callable_util.py
+++ b/src/python/grpcio/grpc/framework/foundation/callable_util.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -35,8 +35,10 @@ import enum
import functools
import logging
+import six
-class Outcome(object):
+
+class Outcome(six.with_metaclass(abc.ABCMeta)):
"""A sum type describing the outcome of some call.
Attributes:
@@ -47,7 +49,6 @@ class Outcome(object):
exception: The exception raised by the call. Must be present if kind is
Kind.RAISED.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
diff --git a/src/python/grpcio/grpc/framework/foundation/future.py b/src/python/grpcio/grpc/framework/foundation/future.py
index bfc16fc1ea..bb8ee3ad87 100644
--- a/src/python/grpcio/grpc/framework/foundation/future.py
+++ b/src/python/grpcio/grpc/framework/foundation/future.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -49,6 +49,8 @@ built-in-but-only-in-3.3-and-later TimeoutError.
import abc
+import six
+
class TimeoutError(Exception):
"""Indicates that a particular call timed out."""
@@ -58,13 +60,12 @@ class CancelledError(Exception):
"""Indicates that the computation underlying a Future was cancelled."""
-class Future(object):
+class Future(six.with_metaclass(abc.ABCMeta)):
"""A representation of a computation in another control flow.
Computations represented by a Future may be yet to be begun, may be ongoing,
or may have already completed.
"""
- __metaclass__ = abc.ABCMeta
# NOTE(nathaniel): This isn't the return type that I would want to have if it
# were up to me. Were this interface being written from scratch, the return
diff --git a/src/python/grpcio/grpc/framework/foundation/relay.py b/src/python/grpcio/grpc/framework/foundation/relay.py
index 9c23946552..ff4e2275ae 100644
--- a/src/python/grpcio/grpc/framework/foundation/relay.py
+++ b/src/python/grpcio/grpc/framework/foundation/relay.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -46,7 +46,6 @@ class Relay(object):
would be no reason to use an implementation of this interface instead of a
thread pool.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_value(self, value):
diff --git a/src/python/grpcio/grpc/framework/foundation/stream.py b/src/python/grpcio/grpc/framework/foundation/stream.py
index 75c0cf145b..32a2e52aed 100644
--- a/src/python/grpcio/grpc/framework/foundation/stream.py
+++ b/src/python/grpcio/grpc/framework/foundation/stream.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,10 +31,10 @@
import abc
+import six
-class Consumer(object):
+class Consumer(six.with_metaclass(abc.ABCMeta)):
"""Interface for consumers of finite streams of values or objects."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def consume(self, value):
diff --git a/src/python/grpcio/grpc/framework/foundation/stream_util.py b/src/python/grpcio/grpc/framework/foundation/stream_util.py
index 2210e4efcf..7d5977fbbd 100644
--- a/src/python/grpcio/grpc/framework/foundation/stream_util.py
+++ b/src/python/grpcio/grpc/framework/foundation/stream_util.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -83,6 +83,9 @@ class IterableConsumer(stream.Consumer):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while self._active and not self._values:
diff --git a/src/python/grpcio/grpc/framework/interfaces/base/base.py b/src/python/grpcio/grpc/framework/interfaces/base/base.py
index a1e70be5e8..69be37e7ab 100644
--- a/src/python/grpcio/grpc/framework/interfaces/base/base.py
+++ b/src/python/grpcio/grpc/framework/interfaces/base/base.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -42,6 +42,8 @@ import abc
import enum
import threading # pylint: disable=unused-import
+import six
+
# abandonment is referenced from specification in this module.
from grpc.framework.foundation import abandonment # pylint: disable=unused-import
@@ -95,7 +97,7 @@ class Outcome(object):
REMOTE_FAILURE = 'remote failure'
-class Completion(object):
+class Completion(six.with_metaclass(abc.ABCMeta)):
"""An aggregate of the values exchanged upon operation completion.
Attributes:
@@ -103,12 +105,10 @@ class Completion(object):
code: A code value for the operation.
message: A message value for the operation.
"""
- __metaclass__ = abc.ABCMeta
-class OperationContext(object):
+class OperationContext(six.with_metaclass(abc.ABCMeta)):
"""Provides operation-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def outcome(self):
@@ -162,9 +162,8 @@ class OperationContext(object):
raise NotImplementedError()
-class Operator(object):
+class Operator(six.with_metaclass(abc.ABCMeta)):
"""An interface through which to participate in an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def advance(
@@ -184,9 +183,8 @@ class Operator(object):
"""
raise NotImplementedError()
-class ProtocolReceiver(object):
+class ProtocolReceiver(six.with_metaclass(abc.ABCMeta)):
"""A means of receiving protocol values during an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def context(self, protocol_context):
@@ -198,7 +196,7 @@ class ProtocolReceiver(object):
raise NotImplementedError()
-class Subscription(object):
+class Subscription(six.with_metaclass(abc.ABCMeta)):
"""Describes customer code's interest in values from the other side.
Attributes:
@@ -216,7 +214,6 @@ class Subscription(object):
become available during the operation. Must be non-None if kind is
Kind.FULL.
"""
- __metaclass__ = abc.ABCMeta
@enum.unique
class Kind(enum.Enum):
@@ -226,9 +223,8 @@ class Subscription(object):
FULL = 'full'
-class Servicer(object):
+class Servicer(six.with_metaclass(abc.ABCMeta)):
"""Interface for service implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, group, method, context, output_operator):
@@ -255,9 +251,8 @@ class Servicer(object):
raise NotImplementedError()
-class End(object):
+class End(six.with_metaclass(abc.ABCMeta)):
"""Common type for entry-point objects on both sides of an operation."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def start(self):
diff --git a/src/python/grpcio/grpc/framework/interfaces/face/face.py b/src/python/grpcio/grpc/framework/interfaces/face/face.py
index 404c3a7937..b994acecac 100644
--- a/src/python/grpcio/grpc/framework/interfaces/face/face.py
+++ b/src/python/grpcio/grpc/framework/interfaces/face/face.py
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
# cardinality, style, abandonment, future, and stream are
# referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
@@ -96,7 +98,7 @@ class Abortion(
REMOTE_FAILURE = 'remote failure'
-class AbortionError(Exception):
+class AbortionError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for exceptions indicating RPC abortion.
initial_metadata: The initial metadata from the other side of the RPC or
@@ -108,7 +110,6 @@ class AbortionError(Exception):
details: The details value from the other side of the RPC or None if no
details value was received.
"""
- __metaclass__ = abc.ABCMeta
def __init__(self, initial_metadata, terminal_metadata, code, details):
super(AbortionError, self).__init__()
@@ -150,9 +151,8 @@ class RemoteError(AbortionError):
"""Indicates that an RPC has terminated due to a remote defect."""
-class RpcContext(object):
+class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@@ -199,9 +199,8 @@ class RpcContext(object):
raise NotImplementedError()
-class Call(RpcContext):
+class Call(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""Invocation-side utility object for an RPC."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def initial_metadata(self):
@@ -256,9 +255,8 @@ class Call(RpcContext):
raise NotImplementedError()
-class ServicerContext(RpcContext):
+class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""A context object passed to method implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def invocation_metadata(self):
@@ -326,9 +324,8 @@ class ServicerContext(RpcContext):
raise NotImplementedError()
-class ResponseReceiver(object):
+class ResponseReceiver(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side object used to accept the output of an RPC."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def initial_metadata(self, initial_metadata):
@@ -362,9 +359,8 @@ class ResponseReceiver(object):
raise NotImplementedError()
-class UnaryUnaryMultiCallable(object):
+class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -434,9 +430,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError()
-class UnaryStreamMultiCallable(object):
+class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout, metadata=None, protocol_options=None):
@@ -480,9 +475,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError()
-class StreamUnaryMultiCallable(object):
+class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -553,9 +547,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError()
-class StreamStreamMultiCallable(object):
+class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@@ -600,7 +593,7 @@ class StreamStreamMultiCallable(object):
raise NotImplementedError()
-class MethodImplementation(object):
+class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes a method implementation.
Attributes:
@@ -643,12 +636,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT.
"""
- __metaclass__ = abc.ABCMeta
-class MultiMethodImplementation(object):
+class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, group, method, response_consumer, context):
@@ -678,9 +669,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError()
-class GenericStub(object):
+class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via generic methods."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking_unary_unary(
@@ -977,7 +967,7 @@ class GenericStub(object):
raise NotImplementedError()
-class DynamicStub(object):
+class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via attributes corresponding to afforded methods.
Instances of this type may be scoped to a single group so that attribute
@@ -993,4 +983,3 @@ class DynamicStub(object):
if the requested attribute is the name of a stream-stream method, the value of
the attribute will be a StreamStreamMultiCallable with which to invoke an RPC.
"""
- __metaclass__ = abc.ABCMeta
diff --git a/src/python/grpcio/grpc/framework/interfaces/links/links.py b/src/python/grpcio/grpc/framework/interfaces/links/links.py
index 24f0e3b354..808167935f 100644
--- a/src/python/grpcio/grpc/framework/interfaces/links/links.py
+++ b/src/python/grpcio/grpc/framework/interfaces/links/links.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import collections
import enum
+import six
+
class Protocol(collections.namedtuple('Protocol', ('kind', 'value',))):
"""A sum type for handles to a system that transmits tickets.
@@ -123,9 +125,8 @@ class Ticket(
REMOTE_FAILURE = 'remote failure'
-class Link(object):
+class Link(six.with_metaclass(abc.ABCMeta)):
"""Accepts and emits tickets."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_ticket(self, ticket):
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 31e16e0491..b9e7d8c898 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -76,8 +76,10 @@ CORE_SOURCE_FILES = [
'src/core/support/wrap_memcpy.c',
'src/core/census/grpc_context.c',
'src/core/census/grpc_filter.c',
+ 'src/core/census/grpc_plugin.c',
'src/core/channel/channel_args.c',
'src/core/channel/channel_stack.c',
+ 'src/core/channel/channel_stack_builder.c',
'src/core/channel/client_channel.c',
'src/core/channel/client_uchannel.c',
'src/core/channel/compress_filter.c',
@@ -165,7 +167,9 @@ CORE_SOURCE_FILES = [
'src/core/surface/channel.c',
'src/core/surface/channel_connectivity.c',
'src/core/surface/channel_create.c',
+ 'src/core/surface/channel_init.c',
'src/core/surface/channel_ping.c',
+ 'src/core/surface/channel_stack_type.c',
'src/core/surface/completion_queue.c',
'src/core/surface/event_string.c',
'src/core/surface/init.c',
@@ -173,7 +177,6 @@ CORE_SOURCE_FILES = [
'src/core/surface/metadata_array.c',
'src/core/surface/server.c',
'src/core/surface/server_chttp2.c',
- 'src/core/surface/server_create.c',
'src/core/surface/validate_metadata.c',
'src/core/surface/version.c',
'src/core/transport/byte_stream.c',
diff --git a/src/python/grpcio/tests/_runner.py b/src/python/grpcio/tests/_runner.py
index 32a31ce00e..3b5ca03dd9 100644
--- a/src/python/grpcio/tests/_runner.py
+++ b/src/python/grpcio/tests/_runner.py
@@ -35,6 +35,7 @@ import os
import select
import signal
import sys
+import tempfile
import threading
import time
import unittest
@@ -43,72 +44,47 @@ import uuid
from tests import _loader
from tests import _result
-# This number needs to be large enough to outpace output on stdout and stderr
-# from the gRPC core, otherwise we could end up in a potential deadlock. This
-# stems from the OS waiting on someone to clear a filled pipe buffer while the
-# GIL is held from a write to stderr from gRPC core, but said someone is in
-# Python code thus necessitating GIL acquisition.
-_READ_BYTES = 2**20
+class CaptureFile(object):
+ """A context-managed file to redirect output to a byte array.
-class CapturePipe(object):
- """A context-manager pipe to redirect output to a byte array.
+ Use by invoking `start` (`__enter__`) and at some point invoking `stop`
+ (`__exit__`). At any point after the initial call to `start` call `output` to
+ get the current redirected output. Note that we don't currently use file
+ locking, so calling `output` between calls to `start` and `stop` may muddle
+ the result (you should only be doing this during a Python-handled interrupt as
+ a last ditch effort to provide output to the user).
Attributes:
- _redirect_fd (int): File descriptor of file to redirect writes from.
+ _redirected_fd (int): File descriptor of file to redirect writes from.
_saved_fd (int): A copy of the original value of the redirected file
descriptor.
- _read_thread (threading.Thread or None): Thread upon which reads through the
- pipe are performed. Only non-None when self is started.
- _read_fd (int or None): File descriptor of the read end of the redirect
- pipe. Only non-None when self is started.
- _write_fd (int or None): File descriptor of the write end of the redirect
- pipe. Only non-None when self is started.
- output (bytearray or None): Redirected output from writes to the redirected
- file descriptor. Only valid during and after self has started.
+ _into_file (TemporaryFile or None): File to which writes are redirected.
+ Only non-None when self is started.
"""
def __init__(self, fd):
- self._redirect_fd = fd
- self._saved_fd = os.dup(self._redirect_fd)
- self._read_thread = None
- self._read_fd = None
- self._write_fd = None
- self.output = None
+ self._redirected_fd = fd
+ self._saved_fd = os.dup(self._redirected_fd)
+ self._into_file = None
+
+ def output(self):
+ """Get all output from the redirected-to file if it exists."""
+ if self._into_file:
+ self._into_file.seek(0)
+ return bytes(self._into_file.read())
+ else:
+ return bytes()
def start(self):
"""Start redirection of writes to the file descriptor."""
- self._read_fd, self._write_fd = os.pipe()
- os.dup2(self._write_fd, self._redirect_fd)
- flags = fcntl.fcntl(self._read_fd, fcntl.F_GETFL)
- fcntl.fcntl(self._read_fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
- self._read_thread = threading.Thread(target=self._read)
- # If the user wants to exit from the Python program and hits ctrl-C and the
- # read thread is somehow deadlocked with something else, the Python code may
- # refuse to exit. This prevents that by making the read thread second-class.
- self._read_thread.daemon = True
- self._read_thread.start()
+ self._into_file = tempfile.TemporaryFile()
+ os.dup2(self._into_file.fileno(), self._redirected_fd)
def stop(self):
"""Stop redirection of writes to the file descriptor."""
- os.close(self._write_fd)
- os.dup2(self._saved_fd, self._redirect_fd) # auto-close self._redirect_fd
- self._read_thread.join()
- self._read_thread = None
- # we waited for the read thread to finish, so _read_fd has been read and we
- # can close it.
- os.close(self._read_fd)
-
- def _read(self):
- """Read-thread target for self."""
- self.output = bytearray()
- while True:
- select.select([self._read_fd], [], [])
- read_bytes = os.read(self._read_fd, _READ_BYTES)
- if read_bytes:
- self.output.extend(read_bytes)
- else:
- break
+ # n.b. this dup2 call auto-closes self._redirected_fd
+ os.dup2(self._saved_fd, self._redirected_fd)
def write_bypass(self, value):
"""Bypass the redirection and write directly to the original file.
@@ -170,8 +146,8 @@ class Runner(object):
result_out = StringIO.StringIO()
result = _result.TerminalResult(
result_out, id_map=lambda case: case_id_by_case[case])
- stdout_pipe = CapturePipe(sys.stdout.fileno())
- stderr_pipe = CapturePipe(sys.stderr.fileno())
+ stdout_pipe = CaptureFile(sys.stdout.fileno())
+ stderr_pipe = CaptureFile(sys.stderr.fileno())
kill_flag = [False]
def sigint_handler(signal_number, frame):
@@ -182,7 +158,8 @@ class Runner(object):
def fault_handler(signal_number, frame):
stdout_pipe.write_bypass(
'Received fault signal {}\nstdout:\n{}\n\nstderr:{}\n'
- .format(signal_number, stdout_pipe.output, stderr_pipe.output))
+ .format(signal_number, stdout_pipe.output(),
+ stderr_pipe.output()))
os._exit(1)
def check_kill_self():
@@ -191,9 +168,9 @@ class Runner(object):
result.stopTestRun()
stdout_pipe.write_bypass(result_out.getvalue())
stdout_pipe.write_bypass(
- '\ninterrupted stdout:\n{}\n'.format(stdout_pipe.output))
+ '\ninterrupted stdout:\n{}\n'.format(stdout_pipe.output()))
stderr_pipe.write_bypass(
- '\ninterrupted stderr:\n{}\n'.format(stderr_pipe.output))
+ '\ninterrupted stderr:\n{}\n'.format(stderr_pipe.output()))
os._exit(1)
signal.signal(signal.SIGINT, sigint_handler)
signal.signal(signal.SIGSEGV, fault_handler)
@@ -223,7 +200,7 @@ class Runner(object):
# re-raise the exception after forcing the with-block to end
raise
result.set_output(
- augmented_case.case, stdout_pipe.output, stderr_pipe.output)
+ augmented_case.case, stdout_pipe.output(), stderr_pipe.output())
sys.stdout.write(result_out.getvalue())
sys.stdout.flush()
result_out.truncate(0)
diff --git a/src/python/grpcio/tests/interop/methods.py b/src/python/grpcio/tests/interop/methods.py
index b3591aef7b..1f5561c1f0 100644
--- a/src/python/grpcio/tests/interop/methods.py
+++ b/src/python/grpcio/tests/interop/methods.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -173,6 +173,9 @@ class _Pipe(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while not self._values and self._open:
diff --git a/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py b/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
index f55a7a23ea..c9f36636b5 100644
--- a/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
+++ b/src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,12 +32,13 @@
import abc
import threading
+import six
+
from tests.unit._junkdrawer import math_pb2
-class ProtoScenario(object):
+class ProtoScenario(six.with_metaclass(abc.ABCMeta)):
"""An RPC test scenario using protocol buffers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def method(self):
diff --git a/src/python/grpcio/tests/unit/_links/_proto_scenarios.py b/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
index f69ff51b16..acd4891390 100644
--- a/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
+++ b/src/python/grpcio/tests/unit/_links/_proto_scenarios.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,13 +32,14 @@
import abc
import threading
+import six
+
from tests.unit._junkdrawer import math_pb2
from tests.unit.framework.common import test_constants
-class ProtoScenario(object):
+class ProtoScenario(six.with_metaclass(abc.ABCMeta)):
"""An RPC test scenario using protocol buffers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def group_and_method(self):
diff --git a/src/python/grpcio/tests/unit/beta/_beta_features_test.py b/src/python/grpcio/tests/unit/beta/_beta_features_test.py
index ea44177b49..ebdedcc11e 100644
--- a/src/python/grpcio/tests/unit/beta/_beta_features_test.py
+++ b/src/python/grpcio/tests/unit/beta/_beta_features_test.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -125,6 +125,9 @@ class _BlockingIterator(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while True:
diff --git a/src/python/grpcio/tests/unit/framework/common/test_control.py b/src/python/grpcio/tests/unit/framework/common/test_control.py
index 8d6eba5c2c..0387668b11 100644
--- a/src/python/grpcio/tests/unit/framework/common/test_control.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@ import abc
import contextlib
import threading
+import six
+
class Defect(Exception):
"""Simulates a programming defect raised into in a system under test.
@@ -42,7 +44,7 @@ class Defect(Exception):
"""
-class Control(object):
+class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method
@@ -51,8 +53,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def control(self):
"""Potentially does anything."""
diff --git a/src/python/grpcio/tests/unit/framework/common/test_coverage.py b/src/python/grpcio/tests/unit/framework/common/test_coverage.py
index a7ed3582c4..184621fb5c 100644
--- a/src/python/grpcio/tests/unit/framework/common/test_coverage.py
+++ b/src/python/grpcio/tests/unit/framework/common/test_coverage.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,14 @@
import abc
+import six
+
# This code is designed for use with the unittest module.
# pylint: disable=invalid-name
-class Coverage(object):
+class Coverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self):
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/base_util.py b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
index 1df1529b27..60ab5bc0fe 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/base_util.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.base import util as _base_util
from grpc.framework.base import implementations
@@ -43,7 +45,7 @@ _POOL_SIZE_LIMIT = 5
_MAXIMUM_TIMEOUT = 90
-class LinkedPair(object):
+class LinkedPair(six.with_metaclass(abc.ABCMeta)):
"""A Front and Back that are linked to one another.
Attributes:
@@ -51,8 +53,6 @@ class LinkedPair(object):
back: An interfaces.Back.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def shut_down(self):
"""Shuts down this object and releases its resources."""
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
index 0613516421..2fc67f6292 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@
import abc
import unittest # pylint: disable=unused-import
+import six
+
from grpc.framework.face import exceptions
from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import control
@@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class BlockingInvocationInlineServiceTestCase(
- test_case.FaceTestCase, coverage.BlockingCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.BlockingCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/control.py b/src/python/grpcio/tests/unit/framework/face/testing/control.py
index 3960c4e649..0d40331e19 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/control.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,8 +33,10 @@ import abc
import contextlib
import threading
+import six
-class Control(object):
+
+class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method
@@ -43,8 +45,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning.
"""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def control(self):
"""Potentially does anything."""
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/coverage.py b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
index f3aca113fe..9f5381069d 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/coverage.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,15 +31,15 @@
import abc
+import six
+
# These classes are only valid when inherited by unittest.TestCases.
# pylint: disable=invalid-name
-class BlockingCoverage(object):
+class BlockingCoverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage for blocking behaviors."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self):
raise NotImplementedError()
@@ -93,11 +93,9 @@ class BlockingCoverage(object):
raise NotImplementedError()
-class FullCoverage(BlockingCoverage):
+class FullCoverage(six.with_metaclass(abc.ABCMeta, BlockingCoverage)):
"""Specification of test coverage for non-blocking behaviors."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def testParallelInvocations(self):
raise NotImplementedError()
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
index 179f3a2f67..b707dcdf6c 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -32,6 +32,8 @@
import abc
import unittest
+import six
+
from grpc.framework.face import interfaces
from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import callback as testing_callback
@@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class EventInvocationSynchronousEventServiceTestCase(
- test_case.FaceTestCase, coverage.FullCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
index 485524a356..8adfc613c6 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,8 @@ import contextlib
import threading
import unittest
+import six
+
from grpc.framework.face import exceptions
from grpc.framework.foundation import future
from grpc.framework.foundation import logging_pool
@@ -66,6 +68,9 @@ class _PauseableIterator(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while self._paused:
@@ -74,12 +79,12 @@ class _PauseableIterator(object):
class FutureInvocationAsynchronousEventServiceTestCase(
- test_case.FaceTestCase, coverage.FullCoverage):
+ six.with_metaclass(abc.ABCMeta,
+ test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase.
"""
- __metaclass__ = abc.ABCMeta
def setUp(self):
"""See unittest.TestCase.setUp for full specification.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
index 5932dabf1e..87be836e2d 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,14 @@
import abc
+import six
+
# cardinality is referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
-class Method(object):
+class Method(six.with_metaclass(abc.ABCMeta)):
"""An RPC method to be used in tests of RPC implementations."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/service.py b/src/python/grpcio/tests/unit/framework/face/testing/service.py
index ac0b89b6ee..dc0f204c04 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/service.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/service.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,16 +31,16 @@
import abc
+import six
+
# interfaces is referenced from specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces
-class UnaryUnaryTestMethodImplementation(interfaces.Method):
+class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-unary RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message.
@@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class UnaryUnaryTestMessages(object):
+class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError()
-class UnaryStreamTestMethodImplementation(interfaces.Method):
+class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-stream RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages.
@@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class UnaryStreamTestMessages(object):
+class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError()
-class StreamUnaryTestMethodImplementation(interfaces.Method):
+class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-unary RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message.
@@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class StreamUnaryTestMessages(object):
+class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError()
-class StreamStreamTestMethodImplementation(interfaces.Method):
+class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-stream RPC method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages.
@@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(interfaces.Method):
raise NotImplementedError()
-class StreamStreamTestMessages(object):
+class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError()
-class TestService(object):
+class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented RPC methods to use in tests."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def name(self):
"""Identifies the RPC service name used during the test.
diff --git a/src/python/grpcio/tests/unit/framework/face/testing/test_case.py b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
index 23d4d919c2..5be9330a77 100644
--- a/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
+++ b/src/python/grpcio/tests/unit/framework/face/testing/test_case.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,18 +31,19 @@
import abc
+import six
+
# face_interfaces and interfaces are referenced in specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces # pylint: disable=unused-import
-class FaceTestCase(object):
+class FaceTestCase(six.with_metaclass(abc.ABCMeta)):
"""Describes a test of the Face Layer of RPC Framework.
Concrete subclasses must also inherit from unittest.TestCase and from at least
one class that defines test methods.
"""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_up_implementation(
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
index 38102b198a..fe69e63995 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -36,6 +36,8 @@ import random # pylint: disable=unused-import
import threading
import time
+import six
+
from grpc.framework.interfaces.base import base
from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.base import _sequence
@@ -247,8 +249,7 @@ class Instruction(
CONCLUDE = 'CONCLUDE'
-class Controller(object):
- __metaclass__ = abc.ABCMeta
+class Controller(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def failed(self, message):
@@ -308,8 +309,7 @@ class Controller(object):
raise NotImplementedError()
-class ControllerCreator(object):
- __metaclass__ = abc.ABCMeta
+class ControllerCreator(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
index 84afd24d47..0594cfeb31 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,12 +31,13 @@
import abc
+import six
+
from grpc.framework.interfaces.base import base # pylint: disable=unused-import
-class Serialization(object):
+class Serialization(six.with_metaclass(abc.ABCMeta)):
"""Specifies serialization and deserialization of test payloads."""
- __metaclass__ = abc.ABCMeta
def serialize_request(self, request):
"""Serializes a request value used in a test.
@@ -85,9 +86,8 @@ class Serialization(object):
raise NotImplementedError()
-class Implementation(object):
+class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Base layer."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def instantiate(self, serializations, servicer):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
index c8a3a1bc74..a47fcd3681 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
@@ -34,6 +34,8 @@ import itertools
import unittest
from concurrent import futures
+import six
+
# test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face
@@ -46,14 +48,13 @@ from tests.unit.framework.interfaces.face import _stock_service
from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
-class TestCase(test_coverage.Coverage, unittest.TestCase):
+class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor.
"""
- __metaclass__ = abc.ABCMeta
NAME = 'BlockingInvocationInlineServiceTest'
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
index 1d36a931e8..c1081a7d99 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
@@ -36,6 +36,8 @@ import threading
import unittest
from concurrent import futures
+import six
+
# test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face
@@ -67,6 +69,9 @@ class _PauseableIterator(object):
def __iter__(self):
return self
+ def __next__(self):
+ return self.next()
+
def next(self):
with self._condition:
while self._paused:
@@ -104,14 +109,13 @@ class _Callback(object):
self._condition.wait()
-class TestCase(test_coverage.Coverage, unittest.TestCase):
+class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor.
"""
- __metaclass__ = abc.ABCMeta
NAME = 'FutureInvocationAsynchronousEventServiceTest'
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
index 448e845a08..ff38dc2ece 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,6 +31,8 @@
import abc
+import six
+
from grpc.framework.common import cardinality
_CARDINALITY_TO_GENERIC_BLOCKING_BEHAVIOR = {
@@ -62,9 +64,8 @@ _CARDINALITY_TO_MULTI_CALLABLE_ATTRIBUTE = {
}
-class Invoker(object):
+class Invoker(six.with_metaclass(abc.ABCMeta)):
"""A type used to invoke test RPCs."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking(self, group, name):
@@ -82,9 +83,8 @@ class Invoker(object):
raise NotImplementedError()
-class InvokerConstructor(object):
+class InvokerConstructor(six.with_metaclass(abc.ABCMeta)):
"""A type used to create Invokers."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def name(self):
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
index 28941e2ad0..bec8d5113c 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,16 +31,16 @@
import abc
+import six
+
# face is referenced from specification in this module.
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
from tests.unit.framework.interfaces.face import test_interfaces
-class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
+class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-unary method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message.
@@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class UnaryUnaryTestMessages(object):
+class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError()
-class UnaryStreamTestMethodImplementation(test_interfaces.Method):
+class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-stream method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages.
@@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class UnaryStreamTestMessages(object):
+class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def request(self):
"""Affords a request message.
@@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError()
-class StreamUnaryTestMethodImplementation(test_interfaces.Method):
+class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-unary method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message.
@@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class StreamUnaryTestMessages(object):
+class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError()
-class StreamStreamTestMethodImplementation(test_interfaces.Method):
+class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-stream method."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages.
@@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError()
-class StreamStreamTestMessages(object):
+class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def requests(self):
"""Affords a sequence of request messages.
@@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError()
-class TestService(object):
+class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented methods to use in tests."""
- __metaclass__ = abc.ABCMeta
-
@abc.abstractmethod
def unary_unary_scenarios(self):
"""Affords unary-request-unary-response test methods and their messages.
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
index b2b5c10fa6..a5e28b7942 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,13 +31,14 @@
import abc
+import six
+
from grpc.framework.common import cardinality # pylint: disable=unused-import
from grpc.framework.interfaces.face import face # pylint: disable=unused-import
-class Method(object):
+class Method(six.with_metaclass(abc.ABCMeta)):
"""Specifies a method to be used in tests."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def group(self):
@@ -126,9 +127,8 @@ class Method(object):
raise NotImplementedError()
-class Implementation(object):
+class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Face layer."""
- __metaclass__ = abc.ABCMeta
@abc.abstractmethod
def instantiate(
diff --git a/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
index dace6c23f3..2283e79f0a 100644
--- a/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
+++ b/src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,8 @@
import abc
import unittest # pylint: disable=unused-import
+import six
+
from grpc.framework.interfaces.links import links
from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.links import test_utilities
@@ -58,13 +60,12 @@ _TRANSMISSION_GROUP = 'test.Group'
_TRANSMISSION_METHOD = 'TestMethod'
-class TransmissionTest(object):
+class TransmissionTest(six.with_metaclass(abc.ABCMeta)):
"""Tests ticket transmission between two connected links.
This class must be mixed into a unittest.TestCase that implements the abstract
methods it provides.
"""
- __metaclass__ = abc.ABCMeta
# This is a unittest.TestCase mix-in.
# pylint: disable=invalid-name
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
index b972f60fc3..3bf81af8fb 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -166,7 +166,7 @@ extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_im
typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, char **name);
extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
#define grpc_compression_algorithm_name grpc_compression_algorithm_name_import
-typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level);
+typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level, uint32_t accepted_encodings);
extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
#define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import
typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts);