Merge github.com:grpc/grpc into fuzzy-bits

pull/5846/head
Craig Tiller 9 years ago
commit 995bc78441
  1. 8
      .clang_complete
  2. 55
      BUILD
  3. 14
      MANIFEST.md
  4. 187
      Makefile
  5. 11
      binding.gyp
  6. 50
      build.yaml
  7. 13
      config.m4
  8. 6
      examples/python/helloworld/greeter_client.py
  9. 36
      examples/python/route_guide/route_guide_client.py
  10. 27
      gRPC.podspec
  11. 19
      grpc.gemspec
  12. 4
      include/grpc++/support/byte_buffer.h
  13. 4
      include/grpc/impl/codegen/port_platform.h
  14. 19
      package.json
  15. 19
      package.xml
  16. 4
      setup.py
  17. 108
      src/compiler/cpp_generator.cc
  18. 6
      src/compiler/cpp_generator.h
  19. 14
      src/compiler/cpp_plugin.cc
  20. 7
      src/compiler/python_generator.cc
  21. 2
      src/core/census/grpc_plugin.c
  22. 1
      src/core/channel/channel_stack_builder.c
  23. 233
      src/core/channel/client_uchannel.c
  24. 5
      src/core/channel/subchannel_call_holder.h
  25. 27
      src/core/client_config/resolvers/dns_resolver.c
  26. 35
      src/core/client_config/resolvers/sockaddr_resolver.c
  27. 16
      src/core/http/format_request.c
  28. 8
      src/core/http/format_request.h
  29. 27
      src/core/http/httpcli.c
  30. 39
      src/core/http/httpcli.h
  31. 2
      src/core/http/httpcli_security_connector.c
  32. 313
      src/core/http/parser.c
  33. 116
      src/core/http/parser.h
  34. 219
      src/core/httpcli/parser.c
  35. 5
      src/core/iomgr/endpoint_pair_posix.c
  36. 10
      src/core/iomgr/fd_posix.c
  37. 12
      src/core/iomgr/resolve_address_posix.c
  38. 21
      src/core/iomgr/sockaddr_utils.c
  39. 4
      src/core/iomgr/tcp_client_posix.c
  40. 21
      src/core/iomgr/tcp_server_posix.c
  41. 19
      src/core/iomgr/udp_server.c
  42. 9
      src/core/iomgr/udp_server.h
  43. 103
      src/core/iomgr/unix_sockets_posix.c
  44. 39
      src/core/iomgr/unix_sockets_posix.h
  45. 61
      src/core/iomgr/unix_sockets_posix_noop.c
  46. 11
      src/core/iomgr/wakeup_fd_pipe.c
  47. 25
      src/core/security/credentials.c
  48. 7
      src/core/security/credentials.h
  49. 9
      src/core/security/google_default_credentials.c
  50. 20
      src/core/security/jwt_verifier.c
  51. 5
      src/core/support/backoff.c
  52. 3
      src/core/support/backoff.h
  53. 17
      src/core/surface/channel_connectivity.c
  54. 2
      src/core/surface/channel_init.c
  55. 2
      src/core/surface/channel_stack_type.c
  56. 3
      src/core/surface/channel_stack_type.h
  57. 6
      src/core/surface/init.c
  58. 2
      src/core/transport/chttp2/timeout_encoding.c
  59. 2
      src/core/transport/static_metadata.c
  60. 81
      src/node/ext/call_credentials.cc
  61. 18
      src/node/ext/call_credentials.h
  62. 2
      src/node/src/credentials.js
  63. 48
      src/objective-c/GRPCClient/GRPCCall.m
  64. 6
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m
  65. 19
      src/proto/grpc/testing/metrics.proto
  66. 4
      src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
  67. 4
      src/python/grpcio/grpc/framework/alpha/_face_utilities.py
  68. 6
      src/python/grpcio/grpc/framework/alpha/_reexport.py
  69. 6
      src/python/grpcio/grpc/framework/crust/implementations.py
  70. 6
      src/python/grpcio/grpc/framework/face/implementations.py
  71. 11
      src/python/grpcio/grpc_core_dependencies.py
  72. 4
      src/python/grpcio/tests/__init__.py
  73. 4
      src/python/grpcio/tests/_loader.py
  74. 8
      src/python/grpcio/tests/_result.py
  75. 7
      src/python/grpcio/tests/_runner.py
  76. 6
      src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py
  77. 8
      src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py
  78. 8
      src/python/grpcio/tests/unit/beta/_face_interface_test.py
  79. 6
      src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py
  80. 26
      src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
  81. 6
      src/python/grpcio/tests/unit/framework/face/testing/digest.py
  82. 36
      src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
  83. 36
      src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
  84. 30
      src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
  85. 6
      src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
  86. 40
      src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
  87. 6
      src/python/grpcio/tests/unit/test_common.py
  88. 6
      src/ruby/ext/grpc/rb_call.c
  89. 38
      src/ruby/ext/grpc/rb_call_credentials.c
  90. 22
      src/ruby/ext/grpc/rb_channel.c
  91. 23
      src/ruby/ext/grpc/rb_channel_credentials.c
  92. 2
      summerofcode/ideas.md
  93. 8
      test/core/end2end/fixtures/h2_full+trace.c
  94. 350
      test/core/end2end/fixtures/h2_uchannel.c
  95. 1
      test/core/end2end/gen_build_yaml.py
  96. 36
      test/core/http/format_request_test.c
  97. 8
      test/core/http/httpcli_test.c
  98. 8
      test/core/http/httpscli_test.c
  99. 135
      test/core/http/parser_test.c
  100. 3
      test/core/http/request_corpus/request1.txt
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,8 @@
-Ithird_party/googletest/include
-Ithird_party/googletest
-Iinclude
-Igens
-I.
-Ithird_party/boringssl/include
-Ithird_party/zlib
-Ithird_party/protobuf/src

55
BUILD

@ -163,7 +163,6 @@ cc_library(
"src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
@ -191,9 +190,9 @@ cc_library(
"src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/parser.h",
"src/core/http/format_request.h",
"src/core/http/httpcli.h",
"src/core/http/parser.h",
"src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
@ -225,6 +224,7 @@ cc_library(
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",
@ -305,7 +305,6 @@ cc_library(
"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",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
@ -333,9 +332,9 @@ cc_library(
"src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/parser.c",
"src/core/http/format_request.c",
"src/core/http/httpcli.c",
"src/core/http/parser.c",
"src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
@ -370,6 +369,8 @@ cc_library(
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
@ -431,7 +432,7 @@ cc_library(
"src/core/transport/static_metadata.c",
"src/core/transport/transport.c",
"src/core/transport/transport_op_string.c",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/http/httpcli_security_connector.c",
"src/core/security/b64.c",
"src/core/security/client_auth_filter.c",
"src/core/security/credentials.c",
@ -537,7 +538,6 @@ cc_library(
"src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
@ -565,9 +565,9 @@ cc_library(
"src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/parser.h",
"src/core/http/format_request.h",
"src/core/http/httpcli.h",
"src/core/http/parser.h",
"src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
@ -599,6 +599,7 @@ cc_library(
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",
@ -666,7 +667,6 @@ cc_library(
"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",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
@ -694,9 +694,9 @@ cc_library(
"src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/parser.c",
"src/core/http/format_request.c",
"src/core/http/httpcli.c",
"src/core/http/parser.c",
"src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
@ -731,6 +731,8 @@ cc_library(
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
@ -1367,7 +1369,6 @@ objc_library(
"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",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
@ -1395,9 +1396,9 @@ objc_library(
"src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/parser.c",
"src/core/http/format_request.c",
"src/core/http/httpcli.c",
"src/core/http/parser.c",
"src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
@ -1432,6 +1433,8 @@ objc_library(
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
@ -1493,7 +1496,7 @@ objc_library(
"src/core/transport/static_metadata.c",
"src/core/transport/transport.c",
"src/core/transport/transport_op_string.c",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/http/httpcli_security_connector.c",
"src/core/security/b64.c",
"src/core/security/client_auth_filter.c",
"src/core/security/credentials.c",
@ -1544,7 +1547,6 @@ objc_library(
"src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
@ -1572,9 +1574,9 @@ objc_library(
"src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/parser.h",
"src/core/http/format_request.h",
"src/core/http/httpcli.h",
"src/core/http/parser.h",
"src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
@ -1606,6 +1608,7 @@ objc_library(
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",

@ -1,14 +1,28 @@
# Top-level Items by language
## Bazel
* [grpc.bzl](grpc.bzl)
## Node
* [binding.gyp](binding.gyp)
* [package.json](package.json)
## Objective-C
* [gRPC.podspec](gRPC.podspec)
## PHP
* [composer.json](composer.json)
* [config.m4](config.m4)
* [package.xml](package.xml)
## Python
* [requirements.txt](requirements.txt)
* [setup.cfg](setup.cfg)
* [setup.py](setup.py)
* [tox.ini](tox.ini)
* [PYTHON-MANIFEST.in](PYTHON-MANIFEST.in)
## Ruby
* [Gemfile](Gemfile)
* [grpc.gemspec](grpc.gemspec)
* [Rakefile](Rakefile)

@ -928,9 +928,10 @@ grpc_verify_jwt: $(BINDIR)/$(CONFIG)/grpc_verify_jwt
hpack_parser_fuzzer_test: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test
hpack_parser_test: $(BINDIR)/$(CONFIG)/hpack_parser_test
hpack_table_test: $(BINDIR)/$(CONFIG)/hpack_table_test
http_parser_test: $(BINDIR)/$(CONFIG)/http_parser_test
http_request_fuzzer_test: $(BINDIR)/$(CONFIG)/http_request_fuzzer_test
http_response_fuzzer_test: $(BINDIR)/$(CONFIG)/http_response_fuzzer_test
httpcli_format_request_test: $(BINDIR)/$(CONFIG)/httpcli_format_request_test
httpcli_fuzzer_test: $(BINDIR)/$(CONFIG)/httpcli_fuzzer_test
httpcli_parser_test: $(BINDIR)/$(CONFIG)/httpcli_parser_test
httpcli_test: $(BINDIR)/$(CONFIG)/httpcli_test
httpscli_test: $(BINDIR)/$(CONFIG)/httpscli_test
init_test: $(BINDIR)/$(CONFIG)/init_test
@ -1088,7 +1089,6 @@ h2_sockpair_1byte_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test
h2_ssl_test: $(BINDIR)/$(CONFIG)/h2_ssl_test
h2_ssl+poll_test: $(BINDIR)/$(CONFIG)/h2_ssl+poll_test
h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test
h2_uchannel_test: $(BINDIR)/$(CONFIG)/h2_uchannel_test
h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test
h2_uds+poll_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_test
h2_census_nosec_test: $(BINDIR)/$(CONFIG)/h2_census_nosec_test
@ -1102,7 +1102,6 @@ h2_proxy_nosec_test: $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test
h2_sockpair_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test
h2_sockpair+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test
h2_sockpair_1byte_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test
h2_uchannel_nosec_test: $(BINDIR)/$(CONFIG)/h2_uchannel_nosec_test
h2_uds_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds_nosec_test
h2_uds+poll_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_nosec_test
@ -1242,8 +1241,8 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/grpc_security_connector_test \
$(BINDIR)/$(CONFIG)/hpack_parser_test \
$(BINDIR)/$(CONFIG)/hpack_table_test \
$(BINDIR)/$(CONFIG)/http_parser_test \
$(BINDIR)/$(CONFIG)/httpcli_format_request_test \
$(BINDIR)/$(CONFIG)/httpcli_parser_test \
$(BINDIR)/$(CONFIG)/httpcli_test \
$(BINDIR)/$(CONFIG)/httpscli_test \
$(BINDIR)/$(CONFIG)/init_test \
@ -1311,7 +1310,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_ssl_test \
$(BINDIR)/$(CONFIG)/h2_ssl+poll_test \
$(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \
$(BINDIR)/$(CONFIG)/h2_uchannel_test \
$(BINDIR)/$(CONFIG)/h2_uds_test \
$(BINDIR)/$(CONFIG)/h2_uds+poll_test \
$(BINDIR)/$(CONFIG)/h2_census_nosec_test \
@ -1325,7 +1323,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test \
$(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test \
$(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test \
$(BINDIR)/$(CONFIG)/h2_uchannel_nosec_test \
$(BINDIR)/$(CONFIG)/h2_uds_nosec_test \
$(BINDIR)/$(CONFIG)/h2_uds+poll_nosec_test \
@ -1530,10 +1527,10 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/hpack_parser_test || ( echo test hpack_parser_test failed ; exit 1 )
$(E) "[RUN] Testing hpack_table_test"
$(Q) $(BINDIR)/$(CONFIG)/hpack_table_test || ( echo test hpack_table_test failed ; exit 1 )
$(E) "[RUN] Testing http_parser_test"
$(Q) $(BINDIR)/$(CONFIG)/http_parser_test || ( echo test http_parser_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_format_request_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_format_request_test || ( echo test httpcli_format_request_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_parser_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_parser_test || ( echo test httpcli_parser_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_test || ( echo test httpcli_test failed ; exit 1 )
$(E) "[RUN] Testing httpscli_test"
@ -1552,8 +1549,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/lame_client_test || ( echo test lame_client_test failed ; exit 1 )
$(E) "[RUN] Testing message_compress_test"
$(Q) $(BINDIR)/$(CONFIG)/message_compress_test || ( echo test message_compress_test failed ; exit 1 )
$(E) "[RUN] Testing mlog_test"
$(Q) $(BINDIR)/$(CONFIG)/mlog_test || ( echo test mlog_test failed ; exit 1 )
$(E) "[RUN] Testing multiple_server_queues_test"
$(Q) $(BINDIR)/$(CONFIG)/multiple_server_queues_test || ( echo test multiple_server_queues_test failed ; exit 1 )
$(E) "[RUN] Testing murmur_hash_test"
@ -1633,6 +1628,8 @@ test_c: buildtests_c
flaky_test_c: buildtests_c
$(E) "[RUN] Testing lb_policies_test"
$(Q) $(BINDIR)/$(CONFIG)/lb_policies_test || ( echo test lb_policies_test failed ; exit 1 )
$(E) "[RUN] Testing mlog_test"
$(Q) $(BINDIR)/$(CONFIG)/mlog_test || ( echo test mlog_test failed ; exit 1 )
test_cxx: test_zookeeper buildtests_cxx
@ -2418,7 +2415,6 @@ LIBGRPC_SRC = \
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 \
src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \
@ -2446,9 +2442,9 @@ LIBGRPC_SRC = \
src/core/compression/compression_algorithm.c \
src/core/compression/message_compress.c \
src/core/debug/trace.c \
src/core/httpcli/format_request.c \
src/core/httpcli/httpcli.c \
src/core/httpcli/parser.c \
src/core/http/format_request.c \
src/core/http/httpcli.c \
src/core/http/parser.c \
src/core/iomgr/closure.c \
src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \
@ -2483,6 +2479,8 @@ LIBGRPC_SRC = \
src/core/iomgr/timer.c \
src/core/iomgr/timer_heap.c \
src/core/iomgr/udp_server.c \
src/core/iomgr/unix_sockets_posix.c \
src/core/iomgr/unix_sockets_posix_noop.c \
src/core/iomgr/wakeup_fd_eventfd.c \
src/core/iomgr/wakeup_fd_nospecial.c \
src/core/iomgr/wakeup_fd_pipe.c \
@ -2544,7 +2542,7 @@ LIBGRPC_SRC = \
src/core/transport/static_metadata.c \
src/core/transport/transport.c \
src/core/transport/transport_op_string.c \
src/core/httpcli/httpcli_security_connector.c \
src/core/http/httpcli_security_connector.c \
src/core/security/b64.c \
src/core/security/client_auth_filter.c \
src/core/security/credentials.c \
@ -2779,7 +2777,6 @@ LIBGRPC_UNSECURE_SRC = \
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 \
src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \
@ -2807,9 +2804,9 @@ LIBGRPC_UNSECURE_SRC = \
src/core/compression/compression_algorithm.c \
src/core/compression/message_compress.c \
src/core/debug/trace.c \
src/core/httpcli/format_request.c \
src/core/httpcli/httpcli.c \
src/core/httpcli/parser.c \
src/core/http/format_request.c \
src/core/http/httpcli.c \
src/core/http/parser.c \
src/core/iomgr/closure.c \
src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \
@ -2844,6 +2841,8 @@ LIBGRPC_UNSECURE_SRC = \
src/core/iomgr/timer.c \
src/core/iomgr/timer_heap.c \
src/core/iomgr/udp_server.c \
src/core/iomgr/unix_sockets_posix.c \
src/core/iomgr/unix_sockets_posix_noop.c \
src/core/iomgr/wakeup_fd_eventfd.c \
src/core/iomgr/wakeup_fd_nospecial.c \
src/core/iomgr/wakeup_fd_pipe.c \
@ -7799,104 +7798,136 @@ endif
endif
HTTPCLI_FORMAT_REQUEST_TEST_SRC = \
test/core/httpcli/format_request_test.c \
HTTP_PARSER_TEST_SRC = \
test/core/http/parser_test.c \
HTTPCLI_FORMAT_REQUEST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_FORMAT_REQUEST_TEST_SRC))))
HTTP_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_PARSER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/httpcli_format_request_test: openssl_dep_error
$(BINDIR)/$(CONFIG)/http_parser_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(BINDIR)/$(CONFIG)/http_parser_test: $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test
$(Q) $(LD) $(LDFLAGS) $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_parser_test
endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/format_request_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
deps_http_parser_test: $(HTTP_PARSER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
-include $(HTTP_PARSER_TEST_OBJS:.o=.dep)
endif
endif
HTTP_REQUEST_FUZZER_TEST_SRC = \
test/core/httpcli/request_fuzzer.c \
HTTP_REQUEST_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_REQUEST_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/http_request_fuzzer_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/http_request_fuzzer_test: $(HTTP_REQUEST_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(HTTP_REQUEST_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -lFuzzer -o $(BINDIR)/$(CONFIG)/http_request_fuzzer_test
endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/request_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_http_request_fuzzer_test: $(HTTP_REQUEST_FUZZER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTP_REQUEST_FUZZER_TEST_OBJS:.o=.dep)
endif
endif
HTTPCLI_FUZZER_TEST_SRC = \
test/core/httpcli/fuzzer.c \
HTTP_RESPONSE_FUZZER_TEST_SRC = \
test/core/httpcli/response_fuzzer.c \
HTTPCLI_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_FUZZER_TEST_SRC))))
HTTP_RESPONSE_FUZZER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_RESPONSE_FUZZER_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/httpcli_fuzzer_test: openssl_dep_error
$(BINDIR)/$(CONFIG)/http_response_fuzzer_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/httpcli_fuzzer_test: $(HTTPCLI_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(BINDIR)/$(CONFIG)/http_response_fuzzer_test: $(HTTP_RESPONSE_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(HTTPCLI_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -lFuzzer -o $(BINDIR)/$(CONFIG)/httpcli_fuzzer_test
$(Q) $(LDXX) $(LDFLAGS) $(HTTP_RESPONSE_FUZZER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -lFuzzer -o $(BINDIR)/$(CONFIG)/http_response_fuzzer_test
endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/httpcli/response_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpcli_fuzzer_test: $(HTTPCLI_FUZZER_TEST_OBJS:.o=.dep)
deps_http_response_fuzzer_test: $(HTTP_RESPONSE_FUZZER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTPCLI_FUZZER_TEST_OBJS:.o=.dep)
-include $(HTTP_RESPONSE_FUZZER_TEST_OBJS:.o=.dep)
endif
endif
HTTPCLI_PARSER_TEST_SRC = \
test/core/httpcli/parser_test.c \
HTTPCLI_FORMAT_REQUEST_TEST_SRC = \
test/core/http/format_request_test.c \
HTTPCLI_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_PARSER_TEST_SRC))))
HTTPCLI_FORMAT_REQUEST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_FORMAT_REQUEST_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/httpcli_parser_test: openssl_dep_error
$(BINDIR)/$(CONFIG)/httpcli_format_request_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/httpcli_parser_test: $(HTTPCLI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(BINDIR)/$(CONFIG)/httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(HTTPCLI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_parser_test
$(Q) $(LD) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test
endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/format_request_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpcli_parser_test: $(HTTPCLI_PARSER_TEST_OBJS:.o=.dep)
deps_httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(HTTPCLI_PARSER_TEST_OBJS:.o=.dep)
-include $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
endif
endif
HTTPCLI_TEST_SRC = \
test/core/httpcli/httpcli_test.c \
test/core/http/httpcli_test.c \
HTTPCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@ -7916,7 +7947,7 @@ $(BINDIR)/$(CONFIG)/httpcli_test: $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgr
endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/httpcli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/httpcli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpcli_test: $(HTTPCLI_TEST_OBJS:.o=.dep)
@ -7928,7 +7959,7 @@ endif
HTTPSCLI_TEST_SRC = \
test/core/httpcli/httpscli_test.c \
test/core/http/httpscli_test.c \
HTTPSCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPSCLI_TEST_SRC))))
ifeq ($(NO_SECURE),true)
@ -7948,7 +7979,7 @@ $(BINDIR)/$(CONFIG)/httpscli_test: $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/lib
endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/httpscli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/http/httpscli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpscli_test: $(HTTPSCLI_TEST_OBJS:.o=.dep)
@ -13184,38 +13215,6 @@ endif
endif
H2_UCHANNEL_TEST_SRC = \
test/core/end2end/fixtures/h2_uchannel.c \
H2_UCHANNEL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_UCHANNEL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/h2_uchannel_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/h2_uchannel_test: $(H2_UCHANNEL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(H2_UCHANNEL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_uchannel_test
endif
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_uchannel.o: $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_h2_uchannel_test: $(H2_UCHANNEL_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(H2_UCHANNEL_TEST_OBJS:.o=.dep)
endif
endif
H2_UDS_TEST_SRC = \
test/core/end2end/fixtures/h2_uds.c \
@ -13500,26 +13499,6 @@ ifneq ($(NO_DEPS),true)
endif
H2_UCHANNEL_NOSEC_TEST_SRC = \
test/core/end2end/fixtures/h2_uchannel.c \
H2_UCHANNEL_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_UCHANNEL_NOSEC_TEST_SRC))))
$(BINDIR)/$(CONFIG)/h2_uchannel_nosec_test: $(H2_UCHANNEL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(H2_UCHANNEL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_uchannel_nosec_test
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_uchannel.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_h2_uchannel_nosec_test: $(H2_UCHANNEL_NOSEC_TEST_OBJS:.o=.dep)
ifneq ($(NO_DEPS),true)
-include $(H2_UCHANNEL_NOSEC_TEST_OBJS:.o=.dep)
endif
H2_UDS_NOSEC_TEST_SRC = \
test/core/end2end/fixtures/h2_uds.c \
@ -13568,7 +13547,7 @@ ifneq ($(OPENSSL_DEP),)
# This is to ensure the embedded OpenSSL is built beforehand, properly
# installing headers to their final destination on the drive. We need this
# otherwise parallel compilation will fail if a source is compiled first.
src/core/httpcli/httpcli_security_connector.c: $(OPENSSL_DEP)
src/core/http/httpcli_security_connector.c: $(OPENSSL_DEP)
src/core/security/b64.c: $(OPENSSL_DEP)
src/core/security/client_auth_filter.c: $(OPENSSL_DEP)
src/core/security/credentials.c: $(OPENSSL_DEP)

@ -565,7 +565,6 @@
'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',
'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c',
@ -593,9 +592,9 @@
'src/core/compression/compression_algorithm.c',
'src/core/compression/message_compress.c',
'src/core/debug/trace.c',
'src/core/httpcli/format_request.c',
'src/core/httpcli/httpcli.c',
'src/core/httpcli/parser.c',
'src/core/http/format_request.c',
'src/core/http/httpcli.c',
'src/core/http/parser.c',
'src/core/iomgr/closure.c',
'src/core/iomgr/endpoint.c',
'src/core/iomgr/endpoint_pair_posix.c',
@ -630,6 +629,8 @@
'src/core/iomgr/timer.c',
'src/core/iomgr/timer_heap.c',
'src/core/iomgr/udp_server.c',
'src/core/iomgr/unix_sockets_posix.c',
'src/core/iomgr/unix_sockets_posix_noop.c',
'src/core/iomgr/wakeup_fd_eventfd.c',
'src/core/iomgr/wakeup_fd_nospecial.c',
'src/core/iomgr/wakeup_fd_pipe.c',
@ -691,7 +692,7 @@
'src/core/transport/static_metadata.c',
'src/core/transport/transport.c',
'src/core/transport/transport_op_string.c',
'src/core/httpcli/httpcli_security_connector.c',
'src/core/http/httpcli_security_connector.c',
'src/core/security/b64.c',
'src/core/security/client_auth_filter.c',
'src/core/security/credentials.c',

@ -253,7 +253,6 @@ filegroups:
- src/core/channel/channel_stack.h
- src/core/channel/channel_stack_builder.h
- src/core/channel/client_channel.h
- src/core/channel/client_uchannel.h
- src/core/channel/compress_filter.h
- src/core/channel/connected_channel.h
- src/core/channel/context.h
@ -281,9 +280,9 @@ filegroups:
- src/core/compression/algorithm_metadata.h
- src/core/compression/message_compress.h
- src/core/debug/trace.h
- src/core/httpcli/format_request.h
- src/core/httpcli/httpcli.h
- src/core/httpcli/parser.h
- src/core/http/format_request.h
- src/core/http/httpcli.h
- src/core/http/parser.h
- src/core/iomgr/closure.h
- src/core/iomgr/endpoint.h
- src/core/iomgr/endpoint_pair.h
@ -315,6 +314,7 @@ filegroups:
- src/core/iomgr/timer.h
- src/core/iomgr/timer_heap.h
- src/core/iomgr/udp_server.h
- src/core/iomgr/unix_sockets_posix.h
- src/core/iomgr/wakeup_fd_pipe.h
- src/core/iomgr/wakeup_fd_posix.h
- src/core/iomgr/workqueue.h
@ -375,7 +375,6 @@ filegroups:
- 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
- src/core/channel/connected_channel.c
- src/core/channel/http_client_filter.c
@ -403,9 +402,9 @@ filegroups:
- src/core/compression/compression_algorithm.c
- src/core/compression/message_compress.c
- src/core/debug/trace.c
- src/core/httpcli/format_request.c
- src/core/httpcli/httpcli.c
- src/core/httpcli/parser.c
- src/core/http/format_request.c
- src/core/http/httpcli.c
- src/core/http/parser.c
- src/core/iomgr/closure.c
- src/core/iomgr/endpoint.c
- src/core/iomgr/endpoint_pair_posix.c
@ -440,6 +439,8 @@ filegroups:
- src/core/iomgr/timer.c
- src/core/iomgr/timer_heap.c
- src/core/iomgr/udp_server.c
- src/core/iomgr/unix_sockets_posix.c
- src/core/iomgr/unix_sockets_posix_noop.c
- src/core/iomgr/wakeup_fd_eventfd.c
- src/core/iomgr/wakeup_fd_nospecial.c
- src/core/iomgr/wakeup_fd_pipe.c
@ -526,7 +527,7 @@ filegroups:
- src/core/tsi/transport_security.h
- src/core/tsi/transport_security_interface.h
src:
- src/core/httpcli/httpcli_security_connector.c
- src/core/http/httpcli_security_connector.c
- src/core/security/b64.c
- src/core/security/client_auth_filter.c
- src/core/security/credentials.c
@ -1574,33 +1575,45 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: httpcli_format_request_test
- name: http_parser_test
build: test
language: c
src:
- test/core/httpcli/format_request_test.c
- test/core/http/parser_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: http_request_fuzzer_test
build: fuzzer
language: c
src:
- test/core/httpcli/request_fuzzer.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: httpcli_fuzzer_test
corpus_dirs:
- test/core/http/request_corpus
- name: http_response_fuzzer_test
build: fuzzer
language: c
src:
- test/core/httpcli/fuzzer.c
- test/core/httpcli/response_fuzzer.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
corpus_dirs:
- test/core/httpcli/corpus
- name: httpcli_parser_test
- test/core/http/response_corpus
- name: httpcli_format_request_test
build: test
language: c
src:
- test/core/httpcli/parser_test.c
- test/core/http/format_request_test.c
deps:
- grpc_test_util
- grpc
@ -1611,7 +1624,7 @@ targets:
build: test
language: c
src:
- test/core/httpcli/httpcli_test.c
- test/core/http/httpcli_test.c
deps:
- grpc_test_util
- grpc
@ -1626,7 +1639,7 @@ targets:
build: test
language: c
src:
- test/core/httpcli/httpscli_test.c
- test/core/http/httpscli_test.c
deps:
- grpc_test_util
- grpc
@ -1752,6 +1765,7 @@ targets:
- gpr_test_util
- gpr
- name: mlog_test
flaky: true
build: test
language: c
src:

@ -87,7 +87,6 @@ if test "$PHP_GRPC" != "no"; then
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 \
src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \
@ -115,9 +114,9 @@ if test "$PHP_GRPC" != "no"; then
src/core/compression/compression_algorithm.c \
src/core/compression/message_compress.c \
src/core/debug/trace.c \
src/core/httpcli/format_request.c \
src/core/httpcli/httpcli.c \
src/core/httpcli/parser.c \
src/core/http/format_request.c \
src/core/http/httpcli.c \
src/core/http/parser.c \
src/core/iomgr/closure.c \
src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \
@ -152,6 +151,8 @@ if test "$PHP_GRPC" != "no"; then
src/core/iomgr/timer.c \
src/core/iomgr/timer_heap.c \
src/core/iomgr/udp_server.c \
src/core/iomgr/unix_sockets_posix.c \
src/core/iomgr/unix_sockets_posix_noop.c \
src/core/iomgr/wakeup_fd_eventfd.c \
src/core/iomgr/wakeup_fd_nospecial.c \
src/core/iomgr/wakeup_fd_pipe.c \
@ -213,7 +214,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/transport/static_metadata.c \
src/core/transport/transport.c \
src/core/transport/transport_op_string.c \
src/core/httpcli/httpcli_security_connector.c \
src/core/http/httpcli_security_connector.c \
src/core/security/b64.c \
src/core/security/client_auth_filter.c \
src/core/security/credentials.c \
@ -552,7 +553,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/client_config/resolvers)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/compression)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/debug)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/httpcli)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/http)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/iomgr)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/json)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/profiling)

@ -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
@ -29,6 +29,8 @@
"""The Python implementation of the GRPC helloworld.Greeter client."""
from __future__ import print_function
from grpc.beta import implementations
import helloworld_pb2
@ -40,7 +42,7 @@ def run():
channel = implementations.insecure_channel('localhost', 50051)
stub = helloworld_pb2.beta_create_Greeter_stub(channel)
response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'), _TIMEOUT_SECONDS)
print "Greeter client received: " + response.message
print("Greeter client received: " + response.message)
if __name__ == '__main__':

@ -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
@ -29,6 +29,8 @@
"""The Python implementation of the gRPC route guide client."""
from __future__ import print_function
import random
import time
@ -49,13 +51,13 @@ def make_route_note(message, latitude, longitude):
def guide_get_one_feature(stub, point):
feature = stub.GetFeature(point, _TIMEOUT_SECONDS)
if not feature.location:
print "Server returned incomplete feature"
print("Server returned incomplete feature")
return
if feature.name:
print "Feature called %s at %s" % (feature.name, feature.location)
print("Feature called %s at %s" % (feature.name, feature.location))
else:
print "Found no feature at %s" % feature.location
print("Found no feature at %s" % feature.location)
def guide_get_feature(stub):
@ -69,18 +71,18 @@ def guide_list_features(stub):
latitude=400000000, longitude = -750000000),
hi=route_guide_pb2.Point(
latitude = 420000000, longitude = -730000000))
print "Looking for features between 40, -75 and 42, -73"
print("Looking for features between 40, -75 and 42, -73")
features = stub.ListFeatures(rect, _TIMEOUT_SECONDS)
for feature in features:
print "Feature called %s at %s" % (feature.name, feature.location)
print("Feature called %s at %s" % (feature.name, feature.location))
def generate_route(feature_list):
for _ in range(0, 10):
random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
print "Visiting point %s" % random_feature.location
print("Visiting point %s" % random_feature.location)
yield random_feature.location
time.sleep(random.uniform(0.5, 1.5))
@ -90,10 +92,10 @@ def guide_record_route(stub):
route_iter = generate_route(feature_list)
route_summary = stub.RecordRoute(route_iter, _TIMEOUT_SECONDS)
print "Finished trip with %s points " % route_summary.point_count
print "Passed %s features " % route_summary.feature_count
print "Travelled %s meters " % route_summary.distance
print "It took %s seconds " % route_summary.elapsed_time
print("Finished trip with %s points " % route_summary.point_count)
print("Passed %s features " % route_summary.feature_count)
print("Travelled %s meters " % route_summary.distance)
print("It took %s seconds " % route_summary.elapsed_time)
def generate_messages():
@ -105,7 +107,7 @@ def generate_messages():
make_route_note("Fifth message", 1, 0),
]
for msg in messages:
print "Sending %s at %s" % (msg.message, msg.location)
print("Sending %s at %s" % (msg.message, msg.location))
yield msg
time.sleep(random.uniform(0.5, 1.0))
@ -113,19 +115,19 @@ def generate_messages():
def guide_route_chat(stub):
responses = stub.RouteChat(generate_messages(), _TIMEOUT_SECONDS)
for response in responses:
print "Received message %s at %s" % (response.message, response.location)
print("Received message %s at %s" % (response.message, response.location))
def run():
channel = implementations.insecure_channel('localhost', 50051)
stub = route_guide_pb2.beta_create_RouteGuide_stub(channel)
print "-------------- GetFeature --------------"
print("-------------- GetFeature --------------")
guide_get_feature(stub)
print "-------------- ListFeatures --------------"
print("-------------- ListFeatures --------------")
guide_list_features(stub)
print "-------------- RecordRoute --------------"
print("-------------- RecordRoute --------------")
guide_record_route(stub)
print "-------------- RouteChat --------------"
print("-------------- RouteChat --------------")
guide_route_chat(stub)

@ -167,7 +167,6 @@ Pod::Spec.new do |s|
'src/core/channel/channel_stack.h',
'src/core/channel/channel_stack_builder.h',
'src/core/channel/client_channel.h',
'src/core/channel/client_uchannel.h',
'src/core/channel/compress_filter.h',
'src/core/channel/connected_channel.h',
'src/core/channel/context.h',
@ -195,9 +194,9 @@ Pod::Spec.new do |s|
'src/core/compression/algorithm_metadata.h',
'src/core/compression/message_compress.h',
'src/core/debug/trace.h',
'src/core/httpcli/format_request.h',
'src/core/httpcli/httpcli.h',
'src/core/httpcli/parser.h',
'src/core/http/format_request.h',
'src/core/http/httpcli.h',
'src/core/http/parser.h',
'src/core/iomgr/closure.h',
'src/core/iomgr/endpoint.h',
'src/core/iomgr/endpoint_pair.h',
@ -229,6 +228,7 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.h',
'src/core/iomgr/timer_heap.h',
'src/core/iomgr/udp_server.h',
'src/core/iomgr/unix_sockets_posix.h',
'src/core/iomgr/wakeup_fd_pipe.h',
'src/core/iomgr/wakeup_fd_posix.h',
'src/core/iomgr/workqueue.h',
@ -322,7 +322,6 @@ Pod::Spec.new do |s|
'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',
'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c',
@ -350,9 +349,9 @@ Pod::Spec.new do |s|
'src/core/compression/compression_algorithm.c',
'src/core/compression/message_compress.c',
'src/core/debug/trace.c',
'src/core/httpcli/format_request.c',
'src/core/httpcli/httpcli.c',
'src/core/httpcli/parser.c',
'src/core/http/format_request.c',
'src/core/http/httpcli.c',
'src/core/http/parser.c',
'src/core/iomgr/closure.c',
'src/core/iomgr/endpoint.c',
'src/core/iomgr/endpoint_pair_posix.c',
@ -387,6 +386,8 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.c',
'src/core/iomgr/timer_heap.c',
'src/core/iomgr/udp_server.c',
'src/core/iomgr/unix_sockets_posix.c',
'src/core/iomgr/unix_sockets_posix_noop.c',
'src/core/iomgr/wakeup_fd_eventfd.c',
'src/core/iomgr/wakeup_fd_nospecial.c',
'src/core/iomgr/wakeup_fd_pipe.c',
@ -448,7 +449,7 @@ Pod::Spec.new do |s|
'src/core/transport/static_metadata.c',
'src/core/transport/transport.c',
'src/core/transport/transport_op_string.c',
'src/core/httpcli/httpcli_security_connector.c',
'src/core/http/httpcli_security_connector.c',
'src/core/security/b64.c',
'src/core/security/client_auth_filter.c',
'src/core/security/credentials.c',
@ -497,7 +498,6 @@ Pod::Spec.new do |s|
'src/core/channel/channel_stack.h',
'src/core/channel/channel_stack_builder.h',
'src/core/channel/client_channel.h',
'src/core/channel/client_uchannel.h',
'src/core/channel/compress_filter.h',
'src/core/channel/connected_channel.h',
'src/core/channel/context.h',
@ -525,9 +525,9 @@ Pod::Spec.new do |s|
'src/core/compression/algorithm_metadata.h',
'src/core/compression/message_compress.h',
'src/core/debug/trace.h',
'src/core/httpcli/format_request.h',
'src/core/httpcli/httpcli.h',
'src/core/httpcli/parser.h',
'src/core/http/format_request.h',
'src/core/http/httpcli.h',
'src/core/http/parser.h',
'src/core/iomgr/closure.h',
'src/core/iomgr/endpoint.h',
'src/core/iomgr/endpoint_pair.h',
@ -559,6 +559,7 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.h',
'src/core/iomgr/timer_heap.h',
'src/core/iomgr/udp_server.h',
'src/core/iomgr/unix_sockets_posix.h',
'src/core/iomgr/wakeup_fd_pipe.h',
'src/core/iomgr/wakeup_fd_posix.h',
'src/core/iomgr/workqueue.h',

@ -163,7 +163,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/channel/channel_stack.h )
s.files += %w( src/core/channel/channel_stack_builder.h )
s.files += %w( src/core/channel/client_channel.h )
s.files += %w( src/core/channel/client_uchannel.h )
s.files += %w( src/core/channel/compress_filter.h )
s.files += %w( src/core/channel/connected_channel.h )
s.files += %w( src/core/channel/context.h )
@ -191,9 +190,9 @@ Gem::Specification.new do |s|
s.files += %w( src/core/compression/algorithm_metadata.h )
s.files += %w( src/core/compression/message_compress.h )
s.files += %w( src/core/debug/trace.h )
s.files += %w( src/core/httpcli/format_request.h )
s.files += %w( src/core/httpcli/httpcli.h )
s.files += %w( src/core/httpcli/parser.h )
s.files += %w( src/core/http/format_request.h )
s.files += %w( src/core/http/httpcli.h )
s.files += %w( src/core/http/parser.h )
s.files += %w( src/core/iomgr/closure.h )
s.files += %w( src/core/iomgr/endpoint.h )
s.files += %w( src/core/iomgr/endpoint_pair.h )
@ -225,6 +224,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/iomgr/timer.h )
s.files += %w( src/core/iomgr/timer_heap.h )
s.files += %w( src/core/iomgr/udp_server.h )
s.files += %w( src/core/iomgr/unix_sockets_posix.h )
s.files += %w( src/core/iomgr/wakeup_fd_pipe.h )
s.files += %w( src/core/iomgr/wakeup_fd_posix.h )
s.files += %w( src/core/iomgr/workqueue.h )
@ -305,7 +305,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/channel/channel_stack.c )
s.files += %w( src/core/channel/channel_stack_builder.c )
s.files += %w( src/core/channel/client_channel.c )
s.files += %w( src/core/channel/client_uchannel.c )
s.files += %w( src/core/channel/compress_filter.c )
s.files += %w( src/core/channel/connected_channel.c )
s.files += %w( src/core/channel/http_client_filter.c )
@ -333,9 +332,9 @@ Gem::Specification.new do |s|
s.files += %w( src/core/compression/compression_algorithm.c )
s.files += %w( src/core/compression/message_compress.c )
s.files += %w( src/core/debug/trace.c )
s.files += %w( src/core/httpcli/format_request.c )
s.files += %w( src/core/httpcli/httpcli.c )
s.files += %w( src/core/httpcli/parser.c )
s.files += %w( src/core/http/format_request.c )
s.files += %w( src/core/http/httpcli.c )
s.files += %w( src/core/http/parser.c )
s.files += %w( src/core/iomgr/closure.c )
s.files += %w( src/core/iomgr/endpoint.c )
s.files += %w( src/core/iomgr/endpoint_pair_posix.c )
@ -370,6 +369,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/iomgr/timer.c )
s.files += %w( src/core/iomgr/timer_heap.c )
s.files += %w( src/core/iomgr/udp_server.c )
s.files += %w( src/core/iomgr/unix_sockets_posix.c )
s.files += %w( src/core/iomgr/unix_sockets_posix_noop.c )
s.files += %w( src/core/iomgr/wakeup_fd_eventfd.c )
s.files += %w( src/core/iomgr/wakeup_fd_nospecial.c )
s.files += %w( src/core/iomgr/wakeup_fd_pipe.c )
@ -431,7 +432,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/transport/static_metadata.c )
s.files += %w( src/core/transport/transport.c )
s.files += %w( src/core/transport/transport_op_string.c )
s.files += %w( src/core/httpcli/httpcli_security_connector.c )
s.files += %w( src/core/http/httpcli_security_connector.c )
s.files += %w( src/core/security/b64.c )
s.files += %w( src/core/security/client_auth_filter.c )
s.files += %w( src/core/security/credentials.c )

@ -99,8 +99,8 @@ class SerializationTraits<ByteBuffer, void> {
}
static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer,
bool* own_buffer) {
*buffer = source.buffer();
*own_buffer = false;
*buffer = grpc_byte_buffer_copy(source.buffer());
*own_buffer = true;
return Status::OK;
}
};

@ -133,6 +133,7 @@
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_MSG_NOSIGNAL 1
#define GPR_HAVE_UNIX_SOCKET 1
#elif defined(__linux__)
#define GPR_POSIX_CRASH_HANDLER 1
#define GPR_PLATFORM_STRING "linux"
@ -154,6 +155,7 @@
#define GPR_POSIX_WAKEUP_FD 1
#define GPR_POSIX_SOCKET 1
#define GPR_POSIX_SOCKETADDR 1
#define GPR_HAVE_UNIX_SOCKET 1
#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 9)
#define GPR_LINUX_EVENTFD 1
@ -214,6 +216,7 @@
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_SO_NOSIGPIPE 1
#define GPR_HAVE_UNIX_SOCKET 1
#ifdef _LP64
#define GPR_ARCH_64 1
#else /* _LP64 */
@ -242,6 +245,7 @@
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_SO_NOSIGPIPE 1
#define GPR_HAVE_UNIX_SOCKET 1
#ifdef _LP64
#define GPR_ARCH_64 1
#else /* _LP64 */

@ -105,7 +105,6 @@
"src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
@ -133,9 +132,9 @@
"src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/parser.h",
"src/core/http/format_request.h",
"src/core/http/httpcli.h",
"src/core/http/parser.h",
"src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
@ -167,6 +166,7 @@
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",
@ -247,7 +247,6 @@
"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",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
@ -275,9 +274,9 @@
"src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/parser.c",
"src/core/http/format_request.c",
"src/core/http/httpcli.c",
"src/core/http/parser.c",
"src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
@ -312,6 +311,8 @@
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
@ -373,7 +374,7 @@
"src/core/transport/static_metadata.c",
"src/core/transport/transport.c",
"src/core/transport/transport_op_string.c",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/http/httpcli_security_connector.c",
"src/core/security/b64.c",
"src/core/security/client_auth_filter.c",
"src/core/security/credentials.c",

@ -167,7 +167,6 @@
<file baseinstalldir="/" name="src/core/channel/channel_stack.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/channel_stack_builder.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/client_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/client_uchannel.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/compress_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/connected_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/context.h" role="src" />
@ -195,9 +194,9 @@
<file baseinstalldir="/" name="src/core/compression/algorithm_metadata.h" role="src" />
<file baseinstalldir="/" name="src/core/compression/message_compress.h" role="src" />
<file baseinstalldir="/" name="src/core/debug/trace.h" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/format_request.h" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/httpcli.h" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/parser.h" role="src" />
<file baseinstalldir="/" name="src/core/http/format_request.h" role="src" />
<file baseinstalldir="/" name="src/core/http/httpcli.h" role="src" />
<file baseinstalldir="/" name="src/core/http/parser.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/closure.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/endpoint.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/endpoint_pair.h" role="src" />
@ -229,6 +228,7 @@
<file baseinstalldir="/" name="src/core/iomgr/timer.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/timer_heap.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/udp_server.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_pipe.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/workqueue.h" role="src" />
@ -309,7 +309,6 @@
<file baseinstalldir="/" name="src/core/channel/channel_stack.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/channel_stack_builder.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/client_channel.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/client_uchannel.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/compress_filter.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/connected_channel.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/http_client_filter.c" role="src" />
@ -337,9 +336,9 @@
<file baseinstalldir="/" name="src/core/compression/compression_algorithm.c" role="src" />
<file baseinstalldir="/" name="src/core/compression/message_compress.c" role="src" />
<file baseinstalldir="/" name="src/core/debug/trace.c" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/format_request.c" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/httpcli.c" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/parser.c" role="src" />
<file baseinstalldir="/" name="src/core/http/format_request.c" role="src" />
<file baseinstalldir="/" name="src/core/http/httpcli.c" role="src" />
<file baseinstalldir="/" name="src/core/http/parser.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/closure.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/endpoint.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/endpoint_pair_posix.c" role="src" />
@ -374,6 +373,8 @@
<file baseinstalldir="/" name="src/core/iomgr/timer.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/timer_heap.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/udp_server.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix_noop.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_eventfd.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_nospecial.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_pipe.c" role="src" />
@ -435,7 +436,7 @@
<file baseinstalldir="/" name="src/core/transport/static_metadata.c" role="src" />
<file baseinstalldir="/" name="src/core/transport/transport.c" role="src" />
<file baseinstalldir="/" name="src/core/transport/transport_op_string.c" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/httpcli_security_connector.c" role="src" />
<file baseinstalldir="/" name="src/core/http/httpcli_security_connector.c" role="src" />
<file baseinstalldir="/" name="src/core/security/b64.c" role="src" />
<file baseinstalldir="/" name="src/core/security/client_auth_filter.c" role="src" />
<file baseinstalldir="/" name="src/core/security/credentials.c" role="src" />

@ -111,7 +111,7 @@ if "linux" in sys.platform or "darwin" in sys.platform:
DEFINE_MACROS += (('PyMODINIT_FUNC', pymodinit),)
def cython_extensions(package_names, module_names, extra_sources, include_dirs,
def cython_extensions(module_names, extra_sources, include_dirs,
libraries, define_macros, build_with_cython=False):
# Set compiler directives linetrace argument only if we care about tracing;
# this is due to Cython having different behavior between linetrace being
@ -144,7 +144,7 @@ def cython_extensions(package_names, module_names, extra_sources, include_dirs,
return extensions
CYTHON_EXTENSION_MODULES = cython_extensions(
list(CYTHON_EXTENSION_PACKAGE_NAMES), list(CYTHON_EXTENSION_MODULE_NAMES),
list(CYTHON_EXTENSION_MODULE_NAMES),
list(CYTHON_HELPER_C_FILES) + list(CORE_C_FILES),
list(EXTENSION_INCLUDE_DIRECTORIES), list(EXTENSION_LIBRARIES),
list(DEFINE_MACROS), bool(BUILD_WITH_CYTHON))

@ -83,6 +83,28 @@ grpc::string FilenameIdentifier(const grpc::string &filename) {
}
} // namespace
template<class T, size_t N>
T *array_end(T (&array)[N]) { return array + N; }
void PrintIncludes(grpc::protobuf::io::Printer *printer, const std::vector<grpc::string>& headers, const Parameters &params) {
std::map<grpc::string, grpc::string> vars;
vars["l"] = params.use_system_headers ? '<' : '"';
vars["r"] = params.use_system_headers ? '>' : '"';
if (!params.grpc_search_path.empty()) {
vars["l"] += params.grpc_search_path;
if (params.grpc_search_path.back() != '/') {
vars["l"] += '/';
}
}
for (auto i = headers.begin(); i != headers.end(); i++) {
vars["h"] = *i;
printer->Print(vars, "#include $l$$h$$r$\n");
}
}
grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string output;
@ -111,36 +133,46 @@ grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) {
grpc::string temp =
"#include <grpc++/impl/codegen/async_stream.h>\n"
"#include <grpc++/impl/codegen/async_unary_call.h>\n"
"#include <grpc++/impl/codegen/proto_utils.h>\n"
"#include <grpc++/impl/codegen/rpc_method.h>\n"
"#include <grpc++/impl/codegen/service_type.h>\n"
"#include <grpc++/impl/codegen/status.h>\n"
"#include <grpc++/impl/codegen/stub_options.h>\n"
"#include <grpc++/impl/codegen/sync_stream.h>\n"
"\n"
"namespace grpc {\n"
"class CompletionQueue;\n"
"class RpcService;\n"
"class ServerCompletionQueue;\n"
"class ServerContext;\n"
"} // namespace grpc\n\n";
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
grpc::protobuf::io::StringOutputStream output_stream(&output);
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
if (!file->package().empty()) {
std::vector<grpc::string> parts =
grpc_generator::tokenize(file->package(), ".");
static const char *headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
"grpc++/impl/codegen/async_unary_call.h",
"grpc++/impl/codegen/proto_utils.h",
"grpc++/impl/codegen/rpc_method.h",
"grpc++/impl/codegen/service_type.h",
"grpc++/impl/codegen/status.h",
"grpc++/impl/codegen/stub_options.h",
"grpc++/impl/codegen/sync_stream.h"
};
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
PrintIncludes(&printer, headers, params);
printer.Print(vars, "\n");
printer.Print(vars, "namespace grpc {\n");
printer.Print(vars, "class CompletionQueue;\n");
printer.Print(vars, "class Channel;\n");
printer.Print(vars, "class RpcService;\n");
printer.Print(vars, "class ServerCompletionQueue;\n");
printer.Print(vars, "class ServerContext;\n");
printer.Print(vars, "} // namespace grpc\n\n");
for (auto part = parts.begin(); part != parts.end(); part++) {
temp.append("namespace ");
temp.append(*part);
temp.append(" {\n");
if (!file->package().empty()) {
std::vector<grpc::string> parts =
grpc_generator::tokenize(file->package(), ".");
for (auto part = parts.begin(); part != parts.end(); part++) {
vars["part"] = *part;
printer.Print(vars, "namespace $part$ {\n");
}
printer.Print(vars, "\n");
}
temp.append("\n");
}
return temp;
return output;
}
void PrintHeaderClientMethodInterfaces(
@ -852,7 +884,7 @@ grpc::string GetSourcePrologue(const grpc::protobuf::FileDescriptor *file,
}
grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
const Parameters &param) {
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
@ -860,16 +892,18 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars;
printer.Print(vars, "#include <grpc++/impl/codegen/async_stream.h>\n");
printer.Print(vars, "#include <grpc++/impl/codegen/async_unary_call.h>\n");
printer.Print(vars, "#include <grpc++/impl/codegen/channel_interface.h>\n");
printer.Print(vars, "#include <grpc++/impl/codegen/client_unary_call.h>\n");
printer.Print(vars,
"#include <grpc++/impl/codegen/method_handler_impl.h>\n");
printer.Print(vars,
"#include <grpc++/impl/codegen/rpc_service_method.h>\n");
printer.Print(vars, "#include <grpc++/impl/codegen/service_type.h>\n");
printer.Print(vars, "#include <grpc++/impl/codegen/sync_stream.h>\n");
static const char *headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
"grpc++/impl/codegen/async_unary_call.h",
"grpc++/impl/codegen/channel_interface.h",
"grpc++/impl/codegen/client_unary_call.h",
"grpc++/impl/codegen/method_handler_impl.h",
"grpc++/impl/codegen/rpc_service_method.h",
"grpc++/impl/codegen/service_type.h",
"grpc++/impl/codegen/sync_stream.h"
};
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
PrintIncludes(&printer, headers, params);
if (!file->package().empty()) {
std::vector<grpc::string> parts =

@ -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
@ -42,6 +42,10 @@ namespace grpc_cpp_generator {
struct Parameters {
// Puts the service into a namespace
grpc::string services_namespace;
// Use system includes (<>) or local includes ("")
bool use_system_headers;
// Prefix to any grpc include
grpc::string grpc_search_path;
};
// Return the prologue of the generated header file.

@ -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,6 +59,7 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
}
grpc_cpp_generator::Parameters generator_parameters;
generator_parameters.use_system_headers = true;
if (!parameter.empty()) {
std::vector<grpc::string> parameters_list =
@ -70,6 +71,17 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
grpc_generator::tokenize(*parameter_string, "=");
if (param[0] == "services_namespace") {
generator_parameters.services_namespace = param[1];
} else if (param[0] == "use_system_headers") {
if (param[1] == "true") {
generator_parameters.use_system_headers = true;
} else if (param[1] == "false") {
generator_parameters.use_system_headers = false;
} else {
*error = grpc::string("Invalid parameter: ") + *parameter_string;
return false;
}
} else if (param[0] == "grpc_search_path") {
generator_parameters.grpc_search_path = param[1];
} else {
*error = grpc::string("Unknown parameter: ") + *parameter_string;
return false;

@ -190,11 +190,10 @@ bool PrintBetaServicer(const ServiceDescriptor* service,
"Documentation", doc,
});
out->Print("\n");
out->Print(dict, "class Beta$Service$Servicer(object):\n");
out->Print(dict, "class Beta$Service$Servicer(six.with_metaclass(abc.ABCMeta, object)):\n");
{
IndentScope raii_class_indent(out);
out->Print(dict, "\"\"\"$Documentation$\"\"\"\n");
out->Print("__metaclass__ = abc.ABCMeta\n");
for (int i = 0; i < service->method_count(); ++i) {
auto meth = service->method(i);
grpc::string arg_name = meth->client_streaming() ?
@ -219,11 +218,10 @@ bool PrintBetaStub(const ServiceDescriptor* service,
"Documentation", doc,
});
out->Print("\n");
out->Print(dict, "class Beta$Service$Stub(object):\n");
out->Print(dict, "class Beta$Service$Stub(six.with_metaclass(abc.ABCMeta, object)):\n");
{
IndentScope raii_class_indent(out);
out->Print(dict, "\"\"\"$Documentation$\"\"\"\n");
out->Print("__metaclass__ = abc.ABCMeta\n");
for (int i = 0; i < service->method_count(); ++i) {
const MethodDescriptor* meth = service->method(i);
grpc::string arg_name = meth->client_streaming() ?
@ -449,6 +447,7 @@ bool PrintBetaStubFactory(const grpc::string& package_qualified_service_name,
bool PrintPreamble(const FileDescriptor* file,
const GeneratorConfiguration& config, Printer* out) {
out->Print("import abc\n");
out->Print("import six\n");
out->Print("from $Package$ import implementations as beta_implementations\n",
"Package", config.beta_package_root);
out->Print("from grpc.framework.common import cardinality\n");

@ -63,8 +63,6 @@ void census_grpc_plugin_init(void) {
}
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);
}

@ -216,7 +216,6 @@ void *grpc_channel_stack_builder_finish(grpc_exec_ctx *exec_ctx,
// 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++;
}

@ -1,233 +0,0 @@
/*
*
* 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/channel/client_uchannel.h"
#include <string.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/subchannel_call_holder.h"
#include "src/core/iomgr/iomgr.h"
#include "src/core/support/string.h"
#include "src/core/surface/channel.h"
#include "src/core/transport/connectivity_state.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
/** Microchannel (uchannel) implementation: a lightweight channel without any
* load-balancing mechanisms meant for communication from within the core. */
typedef struct client_uchannel_channel_data {
/** master channel - the grpc_channel instance that ultimately owns
this channel_data via its channel stack.
We occasionally use this to bump the refcount on the master channel
to keep ourselves alive through an asynchronous operation. */
grpc_channel_stack *owning_stack;
/** connectivity state being tracked */
grpc_connectivity_state_tracker state_tracker;
/** the subchannel wrapped by the microchannel */
grpc_connected_subchannel *connected_subchannel;
/** the callback used to stay subscribed to subchannel connectivity
* notifications */
grpc_closure connectivity_cb;
/** the current connectivity state of the wrapped subchannel */
grpc_connectivity_state subchannel_connectivity;
gpr_mu mu_state;
} channel_data;
typedef grpc_subchannel_call_holder call_data;
static void monitor_subchannel(grpc_exec_ctx *exec_ctx, void *arg,
bool iomgr_success) {
channel_data *chand = arg;
grpc_connectivity_state_set(exec_ctx, &chand->state_tracker,
chand->subchannel_connectivity,
"uchannel_monitor_subchannel");
grpc_connected_subchannel_notify_on_state_change(
exec_ctx, chand->connected_subchannel, NULL,
&chand->subchannel_connectivity, &chand->connectivity_cb);
}
static char *cuc_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
return grpc_subchannel_call_holder_get_peer(exec_ctx, elem->call_data);
}
static void cuc_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
grpc_transport_stream_op *op) {
GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
grpc_subchannel_call_holder_perform_op(exec_ctx, elem->call_data, op);
}
static void cuc_start_transport_op(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_transport_op *op) {
channel_data *chand = elem->channel_data;
grpc_exec_ctx_enqueue(exec_ctx, op->on_consumed, true, NULL);
GPR_ASSERT(op->set_accept_stream == false);
GPR_ASSERT(op->bind_pollset == NULL);
if (op->on_connectivity_state_change != NULL) {
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &chand->state_tracker, op->connectivity_state,
op->on_connectivity_state_change);
op->on_connectivity_state_change = NULL;
op->connectivity_state = NULL;
}
if (op->disconnect) {
grpc_connectivity_state_set(exec_ctx, &chand->state_tracker,
GRPC_CHANNEL_FATAL_FAILURE, "disconnect");
}
}
static int cuc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *arg,
grpc_metadata_batch *initial_metadata,
grpc_connected_subchannel **connected_subchannel,
grpc_closure *on_ready) {
channel_data *chand = arg;
GPR_ASSERT(initial_metadata != NULL);
*connected_subchannel = chand->connected_subchannel;
return 1;
}
/* Constructor for call_data */
static void cuc_init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_call_element_args *args) {
grpc_subchannel_call_holder_init(elem->call_data, cuc_pick_subchannel,
elem->channel_data, args->call_stack);
}
/* Destructor for call_data */
static void cuc_destroy_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem) {
grpc_subchannel_call_holder_destroy(exec_ctx, elem->call_data);
}
/* Constructor for channel_data */
static void cuc_init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_channel_element_args *args) {
channel_data *chand = elem->channel_data;
memset(chand, 0, sizeof(*chand));
grpc_closure_init(&chand->connectivity_cb, monitor_subchannel, chand);
GPR_ASSERT(args->is_last);
GPR_ASSERT(elem->filter == &grpc_client_uchannel_filter);
chand->owning_stack = args->channel_stack;
grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE,
"client_uchannel");
gpr_mu_init(&chand->mu_state);
}
/* Destructor for channel_data */
static void cuc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {
channel_data *chand = elem->channel_data;
/* cancel subscription */
grpc_connected_subchannel_notify_on_state_change(
exec_ctx, chand->connected_subchannel, NULL, NULL,
&chand->connectivity_cb);
grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker);
gpr_mu_destroy(&chand->mu_state);
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, chand->connected_subchannel,
"uchannel");
}
static void cuc_set_pollset(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_pollset *pollset) {
call_data *calld = elem->call_data;
calld->pollset = pollset;
}
const grpc_channel_filter grpc_client_uchannel_filter = {
cuc_start_transport_stream_op, cuc_start_transport_op, sizeof(call_data),
cuc_init_call_elem, cuc_set_pollset, cuc_destroy_call_elem,
sizeof(channel_data), cuc_init_channel_elem, cuc_destroy_channel_elem,
cuc_get_peer, "client-uchannel",
};
grpc_connectivity_state grpc_client_uchannel_check_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect) {
channel_data *chand = elem->channel_data;
grpc_connectivity_state out;
gpr_mu_lock(&chand->mu_state);
out = grpc_connectivity_state_check(&chand->state_tracker);
gpr_mu_unlock(&chand->mu_state);
return out;
}
void grpc_client_uchannel_watch_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset,
grpc_connectivity_state *state, grpc_closure *on_complete) {
channel_data *chand = elem->channel_data;
gpr_mu_lock(&chand->mu_state);
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &chand->state_tracker, state, on_complete);
gpr_mu_unlock(&chand->mu_state);
}
grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
grpc_channel_args *args) {
grpc_channel *channel = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
channel =
grpc_channel_create(&exec_ctx, NULL, args, GRPC_CLIENT_UCHANNEL, NULL);
return channel;
}
void grpc_client_uchannel_set_connected_subchannel(
grpc_channel *uchannel, grpc_connected_subchannel *connected_subchannel) {
grpc_channel_element *elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(uchannel));
channel_data *chand = elem->channel_data;
GPR_ASSERT(elem->filter == &grpc_client_uchannel_filter);
gpr_mu_lock(&chand->mu_state);
chand->connected_subchannel = connected_subchannel;
GRPC_CONNECTED_SUBCHANNEL_REF(connected_subchannel, "uchannel");
gpr_mu_unlock(&chand->mu_state);
}

@ -55,15 +55,14 @@ typedef enum {
for initial metadata before trying to create a call object,
and handling cancellation gracefully.
Both the channel and uchannel filter use this as their call_data. */
The channel filter uses this as their call_data. */
typedef struct grpc_subchannel_call_holder {
/** either 0 for no call, 1 for cancelled, or a pointer to a
grpc_subchannel_call */
gpr_atm subchannel_call;
/** Helper function to choose the subchannel on which to create
the call object. Channel filter delegates to the load
balancing policy (once it's ready); uchannel returns
immediately */
balancing policy (once it's ready). */
grpc_subchannel_call_holder_pick_subchannel pick_subchannel;
void *pick_subchannel_arg;

@ -42,8 +42,14 @@
#include "src/core/client_config/lb_policy_registry.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/timer.h"
#include "src/core/support/backoff.h"
#include "src/core/support/string.h"
#define BACKOFF_MULTIPLIER 1.6
#define BACKOFF_JITTER 0.2
#define BACKOFF_MIN_SECONDS 1
#define BACKOFF_MAX_SECONDS 120
typedef struct {
/** base class: must be first */
grpc_resolver base;
@ -75,6 +81,8 @@ typedef struct {
/** retry timer */
bool have_retry_timer;
grpc_timer retry_timer;
/** retry backoff state */
gpr_backoff backoff_state;
} dns_resolver;
static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
@ -111,6 +119,7 @@ static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx,
dns_resolver *r = (dns_resolver *)resolver;
gpr_mu_lock(&r->mu);
if (!r->resolving) {
gpr_backoff_reset(&r->backoff_state);
dns_start_resolving_locked(r);
}
gpr_mu_unlock(&r->mu);
@ -125,6 +134,7 @@ static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
r->next_completion = on_complete;
r->target_config = target_config;
if (r->resolved_version == 0 && !r->resolving) {
gpr_backoff_reset(&r->backoff_state);
dns_start_resolving_locked(r);
} else {
dns_maybe_finish_next_locked(exec_ctx, r);
@ -185,17 +195,16 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
grpc_resolved_addresses_destroy(addresses);
gpr_free(subchannels);
} else {
int retry_seconds = 15;
gpr_log(GPR_DEBUG, "dns resolution failed: retrying in %d seconds",
retry_seconds);
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
gpr_timespec timeout = gpr_time_sub(next_try, now);
gpr_log(GPR_DEBUG, "dns resolution failed: retrying in %d.%09d seconds",
timeout.tv_sec, timeout.tv_nsec);
GPR_ASSERT(!r->have_retry_timer);
r->have_retry_timer = true;
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
GRPC_RESOLVER_REF(&r->base, "retry-timer");
grpc_timer_init(
exec_ctx, &r->retry_timer,
gpr_time_add(now, gpr_time_from_seconds(retry_seconds, GPR_TIMESPAN)),
dns_on_retry_timer, r, now);
grpc_timer_init(exec_ctx, &r->retry_timer, next_try, dns_on_retry_timer, r,
now);
}
if (r->resolved_config) {
grpc_client_config_unref(exec_ctx, r->resolved_config);
@ -263,6 +272,8 @@ static grpc_resolver *dns_create(grpc_resolver_args *args,
r->name = gpr_strdup(path);
r->default_port = gpr_strdup(default_port);
r->subchannel_factory = args->subchannel_factory;
gpr_backoff_init(&r->backoff_state, BACKOFF_MULTIPLIER, BACKOFF_JITTER,
BACKOFF_MIN_SECONDS * 1000, BACKOFF_MAX_SECONDS * 1000);
grpc_subchannel_factory_ref(r->subchannel_factory);
r->lb_policy_name = gpr_strdup(lb_policy_name);
return &r->base;

@ -37,9 +37,6 @@
#include <stdio.h>
#include <string.h>
#ifdef GPR_POSIX_SOCKET
#include <sys/un.h>
#endif
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
@ -47,6 +44,7 @@
#include "src/core/client_config/lb_policy_registry.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
typedef struct {
@ -168,24 +166,6 @@ static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
gpr_free(r);
}
#ifdef GPR_POSIX_SOCKET
static int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr,
size_t *len) {
struct sockaddr_un *un = (struct sockaddr_un *)addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, uri->path);
*len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return 1;
}
static char *unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return gpr_strdup("localhost");
}
#endif
static char *ip_get_default_authority(grpc_uri *uri) {
const char *path = uri->path;
if (path[0] == '/') ++path;
@ -371,21 +351,22 @@ static void sockaddr_factory_ref(grpc_resolver_factory *factory) {}
static void sockaddr_factory_unref(grpc_resolver_factory *factory) {}
#define DECL_FACTORY(name) \
#define DECL_FACTORY(name, prefix) \
static grpc_resolver *name##_factory_create_resolver( \
grpc_resolver_factory *factory, grpc_resolver_args *args) { \
return sockaddr_create(args, "pick_first", parse_##name); \
return sockaddr_create(args, "pick_first", prefix##parse_##name); \
} \
static const grpc_resolver_factory_vtable name##_factory_vtable = { \
sockaddr_factory_ref, sockaddr_factory_unref, \
name##_factory_create_resolver, name##_get_default_authority, #name}; \
name##_factory_create_resolver, prefix##name##_get_default_authority, \
#name}; \
static grpc_resolver_factory name##_resolver_factory = { \
&name##_factory_vtable}; \
grpc_resolver_factory *grpc_##name##_resolver_factory_create() { \
return &name##_resolver_factory; \
}
#ifdef GPR_POSIX_SOCKET
DECL_FACTORY(unix)
#ifdef GPR_HAVE_UNIX_SOCKET
DECL_FACTORY(unix, grpc_)
#endif
DECL_FACTORY(ipv4) DECL_FACTORY(ipv6)
DECL_FACTORY(ipv4, ) DECL_FACTORY(ipv6, )

@ -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 @@
*
*/
#include "src/core/httpcli/format_request.h"
#include "src/core/http/format_request.h"
#include <stdarg.h>
#include <stdio.h>
@ -46,7 +46,7 @@
static void fill_common_header(const grpc_httpcli_request *request,
gpr_strvec *buf) {
size_t i;
gpr_strvec_add(buf, gpr_strdup(request->path));
gpr_strvec_add(buf, gpr_strdup(request->http.path));
gpr_strvec_add(buf, gpr_strdup(" HTTP/1.0\r\n"));
/* just in case some crazy server really expects HTTP/1.1 */
gpr_strvec_add(buf, gpr_strdup("Host: "));
@ -56,10 +56,10 @@ static void fill_common_header(const grpc_httpcli_request *request,
gpr_strvec_add(buf,
gpr_strdup("User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n"));
/* user supplied headers */
for (i = 0; i < request->hdr_count; i++) {
gpr_strvec_add(buf, gpr_strdup(request->hdrs[i].key));
for (i = 0; i < request->http.hdr_count; i++) {
gpr_strvec_add(buf, gpr_strdup(request->http.hdrs[i].key));
gpr_strvec_add(buf, gpr_strdup(": "));
gpr_strvec_add(buf, gpr_strdup(request->hdrs[i].value));
gpr_strvec_add(buf, gpr_strdup(request->http.hdrs[i].value));
gpr_strvec_add(buf, gpr_strdup("\r\n"));
}
}
@ -94,8 +94,8 @@ gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
fill_common_header(request, &out);
if (body_bytes) {
uint8_t has_content_type = 0;
for (i = 0; i < request->hdr_count; i++) {
if (strcmp(request->hdrs[i].key, "Content-Type") == 0) {
for (i = 0; i < request->http.hdr_count; i++) {
if (strcmp(request->http.hdrs[i].key, "Content-Type") == 0) {
has_content_type = 1;
break;
}

@ -31,10 +31,10 @@
*
*/
#ifndef GRPC_CORE_HTTPCLI_FORMAT_REQUEST_H
#define GRPC_CORE_HTTPCLI_FORMAT_REQUEST_H
#ifndef GRPC_CORE_HTTP_FORMAT_REQUEST_H
#define GRPC_CORE_HTTP_FORMAT_REQUEST_H
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/httpcli.h"
#include <grpc/support/slice.h>
gpr_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request);
@ -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_CORE_HTTPCLI_FORMAT_REQUEST_H */
#endif /* GRPC_CORE_HTTP_FORMAT_REQUEST_H */

@ -31,7 +31,7 @@
*
*/
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/httpcli.h"
#include "src/core/iomgr/sockaddr.h"
#include <string.h>
@ -40,8 +40,8 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/httpcli/format_request.h"
#include "src/core/httpcli/parser.h"
#include "src/core/http/format_request.h"
#include "src/core/http/parser.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/resolve_address.h"
@ -50,7 +50,7 @@
typedef struct {
gpr_slice request_text;
grpc_httpcli_parser parser;
grpc_http_parser parser;
grpc_resolved_addresses *addresses;
size_t next_address;
grpc_endpoint *ep;
@ -99,8 +99,9 @@ static void finish(grpc_exec_ctx *exec_ctx, internal_request *req,
int success) {
grpc_pollset_set_del_pollset(exec_ctx, req->context->pollset_set,
req->pollset);
req->on_response(exec_ctx, req->user_data, success ? &req->parser.r : NULL);
grpc_httpcli_parser_destroy(&req->parser);
req->on_response(exec_ctx, req->user_data,
success ? &req->parser.http.response : NULL);
grpc_http_parser_destroy(&req->parser);
if (req->addresses != NULL) {
grpc_resolved_addresses_destroy(req->addresses);
}
@ -129,7 +130,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, bool success) {
for (i = 0; i < req->incoming.count; i++) {
if (GPR_SLICE_LENGTH(req->incoming.slices[i])) {
req->have_read_byte = 1;
if (!grpc_httpcli_parser_parse(&req->parser, req->incoming.slices[i])) {
if (!grpc_http_parser_parse(&req->parser, req->incoming.slices[i])) {
finish(exec_ctx, req, 0);
return;
}
@ -141,7 +142,11 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, bool success) {
} else if (!req->have_read_byte) {
next_address(exec_ctx, req);
} else {
finish(exec_ctx, req, grpc_httpcli_parser_eof(&req->parser));
int parse_success = grpc_http_parser_eof(&req->parser);
if (parse_success && (req->parser.type != GRPC_HTTP_RESPONSE)) {
parse_success = 0;
}
finish(exec_ctx, req, parse_success);
}
}
@ -223,7 +228,7 @@ static void internal_request_begin(
internal_request *req = gpr_malloc(sizeof(internal_request));
memset(req, 0, sizeof(*req));
req->request_text = request_text;
grpc_httpcli_parser_init(&req->parser);
grpc_http_parser_init(&req->parser);
req->on_response = on_response;
req->user_data = user_data;
req->deadline = deadline;
@ -255,7 +260,7 @@ void grpc_httpcli_get(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
g_get_override(exec_ctx, request, deadline, on_response, user_data)) {
return;
}
gpr_asprintf(&name, "HTTP:GET:%s:%s", request->host, request->path);
gpr_asprintf(&name, "HTTP:GET:%s:%s", request->host, request->http.path);
internal_request_begin(exec_ctx, context, pollset, request, deadline,
on_response, user_data, name,
grpc_httpcli_format_get_request(request));
@ -274,7 +279,7 @@ void grpc_httpcli_post(grpc_exec_ctx *exec_ctx, grpc_httpcli_context *context,
on_response, user_data)) {
return;
}
gpr_asprintf(&name, "HTTP:POST:%s:%s", request->host, request->path);
gpr_asprintf(&name, "HTTP:POST:%s:%s", request->host, request->http.path);
internal_request_begin(
exec_ctx, context, pollset, request, deadline, on_response, user_data,
name, grpc_httpcli_format_post_request(request, body_bytes, body_size));

@ -31,27 +31,20 @@
*
*/
#ifndef GRPC_CORE_HTTPCLI_HTTPCLI_H
#define GRPC_CORE_HTTPCLI_HTTPCLI_H
#ifndef GRPC_CORE_HTTP_HTTPCLI_H
#define GRPC_CORE_HTTP_HTTPCLI_H
#include <stddef.h>
#include <grpc/support/time.h>
#include "src/core/http/parser.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/pollset_set.h"
/* User agent this library reports */
#define GRPC_HTTPCLI_USER_AGENT "grpc-httpcli/0.0"
/* Maximum length of a header string of the form 'Key: Value\r\n' */
#define GRPC_HTTPCLI_MAX_HEADER_LENGTH 4096
/* A single header to be passed in a request */
typedef struct grpc_httpcli_header {
char *key;
char *value;
} grpc_httpcli_header;
/* Tracks in-progress http requests
TODO(ctiller): allow caching and capturing multiple requests for the
@ -77,33 +70,21 @@ typedef struct grpc_httpcli_request {
char *host;
/* The host to verify in the SSL handshake (or NULL) */
char *ssl_host_override;
/* The path of the resource to fetch */
char *path;
/* Additional headers: count and key/values; the following are supplied
automatically and MUST NOT be set here:
/* The main part of the request
The following headers are supplied automatically and MUST NOT be set here:
Host, Connection, User-Agent */
size_t hdr_count;
grpc_httpcli_header *hdrs;
grpc_http_request http;
/* handshaker to use ssl for the request */
const grpc_httpcli_handshaker *handshaker;
} grpc_httpcli_request;
/* A response */
typedef struct grpc_httpcli_response {
/* HTTP status code */
int status;
/* Headers: count and key/values */
size_t hdr_count;
grpc_httpcli_header *hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
char *body;
} grpc_httpcli_response;
/* Expose the parser response type as a httpcli response too */
typedef struct grpc_http_response grpc_httpcli_response;
/* Callback for grpc_httpcli_get and grpc_httpcli_post. */
typedef void (*grpc_httpcli_response_cb)(grpc_exec_ctx *exec_ctx,
void *user_data,
const grpc_httpcli_response *response);
const grpc_http_response *response);
void grpc_httpcli_context_init(grpc_httpcli_context *context);
void grpc_httpcli_context_destroy(grpc_httpcli_context *context);
@ -160,4 +141,4 @@ typedef int (*grpc_httpcli_post_override)(
void grpc_httpcli_set_override(grpc_httpcli_get_override get,
grpc_httpcli_post_override post);
#endif /* GRPC_CORE_HTTPCLI_HTTPCLI_H */
#endif /* GRPC_CORE_HTTP_HTTPCLI_H */

@ -31,7 +31,7 @@
*
*/
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/httpcli.h"
#include <string.h>

@ -0,0 +1,313 @@
/*
*
* 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/http/parser.h"
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1);
memcpy(out, buffer, length);
out[length] = 0;
return out;
}
static int handle_response_line(grpc_http_parser *parser) {
uint8_t *beg = parser->cur_line;
uint8_t *cur = beg;
uint8_t *end = beg + parser->cur_line_length;
if (cur == end || *cur++ != 'H') goto error;
if (cur == end || *cur++ != 'T') goto error;
if (cur == end || *cur++ != 'T') goto error;
if (cur == end || *cur++ != 'P') goto error;
if (cur == end || *cur++ != '/') goto error;
if (cur == end || *cur++ != '1') goto error;
if (cur == end || *cur++ != '.') goto error;
if (cur == end || *cur < '0' || *cur++ > '1') goto error;
if (cur == end || *cur++ != ' ') goto error;
if (cur == end || *cur < '1' || *cur++ > '9') goto error;
if (cur == end || *cur < '0' || *cur++ > '9') goto error;
if (cur == end || *cur < '0' || *cur++ > '9') goto error;
parser->http.response.status =
(cur[-3] - '0') * 100 + (cur[-2] - '0') * 10 + (cur[-1] - '0');
if (cur == end || *cur++ != ' ') goto error;
/* we don't really care about the status code message */
return 1;
error:
gpr_log(GPR_ERROR, "Failed parsing response line");
return 0;
}
static int handle_request_line(grpc_http_parser *parser) {
uint8_t *beg = parser->cur_line;
uint8_t *cur = beg;
uint8_t *end = beg + parser->cur_line_length;
uint8_t vers_major = 0;
uint8_t vers_minor = 0;
while (cur != end && *cur++ != ' ')
;
if (cur == end) goto error;
parser->http.request.method = buf2str(beg, (size_t)(cur - beg - 1));
beg = cur;
while (cur != end && *cur++ != ' ')
;
if (cur == end) goto error;
parser->http.request.path = buf2str(beg, (size_t)(cur - beg - 1));
if (cur == end || *cur++ != 'H') goto error;
if (cur == end || *cur++ != 'T') goto error;
if (cur == end || *cur++ != 'T') goto error;
if (cur == end || *cur++ != 'P') goto error;
if (cur == end || *cur++ != '/') goto error;
vers_major = (uint8_t)(*cur++ - '1' + 1);
++cur;
if (cur == end) goto error;
vers_minor = (uint8_t)(*cur++ - '1' + 1);
if (vers_major == 1) {
if (vers_minor == 0) {
parser->http.request.version = GRPC_HTTP_HTTP10;
} else if (vers_minor == 1) {
parser->http.request.version = GRPC_HTTP_HTTP11;
} else {
goto error;
}
} else if (vers_major == 2) {
if (vers_minor == 0) {
parser->http.request.version = GRPC_HTTP_HTTP20;
} else {
goto error;
}
} else {
goto error;
}
return 1;
error:
gpr_log(GPR_ERROR, "Failed parsing request line");
return 0;
}
static int handle_first_line(grpc_http_parser *parser) {
if (parser->cur_line[0] == 'H') {
parser->type = GRPC_HTTP_RESPONSE;
return handle_response_line(parser);
} else {
parser->type = GRPC_HTTP_REQUEST;
return handle_request_line(parser);
}
}
static int add_header(grpc_http_parser *parser) {
uint8_t *beg = parser->cur_line;
uint8_t *cur = beg;
uint8_t *end = beg + parser->cur_line_length;
size_t *hdr_count = NULL;
grpc_http_header **hdrs = NULL;
grpc_http_header hdr = {NULL, NULL};
GPR_ASSERT(cur != end);
if (*cur == ' ' || *cur == '\t') {
gpr_log(GPR_ERROR, "Continued header lines not supported yet");
goto error;
}
while (cur != end && *cur != ':') {
cur++;
}
if (cur == end) {
gpr_log(GPR_ERROR, "Didn't find ':' in header string");
goto error;
}
GPR_ASSERT(cur >= beg);
hdr.key = buf2str(beg, (size_t)(cur - beg));
cur++; /* skip : */
while (cur != end && (*cur == ' ' || *cur == '\t')) {
cur++;
}
GPR_ASSERT(end - cur >= 2);
hdr.value = buf2str(cur, (size_t)(end - cur) - 2);
if (parser->type == GRPC_HTTP_RESPONSE) {
hdr_count = &parser->http.response.hdr_count;
hdrs = &parser->http.response.hdrs;
} else if (parser->type == GRPC_HTTP_REQUEST) {
hdr_count = &parser->http.request.hdr_count;
hdrs = &parser->http.request.hdrs;
} else {
return 0;
}
if (*hdr_count == parser->hdr_capacity) {
parser->hdr_capacity =
GPR_MAX(parser->hdr_capacity + 1, parser->hdr_capacity * 3 / 2);
*hdrs = gpr_realloc(*hdrs, parser->hdr_capacity * sizeof(**hdrs));
}
(*hdrs)[(*hdr_count)++] = hdr;
return 1;
error:
gpr_free(hdr.key);
gpr_free(hdr.value);
return 0;
}
static int finish_line(grpc_http_parser *parser) {
switch (parser->state) {
case GRPC_HTTP_FIRST_LINE:
if (!handle_first_line(parser)) {
return 0;
}
parser->state = GRPC_HTTP_HEADERS;
break;
case GRPC_HTTP_HEADERS:
if (parser->cur_line_length == 2) {
parser->state = GRPC_HTTP_BODY;
break;
}
if (!add_header(parser)) {
return 0;
}
break;
case GRPC_HTTP_BODY:
GPR_UNREACHABLE_CODE(return 0);
}
parser->cur_line_length = 0;
return 1;
}
static int addbyte_body(grpc_http_parser *parser, uint8_t byte) {
size_t *body_length = NULL;
char **body = NULL;
if (parser->type == GRPC_HTTP_RESPONSE) {
body_length = &parser->http.response.body_length;
body = &parser->http.response.body;
} else if (parser->type == GRPC_HTTP_REQUEST) {
body_length = &parser->http.request.body_length;
body = &parser->http.request.body;
} else {
return 0;
}
if (*body_length == parser->body_capacity) {
parser->body_capacity = GPR_MAX(8, parser->body_capacity * 3 / 2);
*body = gpr_realloc((void *)*body, parser->body_capacity);
}
(*body)[*body_length] = (char)byte;
(*body_length)++;
return 1;
}
static int addbyte(grpc_http_parser *parser, uint8_t byte) {
switch (parser->state) {
case GRPC_HTTP_FIRST_LINE:
case GRPC_HTTP_HEADERS:
if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) {
gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
return 0;
}
parser->cur_line[parser->cur_line_length] = byte;
parser->cur_line_length++;
if (parser->cur_line_length >= 2 &&
parser->cur_line[parser->cur_line_length - 2] == '\r' &&
parser->cur_line[parser->cur_line_length - 1] == '\n') {
return finish_line(parser);
} else {
return 1;
}
GPR_UNREACHABLE_CODE(return 0);
case GRPC_HTTP_BODY:
return addbyte_body(parser, byte);
}
GPR_UNREACHABLE_CODE(return 0);
}
void grpc_http_parser_init(grpc_http_parser *parser) {
memset(parser, 0, sizeof(*parser));
parser->state = GRPC_HTTP_FIRST_LINE;
parser->type = GRPC_HTTP_UNKNOWN;
}
void grpc_http_parser_destroy(grpc_http_parser *parser) {
size_t i;
if (parser->type == GRPC_HTTP_RESPONSE) {
gpr_free(parser->http.response.body);
for (i = 0; i < parser->http.response.hdr_count; i++) {
gpr_free(parser->http.response.hdrs[i].key);
gpr_free(parser->http.response.hdrs[i].value);
}
gpr_free(parser->http.response.hdrs);
} else if (parser->type == GRPC_HTTP_REQUEST) {
gpr_free(parser->http.request.body);
for (i = 0; i < parser->http.request.hdr_count; i++) {
gpr_free(parser->http.request.hdrs[i].key);
gpr_free(parser->http.request.hdrs[i].value);
}
gpr_free(parser->http.request.hdrs);
gpr_free(parser->http.request.method);
gpr_free(parser->http.request.path);
}
}
int grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice) {
size_t i;
for (i = 0; i < GPR_SLICE_LENGTH(slice); i++) {
if (!addbyte(parser, GPR_SLICE_START_PTR(slice)[i])) {
return 0;
}
}
return 1;
}
int grpc_http_parser_eof(grpc_http_parser *parser) {
return parser->state == GRPC_HTTP_BODY;
}

@ -0,0 +1,116 @@
/*
*
* 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_HTTP_PARSER_H
#define GRPC_CORE_HTTP_PARSER_H
#include <grpc/support/port_platform.h>
#include <grpc/support/slice.h>
/* Maximum length of a header string of the form 'Key: Value\r\n' */
#define GRPC_HTTP_PARSER_MAX_HEADER_LENGTH 4096
/* A single header to be passed in a request */
typedef struct grpc_http_header {
char *key;
char *value;
} grpc_http_header;
typedef enum {
GRPC_HTTP_FIRST_LINE,
GRPC_HTTP_HEADERS,
GRPC_HTTP_BODY
} grpc_http_parser_state;
typedef enum {
GRPC_HTTP_HTTP10,
GRPC_HTTP_HTTP11,
GRPC_HTTP_HTTP20,
} grpc_http_version;
typedef enum {
GRPC_HTTP_RESPONSE,
GRPC_HTTP_REQUEST,
GRPC_HTTP_UNKNOWN
} grpc_http_type;
/* A request */
typedef struct grpc_http_request {
/* Method of the request (e.g. GET, POST) */
char *method;
/* The path of the resource to fetch */
char *path;
/* HTTP version to use */
grpc_http_version version;
/* Headers attached to the request */
size_t hdr_count;
grpc_http_header *hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
char *body;
} grpc_http_request;
/* A response */
typedef struct grpc_http_response {
/* HTTP status code */
int status;
/* Headers: count and key/values */
size_t hdr_count;
grpc_http_header *hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
char *body;
} grpc_http_response;
typedef struct {
grpc_http_parser_state state;
grpc_http_type type;
union {
grpc_http_response response;
grpc_http_request request;
} http;
size_t body_capacity;
size_t hdr_capacity;
uint8_t cur_line[GRPC_HTTP_PARSER_MAX_HEADER_LENGTH];
size_t cur_line_length;
} grpc_http_parser;
void grpc_http_parser_init(grpc_http_parser *parser);
void grpc_http_parser_destroy(grpc_http_parser *parser);
int grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice);
int grpc_http_parser_eof(grpc_http_parser *parser);
#endif /* GRPC_CORE_HTTP_PARSER_H */

@ -1,219 +0,0 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/httpcli/parser.h"
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
extern int grpc_http_trace;
static int handle_response_line(grpc_httpcli_parser *parser) {
uint8_t *beg = parser->cur_line;
uint8_t *cur = beg;
uint8_t *end = beg + parser->cur_line_length;
if (cur == end || *cur++ != 'H') goto error;
if (cur == end || *cur++ != 'T') goto error;
if (cur == end || *cur++ != 'T') goto error;
if (cur == end || *cur++ != 'P') goto error;
if (cur == end || *cur++ != '/') goto error;
if (cur == end || *cur++ != '1') goto error;
if (cur == end || *cur++ != '.') goto error;
if (cur == end || *cur < '0' || *cur++ > '1') goto error;
if (cur == end || *cur++ != ' ') goto error;
if (cur == end || *cur < '1' || *cur++ > '9') goto error;
if (cur == end || *cur < '0' || *cur++ > '9') goto error;
if (cur == end || *cur < '0' || *cur++ > '9') goto error;
parser->r.status =
(cur[-3] - '0') * 100 + (cur[-2] - '0') * 10 + (cur[-1] - '0');
if (cur == end || *cur++ != ' ') goto error;
/* we don't really care about the status code message */
return 1;
error:
if (grpc_http_trace) {
gpr_log(GPR_ERROR, "Failed parsing response line");
}
return 0;
}
static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1);
memcpy(out, buffer, length);
out[length] = 0;
return out;
}
static int add_header(grpc_httpcli_parser *parser) {
uint8_t *beg = parser->cur_line;
uint8_t *cur = beg;
uint8_t *end = beg + parser->cur_line_length;
grpc_httpcli_header hdr = {NULL, NULL};
GPR_ASSERT(cur != end);
if (*cur == ' ' || *cur == '\t') {
if (grpc_http_trace) {
gpr_log(GPR_ERROR, "Continued header lines not supported yet");
}
goto error;
}
while (cur != end && *cur != ':') {
cur++;
}
if (cur == end) {
if (grpc_http_trace) {
gpr_log(GPR_ERROR, "Didn't find ':' in header string");
}
goto error;
}
GPR_ASSERT(cur >= beg);
hdr.key = buf2str(beg, (size_t)(cur - beg));
cur++; /* skip : */
while (cur != end && (*cur == ' ' || *cur == '\t')) {
cur++;
}
GPR_ASSERT(end - cur >= 2);
hdr.value = buf2str(cur, (size_t)(end - cur) - 2);
if (parser->r.hdr_count == parser->hdr_capacity) {
parser->hdr_capacity =
GPR_MAX(parser->hdr_capacity + 1, parser->hdr_capacity * 3 / 2);
parser->r.hdrs = gpr_realloc(
parser->r.hdrs, parser->hdr_capacity * sizeof(*parser->r.hdrs));
}
parser->r.hdrs[parser->r.hdr_count++] = hdr;
return 1;
error:
gpr_free(hdr.key);
gpr_free(hdr.value);
return 0;
}
static int finish_line(grpc_httpcli_parser *parser) {
switch (parser->state) {
case GRPC_HTTPCLI_INITIAL_RESPONSE:
if (!handle_response_line(parser)) {
return 0;
}
parser->state = GRPC_HTTPCLI_HEADERS;
break;
case GRPC_HTTPCLI_HEADERS:
if (parser->cur_line_length == 2) {
parser->state = GRPC_HTTPCLI_BODY;
break;
}
if (!add_header(parser)) {
return 0;
}
break;
case GRPC_HTTPCLI_BODY:
GPR_UNREACHABLE_CODE(return 0);
}
parser->cur_line_length = 0;
return 1;
}
static int addbyte(grpc_httpcli_parser *parser, uint8_t byte) {
switch (parser->state) {
case GRPC_HTTPCLI_INITIAL_RESPONSE:
case GRPC_HTTPCLI_HEADERS:
if (parser->cur_line_length >= GRPC_HTTPCLI_MAX_HEADER_LENGTH) {
gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
GRPC_HTTPCLI_MAX_HEADER_LENGTH);
return 0;
}
parser->cur_line[parser->cur_line_length] = byte;
parser->cur_line_length++;
if (parser->cur_line_length >= 2 &&
parser->cur_line[parser->cur_line_length - 2] == '\r' &&
parser->cur_line[parser->cur_line_length - 1] == '\n') {
return finish_line(parser);
} else {
return 1;
}
GPR_UNREACHABLE_CODE(return 0);
case GRPC_HTTPCLI_BODY:
if (parser->r.body_length == parser->body_capacity) {
parser->body_capacity = GPR_MAX(8, parser->body_capacity * 3 / 2);
parser->r.body =
gpr_realloc((void *)parser->r.body, parser->body_capacity);
}
parser->r.body[parser->r.body_length] = (char)byte;
parser->r.body_length++;
return 1;
}
GPR_UNREACHABLE_CODE(return 0);
}
void grpc_httpcli_parser_init(grpc_httpcli_parser *parser) {
memset(parser, 0, sizeof(*parser));
parser->state = GRPC_HTTPCLI_INITIAL_RESPONSE;
parser->r.status = 500;
}
void grpc_httpcli_parser_destroy(grpc_httpcli_parser *parser) {
size_t i;
gpr_free(parser->r.body);
for (i = 0; i < parser->r.hdr_count; i++) {
gpr_free(parser->r.hdrs[i].key);
gpr_free(parser->r.hdrs[i].value);
}
gpr_free(parser->r.hdrs);
}
int grpc_httpcli_parser_parse(grpc_httpcli_parser *parser, gpr_slice slice) {
size_t i;
for (i = 0; i < GPR_SLICE_LENGTH(slice); i++) {
if (!addbyte(parser, GPR_SLICE_START_PTR(slice)[i])) {
return 0;
}
}
return 1;
}
int grpc_httpcli_parser_eof(grpc_httpcli_parser *parser) {
return parser->state == GRPC_HTTPCLI_BODY;
}

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -37,6 +37,7 @@
#include "src/core/iomgr/endpoint_pair.h"
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include <errno.h>
#include <fcntl.h>
@ -52,7 +53,7 @@
static void create_sockets(int sv[2]) {
int flags;
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
grpc_create_socketpair_if_unix(sv);
flags = fcntl(sv[0], F_GETFL, 0);
GPR_ASSERT(fcntl(sv[0], F_SETFL, flags | O_NONBLOCK) == 0);
flags = fcntl(sv[1], F_GETFL, 0);

@ -72,9 +72,6 @@ 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;
@ -95,6 +92,7 @@ static grpc_fd *alloc_fd(int fd) {
gpr_mu_init(&r->mu);
}
gpr_mu_lock(&r->mu);
r->shutdown = 0;
r->read_closure = CLOSURE_NOT_READY;
r->write_closure = CLOSURE_NOT_READY;
@ -106,11 +104,9 @@ 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);
gpr_mu_unlock(&r->mu);
return r;
}

@ -39,7 +39,6 @@
#include <string.h>
#include <sys/types.h>
#include <sys/un.h>
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
@ -51,6 +50,7 @@
#include "src/core/iomgr/executor.h"
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/block_annotate.h"
#include "src/core/support/string.h"
@ -71,18 +71,10 @@ static grpc_resolved_addresses *blocking_resolve_address_impl(
int s;
size_t i;
grpc_resolved_addresses *addrs = NULL;
struct sockaddr_un *un;
if (name[0] == 'u' && name[1] == 'n' && name[2] == 'i' && name[3] == 'x' &&
name[4] == ':' && name[5] != 0) {
addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
addrs->naddrs = 1;
addrs->addrs = gpr_malloc(sizeof(grpc_resolved_address));
un = (struct sockaddr_un *)addrs->addrs->addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, name + 5);
addrs->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return addrs;
return grpc_resolve_unix_domain_address(name + 5);
}
/* parse name, splitting it into host and port parts */

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,16 +36,13 @@
#include <errno.h>
#include <string.h>
#ifdef GPR_POSIX_SOCKET
#include <sys/un.h>
#endif
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
static const uint8_t kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
@ -191,14 +188,9 @@ char *grpc_sockaddr_to_uri(const struct sockaddr *addr) {
gpr_asprintf(&result, "ipv6:%s", temp);
gpr_free(temp);
return result;
#ifdef GPR_POSIX_SOCKET
case AF_UNIX:
gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un *)addr)->sun_path);
return result;
#endif
default:
return grpc_sockaddr_to_uri_unix_if_possible(addr);
}
return NULL;
}
int grpc_sockaddr_get_port(const struct sockaddr *addr) {
@ -207,9 +199,10 @@ int grpc_sockaddr_get_port(const struct sockaddr *addr) {
return ntohs(((struct sockaddr_in *)addr)->sin_port);
case AF_INET6:
return ntohs(((struct sockaddr_in6 *)addr)->sin6_port);
case AF_UNIX:
return 1;
default:
if (grpc_is_unix_socket(addr)) {
return 1;
}
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_get_port",
addr->sa_family);
return 0;

@ -54,6 +54,7 @@
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/tcp_posix.h"
#include "src/core/iomgr/timer.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
extern int grpc_tcp_trace;
@ -77,13 +78,12 @@ static int prepare_socket(const struct sockaddr *addr, int fd) {
}
if (!grpc_set_socket_nonblocking(fd, 1) || !grpc_set_socket_cloexec(fd, 1) ||
(addr->sa_family != AF_UNIX && !grpc_set_socket_low_latency(fd, 1)) ||
(!grpc_is_unix_socket(addr) && !grpc_set_socket_low_latency(fd, 1)) ||
!grpc_set_socket_no_sigpipe_if_possible(fd)) {
gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd,
strerror(errno));
goto error;
}
return 1;
error:

@ -52,7 +52,6 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include "src/core/iomgr/pollset_posix.h"
@ -60,6 +59,7 @@
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/tcp_posix.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -81,7 +81,6 @@ struct grpc_tcp_listener {
union {
uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr;
struct sockaddr_un un;
} addr;
size_t addr_len;
int port;
@ -98,14 +97,6 @@ struct grpc_tcp_listener {
int is_sibling;
};
static void unlink_if_unix_domain_socket(const struct sockaddr_un *un) {
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
unlink(un->sun_path);
}
}
/* the overall server */
struct grpc_tcp_server {
gpr_refcount refs;
@ -203,9 +194,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
if (s->head) {
grpc_tcp_listener *sp;
for (sp = s->head; sp; sp = sp->next) {
if (sp->addr.sockaddr.sa_family == AF_UNIX) {
unlink_if_unix_domain_socket(&sp->addr.un);
}
grpc_unlink_if_unix_domain_socket(&sp->addr.sockaddr);
sp->destroyed_closure.cb = destroyed_port;
sp->destroyed_closure.cb_arg = s;
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
@ -281,7 +270,7 @@ static int prepare_socket(int fd, const struct sockaddr *addr,
}
if (!grpc_set_socket_nonblocking(fd, 1) || !grpc_set_socket_cloexec(fd, 1) ||
(addr->sa_family != AF_UNIX && (!grpc_set_socket_low_latency(fd, 1) ||
(!grpc_is_unix_socket(addr) && (!grpc_set_socket_low_latency(fd, 1) ||
!grpc_set_socket_reuse_addr(fd, 1))) ||
!grpc_set_socket_no_sigpipe_if_possible(fd)) {
gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd,
@ -451,9 +440,7 @@ int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
if (s->tail != NULL) {
port_index = s->tail->port_index + 1;
}
if (((struct sockaddr *)addr)->sa_family == AF_UNIX) {
unlink_if_unix_domain_socket(addr);
}
grpc_unlink_if_unix_domain_socket((struct sockaddr *)addr);
/* Check if this is a wildcard port, and if so, try to keep the port the same
as some previously created listener. */

@ -52,7 +52,6 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include "src/core/iomgr/fd_posix.h"
@ -60,6 +59,7 @@
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -77,7 +77,6 @@ typedef struct {
union {
uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr;
struct sockaddr_un un;
} addr;
size_t addr_len;
grpc_closure read_closure;
@ -85,14 +84,6 @@ typedef struct {
grpc_udp_server_read_cb read_cb;
} server_port;
static void unlink_if_unix_domain_socket(const struct sockaddr_un *un) {
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
unlink(un->sun_path);
}
}
/* the overall server */
struct grpc_udp_server {
gpr_mu mu;
@ -176,9 +167,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
if (s->nports) {
for (i = 0; i < s->nports; i++) {
server_port *sp = &s->ports[i];
if (sp->addr.sockaddr.sa_family == AF_UNIX) {
unlink_if_unix_domain_socket(&sp->addr.un);
}
grpc_unlink_if_unix_domain_socket(&sp->addr.sockaddr);
sp->destroyed_closure.cb = destroyed_port;
sp->destroyed_closure.cb_arg = s;
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
@ -336,9 +325,7 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
socklen_t sockname_len;
int port;
if (((struct sockaddr *)addr)->sa_family == AF_UNIX) {
unlink_if_unix_domain_socket(addr);
}
grpc_unlink_if_unix_domain_socket((struct sockaddr *)addr);
/* Check if this is a wildcard port, and if so, try to keep the port the same
as some previously created listener. */

@ -37,15 +37,16 @@
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/fd_posix.h"
/* Forward decl of grpc_server */
typedef struct grpc_server grpc_server;
/* Forward decl of struct grpc_server */
/* This is not typedef'ed to avoid a typedef-redefinition error */
struct grpc_server;
/* Forward decl of grpc_udp_server */
typedef struct grpc_udp_server grpc_udp_server;
/* Called when data is available to read from the socket. */
typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
grpc_server *server);
struct grpc_server *server);
/* Create a server, initially not bound to any ports */
grpc_udp_server *grpc_udp_server_create(void);
@ -53,7 +54,7 @@ grpc_udp_server *grpc_udp_server_create(void);
/* Start listening to bound ports */
void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server,
grpc_pollset **pollsets, size_t pollset_count,
grpc_server *server);
struct grpc_server *server);
int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index);

@ -0,0 +1,103 @@
/*
*
* 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/iomgr/unix_sockets_posix.h"
#ifdef GPR_HAVE_UNIX_SOCKET
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <grpc/support/alloc.h>
void grpc_create_socketpair_if_unix(int sv[2]) {
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
}
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name) {
struct sockaddr_un *un;
grpc_resolved_addresses *addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
addrs->naddrs = 1;
addrs->addrs = gpr_malloc(sizeof(grpc_resolved_address));
un = (struct sockaddr_un *)addrs->addrs->addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, name);
addrs->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return addrs;
}
int grpc_is_unix_socket(const struct sockaddr *addr) {
return addr->sa_family == AF_UNIX;
}
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return;
}
struct sockaddr_un *un = (struct sockaddr_un *)addr;
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
unlink(un->sun_path);
}
}
int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
struct sockaddr_un *un = (struct sockaddr_un *)addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, uri->path);
*len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return 1;
}
char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return gpr_strdup("localhost");
}
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return NULL;
}
char *result;
gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un *)addr)->sun_path);
return result;
}
#endif

@ -1,6 +1,6 @@
/*
*
* Copyright 2015-2016, Google Inc.
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -31,30 +31,31 @@
*
*/
#ifndef GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H
#define GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H
#ifndef GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H
#define GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H
#include "src/core/channel/channel_stack.h"
#include "src/core/client_config/resolver.h"
#include <grpc/support/port_platform.h>
#define GRPC_MICROCHANNEL_SUBCHANNEL_ARG "grpc.microchannel_subchannel_key"
#include <grpc/support/string_util.h>
/* A client microchannel (aka uchannel) is a channel wrapping a subchannel, for
* the purposes of lightweight RPC communications from within the core.*/
#include "src/core/client_config/resolver_factory.h"
#include "src/core/client_config/uri_parser.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/sockaddr.h"
extern const grpc_channel_filter grpc_client_uchannel_filter;
void grpc_create_socketpair_if_unix(int sv[2]);
grpc_connectivity_state grpc_client_uchannel_check_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect);
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name);
void grpc_client_uchannel_watch_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset,
grpc_connectivity_state *state, grpc_closure *on_complete);
int grpc_is_unix_socket(const struct sockaddr *addr);
grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
grpc_channel_args *args);
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr);
void grpc_client_uchannel_set_connected_subchannel(
grpc_channel *uchannel, grpc_connected_subchannel *connected_subchannel);
int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len);
#endif /* GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H */
char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri);
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr);
#endif /* GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H */

@ -0,0 +1,61 @@
/*
*
* 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/iomgr/unix_sockets_posix.h"
#ifndef GPR_HAVE_UNIX_SOCKET
void grpc_create_socketpair_if_unix(int sv[2]) {}
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name) {
return NULL;
}
int grpc_is_unix_socket(const struct sockaddr *addr) { return false; }
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr) {}
int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
return 0;
}
char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return NULL;
}
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
return NULL;
}
#endif

@ -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
@ -41,13 +41,18 @@
#include <string.h>
#include <unistd.h>
#include "src/core/iomgr/socket_utils_posix.h"
#include <grpc/support/log.h>
#include "src/core/iomgr/socket_utils_posix.h"
static void pipe_init(grpc_wakeup_fd* fd_info) {
int pipefd[2];
/* TODO(klempner): Make this nonfatal */
GPR_ASSERT(0 == pipe(pipefd));
int r = pipe(pipefd);
if (0 != r) {
gpr_log(GPR_ERROR, "pipe creation failed (%d): %s", errno, strerror(errno));
abort();
}
GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1));
GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1));
fd_info->read_fd = pipefd[0];

@ -38,7 +38,8 @@
#include "src/core/channel/channel_args.h"
#include "src/core/channel/http_client_filter.h"
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/parser.h"
#include "src/core/http/httpcli.h"
#include "src/core/iomgr/executor.h"
#include "src/core/json/json.h"
#include "src/core/support/string.h"
@ -539,7 +540,7 @@ static void oauth2_token_fetcher_destruct(grpc_call_credentials *creds) {
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
const grpc_httpcli_response *response, grpc_credentials_md_store **token_md,
const grpc_http_response *response, grpc_credentials_md_store **token_md,
gpr_timespec *token_lifetime) {
char *null_terminated_body = NULL;
char *new_access_token = NULL;
@ -629,7 +630,7 @@ end:
static void on_oauth2_token_fetcher_http_response(
grpc_exec_ctx *exec_ctx, void *user_data,
const grpc_httpcli_response *response) {
const grpc_http_response *response) {
grpc_credentials_metadata_request *r =
(grpc_credentials_metadata_request *)user_data;
grpc_oauth2_token_fetcher_credentials *c =
@ -706,13 +707,13 @@ static void compute_engine_fetch_oauth2(
grpc_exec_ctx *exec_ctx, grpc_credentials_metadata_request *metadata_req,
grpc_httpcli_context *httpcli_context, grpc_pollset *pollset,
grpc_httpcli_response_cb response_cb, gpr_timespec deadline) {
grpc_httpcli_header header = {"Metadata-Flavor", "Google"};
grpc_http_header header = {"Metadata-Flavor", "Google"};
grpc_httpcli_request request;
memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = GRPC_COMPUTE_ENGINE_METADATA_HOST;
request.path = GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH;
request.hdr_count = 1;
request.hdrs = &header;
request.http.path = GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH;
request.http.hdr_count = 1;
request.http.hdrs = &header;
grpc_httpcli_get(exec_ctx, httpcli_context, pollset, &request, deadline,
response_cb, metadata_req);
}
@ -747,8 +748,8 @@ static void refresh_token_fetch_oauth2(
grpc_httpcli_response_cb response_cb, gpr_timespec deadline) {
grpc_google_refresh_token_credentials *c =
(grpc_google_refresh_token_credentials *)metadata_req->creds;
grpc_httpcli_header header = {"Content-Type",
"application/x-www-form-urlencoded"};
grpc_http_header header = {"Content-Type",
"application/x-www-form-urlencoded"};
grpc_httpcli_request request;
char *body = NULL;
gpr_asprintf(&body, GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING,
@ -756,9 +757,9 @@ static void refresh_token_fetch_oauth2(
c->refresh_token.refresh_token);
memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = GRPC_GOOGLE_OAUTH2_SERVICE_HOST;
request.path = GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH;
request.hdr_count = 1;
request.hdrs = &header;
request.http.path = GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH;
request.http.hdr_count = 1;
request.http.hdrs = &header;
request.handshaker = &grpc_httpcli_ssl;
grpc_httpcli_post(exec_ctx, httpcli_context, pollset, &request, body,
strlen(body), deadline, response_cb, metadata_req);

@ -39,11 +39,12 @@
#include <grpc/grpc_security.h>
#include <grpc/support/sync.h>
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/httpcli.h"
#include "src/core/http/parser.h"
#include "src/core/security/json_token.h"
#include "src/core/security/security_connector.h"
struct grpc_httpcli_response;
struct grpc_http_response;
/* --- Constants. --- */
@ -207,7 +208,7 @@ grpc_call_credentials *grpc_credentials_contains_type(
/* Exposed for testing only. */
grpc_credentials_status
grpc_oauth2_token_fetcher_credentials_parse_server_response(
const struct grpc_httpcli_response *response,
const struct grpc_http_response *response,
grpc_credentials_md_store **token_md, gpr_timespec *token_lifetime);
void grpc_flush_cached_google_default_credentials(void);

@ -39,7 +39,8 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/httpcli.h"
#include "src/core/http/parser.h"
#include "src/core/support/env.h"
#include "src/core/support/load_file.h"
#include "src/core/surface/api_trace.h"
@ -66,14 +67,14 @@ typedef struct {
static void on_compute_engine_detection_http_response(
grpc_exec_ctx *exec_ctx, void *user_data,
const grpc_httpcli_response *response) {
const grpc_http_response *response) {
compute_engine_detector *detector = (compute_engine_detector *)user_data;
if (response != NULL && response->status == 200 && response->hdr_count > 0) {
/* Internet providers can return a generic response to all requests, so
it is necessary to check that metadata header is present also. */
size_t i;
for (i = 0; i < response->hdr_count; i++) {
grpc_httpcli_header *header = &response->hdrs[i];
grpc_http_header *header = &response->hdrs[i];
if (strcmp(header->key, "Metadata-Flavor") == 0 &&
strcmp(header->value, "Google") == 0) {
detector->success = 1;
@ -109,7 +110,7 @@ static int is_stack_running_on_compute_engine(void) {
memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = GRPC_COMPUTE_ENGINE_DETECTION_HOST;
request.path = "/";
request.http.path = "/";
grpc_httpcli_context_init(&context);

@ -36,7 +36,7 @@
#include <limits.h>
#include <string.h>
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/httpcli.h"
#include "src/core/security/b64.h"
#include "src/core/tsi/ssl_types.h"
@ -635,11 +635,11 @@ static void on_openid_config_retrieved(grpc_exec_ctx *exec_ctx, void *user_data,
jwks_uri += 8;
req.handshaker = &grpc_httpcli_ssl;
req.host = gpr_strdup(jwks_uri);
req.path = strchr(jwks_uri, '/');
if (req.path == NULL) {
req.path = "";
req.http.path = strchr(jwks_uri, '/');
if (req.http.path == NULL) {
req.http.path = "";
} else {
*(req.host + (req.path - jwks_uri)) = '\0';
*(req.host + (req.http.path - jwks_uri)) = '\0';
}
grpc_httpcli_get(
exec_ctx, &ctx->verifier->http_ctx, ctx->pollset, &req,
@ -725,20 +725,20 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx,
req.host = gpr_strdup(mapping->key_url_prefix);
path_prefix = strchr(req.host, '/');
if (path_prefix == NULL) {
gpr_asprintf(&req.path, "/%s", iss);
gpr_asprintf(&req.http.path, "/%s", iss);
} else {
*(path_prefix++) = '\0';
gpr_asprintf(&req.path, "/%s/%s", path_prefix, iss);
gpr_asprintf(&req.http.path, "/%s/%s", path_prefix, iss);
}
http_cb = on_keys_retrieved;
} else {
req.host = gpr_strdup(strstr(iss, "https://") == iss ? iss + 8 : iss);
path_prefix = strchr(req.host, '/');
if (path_prefix == NULL) {
req.path = gpr_strdup(GRPC_OPENID_CONFIG_URL_SUFFIX);
req.http.path = gpr_strdup(GRPC_OPENID_CONFIG_URL_SUFFIX);
} else {
*(path_prefix++) = 0;
gpr_asprintf(&req.path, "/%s%s", path_prefix,
gpr_asprintf(&req.http.path, "/%s%s", path_prefix,
GRPC_OPENID_CONFIG_URL_SUFFIX);
}
http_cb = on_openid_config_retrieved;
@ -749,7 +749,7 @@ static void retrieve_key_and_verify(grpc_exec_ctx *exec_ctx,
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_max_delay),
http_cb, ctx);
gpr_free(req.host);
gpr_free(req.path);
gpr_free(req.http.path);
return;
error:

@ -69,3 +69,8 @@ gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now) {
return gpr_time_add(
now, gpr_time_from_millis(backoff->current_timeout_millis, GPR_TIMESPAN));
}
void gpr_backoff_reset(gpr_backoff *backoff) {
// forces step() to return a timeout of min_timeout_millis
backoff->current_timeout_millis = 0;
}

@ -61,5 +61,8 @@ void gpr_backoff_init(gpr_backoff *backoff, double multiplier, double jitter,
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);
/// Reset the backoff, so the next gpr_backoff_step will be a gpr_backoff_begin
/// instead
void gpr_backoff_reset(gpr_backoff *backoff);
#endif /* GRPC_CORE_SUPPORT_BACKOFF_H */

@ -37,7 +37,6 @@
#include <grpc/support/log.h>
#include "src/core/channel/client_channel.h"
#include "src/core/channel/client_uchannel.h"
#include "src/core/iomgr/timer.h"
#include "src/core/surface/api_trace.h"
#include "src/core/surface/completion_queue.h"
@ -58,12 +57,6 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
grpc_exec_ctx_finish(&exec_ctx);
return state;
}
if (client_channel_elem->filter == &grpc_client_uchannel_filter) {
state = grpc_client_uchannel_check_connectivity_state(
&exec_ctx, client_channel_elem, try_to_connect);
grpc_exec_ctx_finish(&exec_ctx);
return state;
}
gpr_log(GPR_ERROR,
"grpc_channel_check_connectivity_state called on something that is "
"not a (u)client channel, but '%s'",
@ -98,9 +91,6 @@ static void delete_state_watcher(grpc_exec_ctx *exec_ctx, state_watcher *w) {
if (client_channel_elem->filter == &grpc_client_channel_filter) {
GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
"watch_channel_connectivity");
} else if (client_channel_elem->filter == &grpc_client_uchannel_filter) {
GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
"watch_uchannel_connectivity");
} else {
abort();
}
@ -209,11 +199,8 @@ void grpc_channel_watch_connectivity_state(
grpc_client_channel_watch_connectivity_state(&exec_ctx, client_channel_elem,
grpc_cq_pollset(cq), &w->state,
&w->on_complete);
} else if (client_channel_elem->filter == &grpc_client_uchannel_filter) {
GRPC_CHANNEL_INTERNAL_REF(channel, "watch_uchannel_connectivity");
grpc_client_uchannel_watch_connectivity_state(
&exec_ctx, client_channel_elem, grpc_cq_pollset(cq), &w->state,
&w->on_complete);
} else {
abort();
}
grpc_exec_ctx_finish(&exec_ctx);

@ -112,8 +112,6 @@ static const char *name_for_type(grpc_channel_stack_type type) {
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:

@ -39,8 +39,6 @@ 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:

@ -39,9 +39,6 @@
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,

@ -45,7 +45,6 @@
#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"
@ -112,9 +111,6 @@ static void register_builtin_channel_init() {
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,
@ -134,8 +130,6 @@ static void register_builtin_channel_init() {
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,

@ -150,7 +150,7 @@ int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) {
/* spec allows max. 8 digits, but we allow values up to 1,000,000,000 */
if (x >= (100 * 1000 * 1000)) {
if (x != (100 * 1000 * 1000) || digit != 0) {
*timeout = gpr_inf_future(GPR_CLOCK_REALTIME);
*timeout = gpr_inf_future(GPR_TIMESPAN);
return 1;
}
}

@ -50,7 +50,7 @@ grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];
grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 3, 7, 5, 2, 4, 8, 6, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 4, 8, 6, 2, 4, 8, 6, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

@ -35,6 +35,8 @@
#include <nan.h>
#include <uv.h>
#include <list>
#include "grpc/grpc.h"
#include "grpc/grpc_security.h"
#include "grpc/support/log.h"
@ -161,6 +163,15 @@ NAN_METHOD(CallCredentials::CreateFromPlugin) {
grpc_metadata_credentials_plugin plugin;
plugin_state *state = new plugin_state;
state->callback = new Nan::Callback(info[0].As<Function>());
state->pending_callbacks = new std::list<plugin_callback_data*>();
uv_mutex_init(&state->plugin_mutex);
uv_async_init(uv_default_loop(),
&state->plugin_async,
SendPluginCallback);
uv_unref((uv_handle_t*)&state->plugin_async);
state->plugin_async.data = state;
plugin.get_metadata = plugin_get_metadata;
plugin.destroy = plugin_destroy_state;
plugin.state = reinterpret_cast<void*>(state);
@ -208,48 +219,60 @@ NAN_METHOD(PluginCallback) {
NAUV_WORK_CB(SendPluginCallback) {
Nan::HandleScope scope;
plugin_callback_data *data = reinterpret_cast<plugin_callback_data*>(
async->data);
// Attach cb and user_data to plugin_callback so that it can access them later
v8::Local<v8::Function> plugin_callback = Nan::GetFunction(
Nan::New<v8::FunctionTemplate>(PluginCallback)).ToLocalChecked();
Nan::Set(plugin_callback, Nan::New("cb").ToLocalChecked(),
Nan::New<v8::External>(reinterpret_cast<void*>(data->cb)));
Nan::Set(plugin_callback, Nan::New("user_data").ToLocalChecked(),
Nan::New<v8::External>(data->user_data));
const int argc = 2;
v8::Local<v8::Value> argv[argc] = {
Nan::New(data->service_url).ToLocalChecked(),
plugin_callback
};
Nan::Callback *callback = data->state->callback;
callback->Call(argc, argv);
delete data;
uv_unref((uv_handle_t *)async);
uv_close((uv_handle_t *)async, (uv_close_cb)free);
plugin_state *state = reinterpret_cast<plugin_state*>(async->data);
std::list<plugin_callback_data*> callbacks;
uv_mutex_lock(&state->plugin_mutex);
callbacks.splice(callbacks.begin(), *state->pending_callbacks);
uv_mutex_unlock(&state->plugin_mutex);
while (!callbacks.empty()) {
plugin_callback_data *data = callbacks.front();
callbacks.pop_front();
// Attach cb and user_data to plugin_callback so that it can access them later
v8::Local<v8::Function> plugin_callback = Nan::GetFunction(
Nan::New<v8::FunctionTemplate>(PluginCallback)).ToLocalChecked();
Nan::Set(plugin_callback, Nan::New("cb").ToLocalChecked(),
Nan::New<v8::External>(reinterpret_cast<void*>(data->cb)));
Nan::Set(plugin_callback, Nan::New("user_data").ToLocalChecked(),
Nan::New<v8::External>(data->user_data));
const int argc = 2;
v8::Local<v8::Value> argv[argc] = {
Nan::New(data->service_url).ToLocalChecked(),
plugin_callback
};
Nan::Callback *callback = state->callback;
callback->Call(argc, argv);
delete data;
}
}
void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb,
void *user_data) {
uv_async_t *async = static_cast<uv_async_t*>(malloc(sizeof(uv_async_t)));
uv_async_init(uv_default_loop(),
async,
SendPluginCallback);
plugin_state *p_state = reinterpret_cast<plugin_state*>(state);
plugin_callback_data *data = new plugin_callback_data;
data->state = reinterpret_cast<plugin_state*>(state);
data->service_url = context.service_url;
data->cb = cb;
data->user_data = user_data;
async->data = data;
/* libuv says that it will coalesce calls to uv_async_send. If there is ever a
* problem with a callback not getting called, that is probably the reason */
uv_async_send(async);
uv_mutex_lock(&p_state->plugin_mutex);
p_state->pending_callbacks->push_back(data);
uv_mutex_unlock(&p_state->plugin_mutex);
uv_async_send(&p_state->plugin_async);
}
void plugin_uv_close_cb(uv_handle_t *handle) {
uv_async_t *async = reinterpret_cast<uv_async_t*>(handle);
plugin_state *state = reinterpret_cast<plugin_state *>(async->data);
uv_mutex_destroy(&state->plugin_mutex);
delete state->pending_callbacks;
delete state->callback;
delete state;
}
void plugin_destroy_state(void *ptr) {
plugin_state *state = reinterpret_cast<plugin_state *>(ptr);
delete state->callback;
uv_close((uv_handle_t*)&state->plugin_async, plugin_uv_close_cb);
}
} // namespace node

@ -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,8 +34,11 @@
#ifndef GRPC_NODE_CALL_CREDENTIALS_H_
#define GRPC_NODE_CALL_CREDENTIALS_H_
#include <list>
#include <node.h>
#include <nan.h>
#include <uv.h>
#include "grpc/grpc_security.h"
namespace grpc {
@ -73,17 +76,20 @@ class CallCredentials : public Nan::ObjectWrap {
/* Auth metadata plugin functionality */
typedef struct plugin_state {
Nan::Callback *callback;
} plugin_state;
typedef struct plugin_callback_data {
plugin_state *state;
const char *service_url;
grpc_credentials_plugin_metadata_cb cb;
void *user_data;
} plugin_callback_data;
typedef struct plugin_state {
Nan::Callback *callback;
std::list<plugin_callback_data*> *pending_callbacks;
uv_mutex_t plugin_mutex;
// async.data == this
uv_async_t plugin_async;
} plugin_state;
void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb,
void *user_data);

@ -118,7 +118,6 @@ exports.createFromMetadataGenerator = function(metadata_generator) {
exports.createFromGoogleCredential = function(google_credential) {
return exports.createFromMetadataGenerator(function(auth_context, callback) {
var service_url = auth_context.service_url;
console.log('Service URL:', service_url);
google_credential.getRequestMetadata(service_url, function(err, header) {
if (err) {
console.log('Auth error:', err);
@ -127,7 +126,6 @@ exports.createFromGoogleCredential = function(google_credential) {
}
var metadata = new Metadata();
metadata.add('authorization', header.Authorization);
console.log(header.Authorization);
callback(null, metadata);
});
});

@ -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
@ -308,37 +308,30 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
}
- (void)invokeCall {
__weak GRPCCall *weakSelf = self;
[self invokeCallWithHeadersHandler:^(NSDictionary *headers) {
// Response headers received.
GRPCCall *strongSelf = weakSelf;
if (strongSelf) {
strongSelf.responseHeaders = headers;
[strongSelf startNextRead];
}
self.responseHeaders = headers;
[self startNextRead];
} completionHandler:^(NSError *error, NSDictionary *trailers) {
GRPCCall *strongSelf = weakSelf;
if (strongSelf) {
strongSelf.responseTrailers = trailers;
if (error) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (error.userInfo) {
[userInfo addEntriesFromDictionary:error.userInfo];
}
userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers;
// TODO(jcanizales): The C gRPC library doesn't guarantee that the headers block will be
// called before this one, so an error might end up with trailers but no headers. We
// shouldn't call finishWithError until ater both blocks are called. It is also when this is
// done that we can provide a merged view of response headers and trailers in a thread-safe
// way.
if (strongSelf.responseHeaders) {
userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders;
}
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
self.responseTrailers = trailers;
if (error) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (error.userInfo) {
[userInfo addEntriesFromDictionary:error.userInfo];
}
userInfo[kGRPCTrailersKey] = self.responseTrailers;
// TODO(jcanizales): The C gRPC library doesn't guarantee that the headers block will be
// called before this one, so an error might end up with trailers but no headers. We
// shouldn't call finishWithError until ater both blocks are called. It is also when this is
// done that we can provide a merged view of response headers and trailers in a thread-safe
// way.
if (self.responseHeaders) {
userInfo[kGRPCHeadersKey] = self.responseHeaders;
}
[strongSelf finishWithError:error];
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
}
[self finishWithError:error];
}];
// Now that the RPC has been initiated, request writes can start.
@synchronized(_requestWriter) {
@ -377,7 +370,6 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
[strongSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeUnavailable
userInfo:@{NSLocalizedDescriptionKey: @"Connectivity lost."}]];
[[GRPCHost hostWithAddress:strongSelf->_host] disconnect];
}
}];
}

@ -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
@ -54,7 +54,9 @@
- (void)finish {
if (_handler) {
_handler();
void(^handler)() = _handler;
_handler = nil;
handler();
}
}
@end

@ -1,4 +1,3 @@
// Copyright 2015, Google Inc.
// All rights reserved.
//
@ -28,12 +27,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// An integration test service that covers all the method signature permutations
// of unary/streaming requests/responses.
// Contains the definitions for a metrics service and the type of metrics
// exposed by the service.
//
// Currently, 'Gauge' (i.e a metric that represents the measured value of
// something at an instant of time) is the only metric type supported by the
// service.
syntax = "proto3";
package grpc.testing;
// Reponse message containing the gauge name and value
message GaugeResponse {
string name = 1;
oneof value {
@ -43,11 +47,18 @@ message GaugeResponse {
}
}
message GaugeRequest { string name = 1; }
// Request message containing the gauge name
message GaugeRequest {
string name = 1;
}
message EmptyMessage {}
service MetricsService {
// Returns the values of all the gauges that are currently being maintained by
// the service
rpc GetAllGauges(EmptyMessage) returns (stream GaugeResponse);
// Returns the value of one gauge
rpc GetGauge(GaugeRequest) returns (GaugeResponse);
}

@ -254,7 +254,7 @@ cdef class ByteBuffer:
if self.c_byte_buffer != NULL:
with nogil:
grpc_byte_buffer_reader_init(&reader, self.c_byte_buffer)
result = b""
result = bytearray()
with nogil:
while grpc_byte_buffer_reader_next(&reader, &data_slice):
data_slice_pointer = gpr_slice_start_ptr(data_slice)
@ -263,7 +263,7 @@ cdef class ByteBuffer:
result += (<char *>data_slice_pointer)[:data_slice_length]
with nogil:
grpc_byte_buffer_reader_destroy(&reader)
return result
return bytes(result)
else:
return None

@ -111,7 +111,7 @@ def break_down_invocation(service_name, method_descriptions):
face_cardinalities = {}
request_serializers = {}
response_deserializers = {}
for name, method_description in method_descriptions.iteritems():
for name, method_description in six.iteritems(method_descriptions):
qualified_name = _qualified_name(service_name, name)
method_cardinality = method_description.cardinality()
cardinalities[name] = method_description.cardinality()
@ -139,7 +139,7 @@ def break_down_service(service_name, method_descriptions):
implementations = {}
request_deserializers = {}
response_serializers = {}
for name, method_description in method_descriptions.iteritems():
for name, method_description in six.iteritems(method_descriptions):
qualified_name = _qualified_name(service_name, name)
method_cardinality = method_description.cardinality()
if method_cardinality is interfaces.Cardinality.UNARY_UNARY:

@ -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
@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import six
from grpc.framework.common import cardinality
from grpc.framework.face import exceptions as face_exceptions
from grpc.framework.face import interfaces as face_interfaces
@ -181,7 +183,7 @@ def common_cardinality(early_adopter_cardinality):
def common_cardinalities(early_adopter_cardinalities):
common_cardinalities = {}
for name, early_adopter_cardinality in early_adopter_cardinalities.iteritems():
for name, early_adopter_cardinality in six.iteritems(early_adopter_cardinalities):
common_cardinalities[name] = _EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY[
early_adopter_cardinality]
return common_cardinalities

@ -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
@ -29,6 +29,8 @@
"""Entry points into the Crust layer of RPC Framework."""
import six
from grpc.framework.common import cardinality
from grpc.framework.common import style
from grpc.framework.crust import _calls
@ -271,7 +273,7 @@ class _DynamicStub(face.DynamicStub):
def _adapt_method_implementations(method_implementations, pool):
adapted_implementations = {}
for name, method_implementation in method_implementations.iteritems():
for name, method_implementation in six.iteritems(method_implementations):
if method_implementation.style is style.Service.INLINE:
if method_implementation.cardinality is cardinality.Cardinality.UNARY_UNARY:
adapted_implementations[name] = _service.adapt_inline_unary_unary(

@ -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
@ -29,6 +29,8 @@
"""Entry points into the Face layer of RPC Framework."""
import six
from grpc.framework.common import cardinality
from grpc.framework.common import style
from grpc.framework.base import exceptions as _base_exceptions
@ -228,7 +230,7 @@ class _DynamicStub(interfaces.DynamicStub):
def _adapt_method_implementations(method_implementations, pool):
adapted_implementations = {}
for name, method_implementation in method_implementations.iteritems():
for name, method_implementation in six.iteritems(method_implementations):
if method_implementation.style is style.Service.INLINE:
if method_implementation.cardinality is cardinality.Cardinality.UNARY_UNARY:
adapted_implementations[name] = _service.adapt_inline_value_in_value_out(

@ -81,7 +81,6 @@ CORE_SOURCE_FILES = [
'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',
'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c',
@ -109,9 +108,9 @@ CORE_SOURCE_FILES = [
'src/core/compression/compression_algorithm.c',
'src/core/compression/message_compress.c',
'src/core/debug/trace.c',
'src/core/httpcli/format_request.c',
'src/core/httpcli/httpcli.c',
'src/core/httpcli/parser.c',
'src/core/http/format_request.c',
'src/core/http/httpcli.c',
'src/core/http/parser.c',
'src/core/iomgr/closure.c',
'src/core/iomgr/endpoint.c',
'src/core/iomgr/endpoint_pair_posix.c',
@ -146,6 +145,8 @@ CORE_SOURCE_FILES = [
'src/core/iomgr/timer.c',
'src/core/iomgr/timer_heap.c',
'src/core/iomgr/udp_server.c',
'src/core/iomgr/unix_sockets_posix.c',
'src/core/iomgr/unix_sockets_posix_noop.c',
'src/core/iomgr/wakeup_fd_eventfd.c',
'src/core/iomgr/wakeup_fd_nospecial.c',
'src/core/iomgr/wakeup_fd_pipe.c',
@ -207,7 +208,7 @@ CORE_SOURCE_FILES = [
'src/core/transport/static_metadata.c',
'src/core/transport/transport.c',
'src/core/transport/transport_op_string.c',
'src/core/httpcli/httpcli_security_connector.c',
'src/core/http/httpcli_security_connector.c',
'src/core/security/b64.c',
'src/core/security/client_auth_filter.c',
'src/core/security/credentials.c',

@ -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
@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from __future__ import absolute_import
from tests import _loader
from tests import _runner

@ -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
@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from __future__ import absolute_import
import importlib
import pkgutil
import re

@ -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
@ -27,7 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import cStringIO as StringIO
from __future__ import absolute_import
import collections
import itertools
import traceback
@ -35,6 +36,7 @@ import unittest
from xml.etree import ElementTree
import coverage
from six import moves
from tests import _loader
@ -356,7 +358,7 @@ def _traceback_string(type, value, trace):
Returns:
str: Formatted exception descriptive string.
"""
buffer = StringIO.StringIO()
buffer = moves.cStringIO()
traceback.print_exception(type, value, trace, file=buffer)
return buffer.getvalue()

@ -27,7 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import cStringIO as StringIO
from __future__ import absolute_import
import collections
import fcntl
import multiprocessing
@ -41,6 +42,8 @@ import time
import unittest
import uuid
from six import moves
from tests import _loader
from tests import _result
@ -143,7 +146,7 @@ class Runner(object):
for case in filtered_cases]
case_id_by_case = dict((augmented_case.case, augmented_case.id)
for augmented_case in augmented_cases)
result_out = StringIO.StringIO()
result_out = moves.cStringIO()
result = _result.TerminalResult(
result_out, id_map=lambda case: case_id_by_case[case])
stdout_pipe = CaptureFile(sys.stdout.fileno())

@ -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 random
import time
import unittest
import six
from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc._links import service
@ -68,7 +70,7 @@ def _serialization_behaviors_from_serializations(serializations):
request_deserializers = {}
response_serializers = {}
response_deserializers = {}
for (group, method), serialization in serializations.iteritems():
for (group, method), serialization in six.iteritems(serializations):
request_serializers[group, method] = serialization.serialize_request
request_deserializers[group, method] = serialization.deserialize_request
response_serializers[group, method] = serialization.serialize_response

@ -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 collections
import unittest
import six
from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc._links import service
@ -59,7 +61,7 @@ def _serialization_behaviors_from_test_methods(test_methods):
request_deserializers = {}
response_serializers = {}
response_deserializers = {}
for (group, method), test_method in test_methods.iteritems():
for (group, method), test_method in six.iteritems(test_methods):
request_serializers[group, method] = test_method.serialize_request
request_deserializers[group, method] = test_method.deserialize_request
response_serializers[group, method] = test_method.serialize_response
@ -108,7 +110,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest.
cardinalities = {
method: method_object.cardinality()
for (group, method), method_object in methods.iteritems()}
for (group, method), method_object in six.iteritems(methods)}
dynamic_stub = crust_implementations.dynamic_stub(
invocation_end_link, group, cardinalities, pool)

@ -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 collections
import unittest
import six
from grpc.beta import implementations
from grpc.beta import interfaces
from tests.unit import resources
@ -57,7 +59,7 @@ def _serialization_behaviors_from_test_methods(test_methods):
request_deserializers = {}
response_serializers = {}
response_deserializers = {}
for (group, method), test_method in test_methods.iteritems():
for (group, method), test_method in six.iteritems(test_methods):
request_serializers[group, method] = test_method.serialize_request
request_deserializers[group, method] = test_method.deserialize_request
response_serializers[group, method] = test_method.serialize_response
@ -79,7 +81,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest.
cardinalities = {
method: method_object.cardinality()
for (group, method), method_object in methods.iteritems()}
for (group, method), method_object in six.iteritems(methods)}
server_options = implementations.server_options(
request_deserializers=serialization_behaviors.request_deserializers,

@ -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 collections
import unittest
import six
from grpc.framework.core import implementations as core_implementations
from grpc.framework.crust import implementations as crust_implementations
from grpc.framework.foundation import logging_pool
@ -66,7 +68,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest.
cardinalities = {
method: method_object.cardinality()
for (group, method), method_object in methods.iteritems()}
for (group, method), method_object in six.iteritems(methods)}
dynamic_stub = crust_implementations.dynamic_stub(
invocation_end_link, group, cardinalities, pool)

@ -74,7 +74,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -85,7 +85,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -97,7 +97,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -108,7 +108,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -120,7 +120,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSequentialInvocations(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@ -137,7 +137,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -148,7 +148,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -160,7 +160,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -171,7 +171,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -183,7 +183,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -193,7 +193,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -204,7 +204,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -214,7 +214,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()

@ -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 collections
import threading
import six
# testing_control, interfaces, and testing_service are referenced from
# specification in this module.
from grpc.framework.common import cardinality
@ -368,7 +370,7 @@ def _assemble(
events = {}
adaptations = {}
messages = {}
for name, scenario in scenarios.iteritems():
for name, scenario in six.iteritems(scenarios):
if name in names:
raise ValueError('Repeated name "%s"!' % name)

@ -74,7 +74,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@ -89,7 +89,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@ -104,7 +104,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@ -122,7 +122,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@ -140,7 +140,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSequentialInvocations(self):
# pylint: disable=cell-var-from-loop
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@ -165,7 +165,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@ -180,7 +180,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@ -195,7 +195,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for unused_test_messages in test_messages_sequence:
callback = testing_callback.Callback()
@ -208,7 +208,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@ -223,7 +223,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@ -239,7 +239,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@ -255,7 +255,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@ -274,7 +274,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@ -291,7 +291,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testParallelInvocations(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
first_callback = testing_callback.Callback()
@ -318,7 +318,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@ -334,7 +334,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = testing_callback.Callback()
@ -349,7 +349,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = testing_callback.Callback()
@ -366,7 +366,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for unused_test_messages in test_messages_sequence:
callback = testing_callback.Callback()

@ -110,7 +110,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -122,7 +122,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -134,7 +134,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@ -150,7 +150,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@ -166,7 +166,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSequentialInvocations(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@ -185,7 +185,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -200,7 +200,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -212,7 +212,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -227,7 +227,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -239,7 +239,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -258,7 +258,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -273,7 +273,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -292,7 +292,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -307,7 +307,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testParallelInvocations(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@ -329,7 +329,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -343,7 +343,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledUnaryRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -357,7 +357,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledStreamRequestUnaryResponse(self):
for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -371,7 +371,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledStreamRequestStreamResponse(self):
for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()

@ -82,7 +82,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSuccessfulUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -93,7 +93,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSuccessfulUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -105,7 +105,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSuccessfulStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -116,7 +116,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSuccessfulStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -128,7 +128,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSequentialInvocations(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@ -146,7 +146,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@ -168,7 +168,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@ -206,7 +206,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testExpiredUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -217,7 +217,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testExpiredUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -229,7 +229,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testExpiredStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -240,7 +240,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testExpiredStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -252,7 +252,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testFailedUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -262,7 +262,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testFailedUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -273,7 +273,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testFailedStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -283,7 +283,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testFailedStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()

@ -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 collections
import threading
import six
# test_control, _service, and test_interfaces are referenced from specification
# in this module.
from grpc.framework.common import cardinality
@ -363,7 +365,7 @@ def _assemble(
events = {}
adaptations = {}
messages = {}
for identifier, scenario in scenarios.iteritems():
for identifier, scenario in six.iteritems(scenarios):
if identifier in identifiers:
raise ValueError('Repeated identifier "(%s, %s)"!' % identifier)

@ -145,7 +145,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSuccessfulUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@ -160,7 +160,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSuccessfulUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -172,7 +172,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSuccessfulStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@ -192,7 +192,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSuccessfulStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests))
@ -208,7 +208,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testSequentialInvocations(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@ -227,7 +227,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testParallelInvocations(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
first_request = test_messages.request()
second_request = test_messages.request()
@ -243,7 +243,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
test_messages.verify(second_request, second_response, self)
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures = []
@ -263,7 +263,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = []
response_futures_to_indices = {}
@ -285,7 +285,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testCancelledUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@ -302,7 +302,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testCancelledUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -316,7 +316,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testCancelledStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@ -333,7 +333,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testCancelledStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -347,7 +347,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testExpiredUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@ -364,7 +364,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testExpiredUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -376,7 +376,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testExpiredStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@ -393,7 +393,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testExpiredStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
@ -405,7 +405,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testFailedUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
callback = _Callback()
@ -427,7 +427,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testFailedUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence:
request = test_messages.request()
@ -442,7 +442,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testFailedStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
callback = _Callback()
@ -464,7 +464,7 @@ class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.
def testFailedStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()):
six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence:
requests = test_messages.requests()

@ -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 collections
import six
INVOCATION_INITIAL_METADATA = ((b'0', b'abc'), (b'1', b'def'), (b'2', b'ghi'),)
SERVICE_INITIAL_METADATA = ((b'3', b'jkl'), (b'4', b'mno'), (b'5', b'pqr'),)
SERVICE_TERMINAL_METADATA = ((b'6', b'stu'), (b'7', b'vwx'), (b'8', b'yza'),)
@ -65,7 +67,7 @@ def metadata_transmitted(original_metadata, transmitted_metadata):
key, value = tuple(key_value_pair)
transmitted[key].append(value)
for key, values in original.iteritems():
for key, values in six.iteritems(original):
transmitted_values = transmitted[key]
transmitted_iterator = iter(transmitted_values)
try:

@ -72,6 +72,10 @@ static ID id_cq;
* the flags used to create metadata from a Hash */
static ID id_flags;
/* id_credentials is the name of the hidden ivar that preserves the value
* of the credentials added to the call */
static ID id_credentials;
/* id_input_md is the name of the hidden ivar that preserves the hash used to
* create metadata, so that references to the strings it contains last as long
* as the call the metadata is added to. */
@ -299,6 +303,7 @@ static VALUE grpc_rb_call_set_credentials(VALUE self, VALUE credentials) {
"grpc_call_set_credentials failed with %s (code=%d)",
grpc_call_error_detail_of(err), err);
}
rb_ivar_set(self, id_credentials, credentials);
return Qnil;
}
@ -859,6 +864,7 @@ void Init_grpc_call() {
id_cq = rb_intern("__cq");
id_flags = rb_intern("__flags");
id_input_md = rb_intern("__input_md");
id_credentials = rb_intern("__credentials");
/* Ids used in constructing the batch result. */
sym_send_message = ID2SYM(rb_intern("send_message"));

@ -41,6 +41,7 @@
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "rb_call.h"
#include "rb_event_thread.h"
@ -50,9 +51,9 @@
* grpc_call_credentials */
static VALUE grpc_rb_cCallCredentials = Qnil;
/* grpc_rb_call_credentials wraps a grpc_call_credentials. It provides a peer
* ruby object, 'mark' to minimize copying when a credential is created from
* ruby. */
/* grpc_rb_call_credentials wraps a grpc_call_credentials. It provides a mark
* object that is used to hold references to any objects used to create the
* credentials. */
typedef struct grpc_rb_call_credentials {
/* Holder of ruby objects involved in contructing the credentials */
VALUE mark;
@ -81,14 +82,23 @@ static VALUE grpc_rb_call_credentials_callback(VALUE callback_args) {
static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args,
VALUE exception_object) {
VALUE result = rb_hash_new();
VALUE backtrace = rb_funcall(
rb_funcall(exception_object, rb_intern("backtrace"), 0),
rb_intern("join"),
1, rb_str_new2("\n\tfrom "));
VALUE exception_info = rb_funcall(exception_object, rb_intern("to_s"), 0);
const char *exception_classname = rb_obj_classname(exception_object);
(void)args;
gpr_log(GPR_INFO, "Call credentials callback failed: %s: %s\n%s",
exception_classname, StringValueCStr(exception_info),
StringValueCStr(backtrace));
rb_hash_aset(result, rb_str_new2("metadata"), Qnil);
/* Currently only gives the exception class name. It should be possible get
more details */
rb_hash_aset(result, rb_str_new2("status"),
INT2NUM(GRPC_STATUS_PERMISSION_DENIED));
rb_hash_aset(result, rb_str_new2("details"),
rb_str_new2(rb_obj_classname(exception_object)));
rb_str_new2(exception_classname));
return result;
}
@ -146,13 +156,8 @@ static void grpc_rb_call_credentials_free(void *p) {
return;
}
wrapper = (grpc_rb_call_credentials *)p;
/* Delete the wrapped object if the mark object is Qnil, which indicates that
* no other object is the actual owner. */
if (wrapper->wrapped != NULL && wrapper->mark == Qnil) {
grpc_call_credentials_release(wrapper->wrapped);
wrapper->wrapped = NULL;
}
grpc_call_credentials_release(wrapper->wrapped);
wrapper->wrapped = NULL;
xfree(p);
}
@ -164,8 +169,6 @@ static void grpc_rb_call_credentials_mark(void *p) {
return;
}
wrapper = (grpc_rb_call_credentials *)p;
/* If it's not already cleaned up, mark the mark object */
if (wrapper->mark != Qnil) {
rb_gc_mark(wrapper->mark);
}
@ -194,7 +197,7 @@ static VALUE grpc_rb_call_credentials_alloc(VALUE cls) {
/* Creates a wrapping object for a given call credentials. This should only be
* called with grpc_call_credentials objects that are not already associated
* with any Ruby object */
VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials *c) {
VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials *c, VALUE mark) {
VALUE rb_wrapper;
grpc_rb_call_credentials *wrapper;
if (c == NULL) {
@ -204,6 +207,7 @@ VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials *c) {
TypedData_Get_Struct(rb_wrapper, grpc_rb_call_credentials,
&grpc_rb_call_credentials_data_type, wrapper);
wrapper->wrapped = c;
wrapper->mark = mark;
return rb_wrapper;
}
@ -267,6 +271,7 @@ static VALUE grpc_rb_call_credentials_init(VALUE self, VALUE proc) {
return Qnil;
}
wrapper->mark = proc;
wrapper->wrapped = creds;
rb_ivar_set(self, id_callback, proc);
@ -277,15 +282,18 @@ static VALUE grpc_rb_call_credentials_compose(int argc, VALUE *argv,
VALUE self) {
grpc_call_credentials *creds;
grpc_call_credentials *other;
VALUE mark;
if (argc == 0) {
return self;
}
mark = rb_ary_new();
creds = grpc_rb_get_wrapped_call_credentials(self);
for (int i = 0; i < argc; i++) {
rb_ary_push(mark, argv[i]);
other = grpc_rb_get_wrapped_call_credentials(argv[i]);
creds = grpc_composite_call_credentials_create(creds, other, NULL);
}
return grpc_rb_wrap_call_credentials(creds);
return grpc_rb_wrap_call_credentials(creds, mark);
}
void Init_grpc_call_credentials() {

@ -70,11 +70,10 @@ static VALUE grpc_rb_cChannel = Qnil;
/* Used during the conversion of a hash to channel args during channel setup */
static VALUE grpc_rb_cChannelArgs;
/* grpc_rb_channel wraps a grpc_channel. It provides a peer ruby object,
* 'mark' to minimize copying when a channel is created from ruby. */
/* grpc_rb_channel wraps a grpc_channel. */
typedef struct grpc_rb_channel {
/* Holder of ruby objects involved in constructing the channel */
VALUE mark;
VALUE credentials;
/* The actual channel */
grpc_channel *wrapped;
} grpc_rb_channel;
@ -87,13 +86,8 @@ static void grpc_rb_channel_free(void *p) {
};
ch = (grpc_rb_channel *)p;
/* Deletes the wrapped object if the mark object is Qnil, which indicates
* that no other object is the actual owner. */
if (ch->wrapped != NULL && ch->mark == Qnil) {
if (ch->wrapped != NULL) {
grpc_channel_destroy(ch->wrapped);
rb_warning("channel gc: destroyed the c channel");
} else {
rb_warning("channel gc: did not destroy the c channel");
}
xfree(p);
@ -106,8 +100,8 @@ static void grpc_rb_channel_mark(void *p) {
return;
}
channel = (grpc_rb_channel *)p;
if (channel->mark != Qnil) {
rb_gc_mark(channel->mark);
if (channel->credentials != Qnil) {
rb_gc_mark(channel->credentials);
}
}
@ -125,7 +119,7 @@ static rb_data_type_t grpc_channel_data_type = {
static VALUE grpc_rb_channel_alloc(VALUE cls) {
grpc_rb_channel *wrapper = ALLOC(grpc_rb_channel);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
wrapper->credentials = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_channel_data_type, wrapper);
}
@ -162,6 +156,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
}
ch = grpc_insecure_channel_create(target_chars, &args, NULL);
} else {
wrapper->credentials = credentials;
creds = grpc_rb_get_wrapped_channel_credentials(credentials);
ch = grpc_secure_channel_create(creds, target_chars, &args, NULL);
}
@ -330,7 +325,6 @@ static VALUE grpc_rb_channel_destroy(VALUE self) {
if (ch != NULL) {
grpc_channel_destroy(ch);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
}
return Qnil;

@ -49,8 +49,8 @@
static VALUE grpc_rb_cChannelCredentials = Qnil;
/* grpc_rb_channel_credentials wraps a grpc_channel_credentials. It provides a
* peer ruby object, 'mark' to minimize copying when a credential is
* created from ruby. */
* mark object that is used to hold references to any objects used to create
* the credentials. */
typedef struct grpc_rb_channel_credentials {
/* Holder of ruby objects involved in constructing the credentials */
VALUE mark;
@ -66,13 +66,8 @@ static void grpc_rb_channel_credentials_free(void *p) {
return;
};
wrapper = (grpc_rb_channel_credentials *)p;
/* Delete the wrapped object if the mark object is Qnil, which indicates that
* no other object is the actual owner. */
if (wrapper->wrapped != NULL && wrapper->mark == Qnil) {
grpc_channel_credentials_release(wrapper->wrapped);
wrapper->wrapped = NULL;
}
grpc_channel_credentials_release(wrapper->wrapped);
wrapper->wrapped = NULL;
xfree(p);
}
@ -85,7 +80,6 @@ static void grpc_rb_channel_credentials_mark(void *p) {
}
wrapper = (grpc_rb_channel_credentials *)p;
/* If it's not already cleaned up, mark the mark object */
if (wrapper->mark != Qnil) {
rb_gc_mark(wrapper->mark);
}
@ -114,7 +108,7 @@ static VALUE grpc_rb_channel_credentials_alloc(VALUE cls) {
/* Creates a wrapping object for a given channel credentials. This should only
* be called with grpc_channel_credentials objects that are not already
* associated with any Ruby object. */
VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials *c) {
VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials *c, VALUE mark) {
VALUE rb_wrapper;
grpc_rb_channel_credentials *wrapper;
if (c == NULL) {
@ -124,6 +118,7 @@ VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials *c) {
TypedData_Get_Struct(rb_wrapper, grpc_rb_channel_credentials,
&grpc_rb_channel_credentials_data_type, wrapper);
wrapper->wrapped = c;
wrapper->mark = mark;
return rb_wrapper;
}
@ -222,11 +217,15 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
VALUE self) {
grpc_channel_credentials *creds;
grpc_call_credentials *other;
VALUE mark;
if (argc == 0) {
return self;
}
mark = rb_ary_new();
rb_ary_push(mark, self);
creds = grpc_rb_get_wrapped_channel_credentials(self);
for (int i = 0; i < argc; i++) {
rb_ary_push(mark, argv[i]);
other = grpc_rb_get_wrapped_call_credentials(argv[i]);
creds = grpc_composite_channel_credentials_create(creds, other, NULL);
if (creds == NULL) {
@ -234,7 +233,7 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
"Failed to compose channel and call credentials");
}
}
return grpc_rb_wrap_channel_credentials(creds);
return grpc_rb_wrap_channel_credentials(creds, mark);
}
void Init_grpc_channel_credentials() {

@ -36,7 +36,7 @@ gRPC Python:
* **Required skills:** Python programming language, PyPy Python interpreter.
* **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Masood Malekghassemi](https://github.com/soltanmm).
1. Develop and test Python 3.5 Support for gRPC. Make necessary changes to port gRPC and package it for supported platforms.
* **Required skills:** Python programming language, PyPy Python interpreter.
* **Required skills:** Python programming language, Python 3.5 interpreter.
* **Likely mentors:** [Nathaniel Manista](https://github.com/nathanielmanistaatgoogle), [Masood Malekghassemi](https://github.com/soltanmm).
gRPC Ruby/Java:

@ -118,14 +118,14 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_init();
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
grpc_end2end_tests(argc, argv, configs[i]);
}
GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0));
GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1));
GPR_ASSERT(1 == grpc_tracer_set_enabled("all", 1));
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
grpc_end2end_tests(argc, argv, configs[i]);
}
grpc_shutdown();
return 0;

@ -1,350 +0,0 @@
/*
*
* 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 "test/core/end2end/end2end_tests.h"
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
#include <grpc/support/useful.h>
#include "src/core/channel/channel_args.h"
#include "src/core/channel/client_channel.h"
#include "src/core/channel/client_uchannel.h"
#include "src/core/channel/connected_channel.h"
#include "src/core/channel/http_client_filter.h"
#include "src/core/channel/http_server_filter.h"
#include "src/core/client_config/resolver_registry.h"
#include "src/core/iomgr/tcp_client.h"
#include "src/core/surface/channel.h"
#include "src/core/surface/server.h"
#include "src/core/transport/chttp2_transport.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
typedef struct {
grpc_connector base;
gpr_refcount refs;
grpc_closure *notify;
grpc_connect_in_args args;
grpc_connect_out_args *result;
grpc_endpoint *tcp;
grpc_closure connected;
} connector;
static void connector_ref(grpc_connector *con) {
connector *c = (connector *)con;
gpr_ref(&c->refs);
}
static void connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *con) {
connector *c = (connector *)con;
if (gpr_unref(&c->refs)) {
gpr_free(c);
}
}
static void connected(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
connector *c = arg;
grpc_closure *notify;
grpc_endpoint *tcp = c->tcp;
if (tcp != NULL) {
c->result->transport =
grpc_create_chttp2_transport(exec_ctx, c->args.channel_args, tcp, 1);
grpc_chttp2_transport_start_reading(exec_ctx, c->result->transport, NULL,
0);
GPR_ASSERT(c->result->transport);
} else {
memset(c->result, 0, sizeof(*c->result));
}
notify = c->notify;
c->notify = NULL;
notify->cb(exec_ctx, notify->cb_arg, 1);
}
static void connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *con) {}
static void connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *con,
const grpc_connect_in_args *args,
grpc_connect_out_args *result,
grpc_closure *notify) {
connector *c = (connector *)con;
GPR_ASSERT(c->notify == NULL);
GPR_ASSERT(notify->cb);
c->notify = notify;
c->args = *args;
c->result = result;
c->tcp = NULL;
grpc_closure_init(&c->connected, connected, c);
grpc_tcp_client_connect(exec_ctx, &c->connected, &c->tcp,
args->interested_parties, args->addr, args->addr_len,
args->deadline);
}
static const grpc_connector_vtable connector_vtable = {
connector_ref, connector_unref, connector_shutdown, connector_connect};
typedef struct {
grpc_subchannel_factory base;
gpr_refcount refs;
grpc_channel_args *merge_args;
grpc_channel *master;
grpc_subchannel **sniffed_subchannel;
} subchannel_factory;
static void subchannel_factory_ref(grpc_subchannel_factory *scf) {
subchannel_factory *f = (subchannel_factory *)scf;
gpr_ref(&f->refs);
}
static void subchannel_factory_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel_factory *scf) {
subchannel_factory *f = (subchannel_factory *)scf;
if (gpr_unref(&f->refs)) {
GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, f->master, "subchannel_factory");
grpc_channel_args_destroy(f->merge_args);
gpr_free(f);
}
}
static grpc_subchannel *subchannel_factory_create_subchannel(
grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *scf,
grpc_subchannel_args *args) {
subchannel_factory *f = (subchannel_factory *)scf;
connector *c = gpr_malloc(sizeof(*c));
grpc_channel_args *final_args =
grpc_channel_args_merge(args->args, f->merge_args);
grpc_subchannel *s;
memset(c, 0, sizeof(*c));
c->base.vtable = &connector_vtable;
gpr_ref_init(&c->refs, 1);
args->args = final_args;
s = grpc_subchannel_create(exec_ctx, &c->base, args);
grpc_connector_unref(exec_ctx, &c->base);
grpc_channel_args_destroy(final_args);
if (*f->sniffed_subchannel) {
GRPC_SUBCHANNEL_UNREF(exec_ctx, *f->sniffed_subchannel, "sniffed");
}
*f->sniffed_subchannel = s;
GRPC_SUBCHANNEL_REF(s, "sniffed");
return s;
}
static const grpc_subchannel_factory_vtable test_subchannel_factory_vtable = {
subchannel_factory_ref, subchannel_factory_unref,
subchannel_factory_create_subchannel};
/* The evil twin of grpc_insecure_channel_create. It allows the test to use the
* custom-built sniffing subchannel_factory */
grpc_channel *channel_create(const char *target, const grpc_channel_args *args,
grpc_subchannel **sniffed_subchannel) {
grpc_channel *channel = NULL;
grpc_resolver *resolver;
subchannel_factory *f;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
channel =
grpc_channel_create(&exec_ctx, target, args, GRPC_CLIENT_CHANNEL, NULL);
f = gpr_malloc(sizeof(*f));
f->sniffed_subchannel = sniffed_subchannel;
f->base.vtable = &test_subchannel_factory_vtable;
gpr_ref_init(&f->refs, 1);
f->merge_args = grpc_channel_args_copy(args);
f->master = channel;
GRPC_CHANNEL_INTERNAL_REF(f->master, "test_subchannel_factory");
resolver = grpc_resolver_create(target, &f->base);
if (!resolver) {
return NULL;
}
grpc_client_channel_set_resolver(
&exec_ctx, grpc_channel_get_channel_stack(channel), resolver);
GRPC_RESOLVER_UNREF(&exec_ctx, resolver, "test_create");
grpc_subchannel_factory_unref(&exec_ctx, &f->base);
grpc_exec_ctx_finish(&exec_ctx);
return channel;
}
typedef struct micro_fullstack_fixture_data {
char *localaddr;
grpc_channel *master_channel;
grpc_subchannel *sniffed_subchannel;
} micro_fullstack_fixture_data;
static grpc_end2end_test_fixture chttp2_create_fixture_micro_fullstack(
grpc_channel_args *client_args, grpc_channel_args *server_args) {
grpc_end2end_test_fixture f;
int port = grpc_pick_unused_port_or_die();
micro_fullstack_fixture_data *ffd =
gpr_malloc(sizeof(micro_fullstack_fixture_data));
memset(&f, 0, sizeof(f));
memset(ffd, 0, sizeof(*ffd));
gpr_join_host_port(&ffd->localaddr, "127.0.0.1", port);
f.fixture_data = ffd;
f.cq = grpc_completion_queue_create(NULL);
return f;
}
grpc_connectivity_state g_state = GRPC_CHANNEL_IDLE;
grpc_pollset_set *g_interested_parties;
static void state_changed(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
if (g_state != GRPC_CHANNEL_READY) {
grpc_subchannel_notify_on_state_change(
exec_ctx, arg, g_interested_parties, &g_state,
grpc_closure_create(state_changed, arg));
}
}
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
grpc_pollset_destroy(arg);
}
static grpc_connected_subchannel *connect_subchannel(grpc_subchannel *c) {
gpr_mu *mu;
grpc_pollset *pollset = gpr_malloc(grpc_pollset_size());
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_pollset_init(pollset, &mu);
g_interested_parties = grpc_pollset_set_create();
grpc_pollset_set_add_pollset(&exec_ctx, g_interested_parties, pollset);
grpc_subchannel_notify_on_state_change(&exec_ctx, c, g_interested_parties,
&g_state,
grpc_closure_create(state_changed, c));
grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(mu);
while (g_state != GRPC_CHANNEL_READY) {
grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1));
gpr_mu_unlock(mu);
grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(mu);
}
grpc_pollset_shutdown(&exec_ctx, pollset,
grpc_closure_create(destroy_pollset, pollset));
grpc_pollset_set_destroy(g_interested_parties);
gpr_mu_unlock(mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(pollset);
return grpc_subchannel_get_connected_subchannel(c);
}
static void chttp2_init_client_micro_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args) {
micro_fullstack_fixture_data *ffd = f->fixture_data;
grpc_connectivity_state conn_state;
grpc_connected_subchannel *connected_subchannel;
char *ipv4_localaddr;
gpr_asprintf(&ipv4_localaddr, "ipv4:%s", ffd->localaddr);
ffd->master_channel =
channel_create(ipv4_localaddr, client_args, &ffd->sniffed_subchannel);
gpr_free(ipv4_localaddr);
gpr_log(GPR_INFO, "MASTER CHANNEL %p ", ffd->master_channel);
/* the following will block. That's ok for this test */
conn_state = grpc_channel_check_connectivity_state(ffd->master_channel,
1 /* try to connect */);
GPR_ASSERT(conn_state == GRPC_CHANNEL_IDLE);
/* here sniffed_subchannel should be ready to use */
GPR_ASSERT(conn_state == GRPC_CHANNEL_IDLE);
GPR_ASSERT(ffd->sniffed_subchannel != NULL);
connected_subchannel = connect_subchannel(ffd->sniffed_subchannel);
f->client = grpc_client_uchannel_create(ffd->sniffed_subchannel, client_args);
grpc_client_uchannel_set_connected_subchannel(f->client,
connected_subchannel);
gpr_log(GPR_INFO, "CHANNEL WRAPPING SUBCHANNEL: %p(%p)", f->client,
ffd->sniffed_subchannel);
GPR_ASSERT(f->client);
}
static void chttp2_init_server_micro_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *server_args) {
micro_fullstack_fixture_data *ffd = f->fixture_data;
if (f->server) {
grpc_server_destroy(f->server);
}
f->server = grpc_server_create(server_args, NULL);
grpc_server_register_completion_queue(f->server, f->cq, NULL);
GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr));
grpc_server_start(f->server);
}
static void chttp2_tear_down_micro_fullstack(grpc_end2end_test_fixture *f) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
micro_fullstack_fixture_data *ffd = f->fixture_data;
grpc_channel_destroy(ffd->master_channel);
if (ffd->sniffed_subchannel) {
GRPC_SUBCHANNEL_UNREF(&exec_ctx, ffd->sniffed_subchannel, "sniffed");
}
gpr_free(ffd->localaddr);
gpr_free(ffd);
grpc_exec_ctx_finish(&exec_ctx);
}
/* All test configurations */
static grpc_end2end_test_config configs[] = {
{"chttp2/micro_fullstack", 0, chttp2_create_fixture_micro_fullstack,
chttp2_init_client_micro_fullstack, chttp2_init_server_micro_fullstack,
chttp2_tear_down_micro_fullstack},
};
int main(int argc, char **argv) {
size_t i;
grpc_test_init(argc, argv);
grpc_init();
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) {
grpc_end2end_tests(argc, argv, configs[i]);
}
grpc_shutdown();
return 0;
}

@ -72,7 +72,6 @@ END2END_FIXTURES = {
'h2_ssl+poll': default_secure_fixture_options._replace(platforms=['linux']),
'h2_ssl_proxy': default_secure_fixture_options._replace(includes_proxy=True,
ci_mac=False),
'h2_uchannel': default_unsecure_fixture_options._replace(fullstack=False),
'h2_uds+poll': uds_fixture_options._replace(platforms=['linux']),
'h2_uds': uds_fixture_options,
}

@ -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 @@
*
*/
#include "src/core/httpcli/format_request.h"
#include "src/core/http/format_request.h"
#include <string.h>
@ -39,15 +39,15 @@
#include "test/core/util/test_config.h"
static void test_format_get_request(void) {
grpc_httpcli_header hdr = {"x-yz", "abc"};
grpc_http_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
gpr_slice slice;
memset(&req, 0, sizeof(req));
req.host = "example.com";
req.path = "/index.html";
req.hdr_count = 1;
req.hdrs = &hdr;
req.http.path = "/index.html";
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
slice = grpc_httpcli_format_get_request(&req);
@ -64,7 +64,7 @@ static void test_format_get_request(void) {
}
static void test_format_post_request(void) {
grpc_httpcli_header hdr = {"x-yz", "abc"};
grpc_http_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
gpr_slice slice;
char body_bytes[] = "fake body";
@ -72,9 +72,9 @@ static void test_format_post_request(void) {
memset(&req, 0, sizeof(req));
req.host = "example.com";
req.path = "/index.html";
req.hdr_count = 1;
req.hdrs = &hdr;
req.http.path = "/index.html";
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len);
@ -94,15 +94,15 @@ static void test_format_post_request(void) {
}
static void test_format_post_request_no_body(void) {
grpc_httpcli_header hdr = {"x-yz", "abc"};
grpc_http_header hdr = {"x-yz", "abc"};
grpc_httpcli_request req;
gpr_slice slice;
memset(&req, 0, sizeof(req));
req.host = "example.com";
req.path = "/index.html";
req.hdr_count = 1;
req.hdrs = &hdr;
req.http.path = "/index.html";
req.http.hdr_count = 1;
req.http.hdrs = &hdr;
slice = grpc_httpcli_format_post_request(&req, NULL, 0);
@ -119,7 +119,7 @@ static void test_format_post_request_no_body(void) {
}
static void test_format_post_request_content_type_override(void) {
grpc_httpcli_header hdrs[2];
grpc_http_header hdrs[2];
grpc_httpcli_request req;
gpr_slice slice;
char body_bytes[] = "fake%20body";
@ -131,9 +131,9 @@ static void test_format_post_request_content_type_override(void) {
hdrs[1].value = "application/x-www-form-urlencoded";
memset(&req, 0, sizeof(req));
req.host = "example.com";
req.path = "/index.html";
req.hdr_count = 2;
req.hdrs = hdrs;
req.http.path = "/index.html";
req.http.hdr_count = 2;
req.http.hdrs = hdrs;
slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len);

@ -31,7 +31,7 @@
*
*/
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/httpcli.h"
#include <string.h>
@ -83,7 +83,7 @@ static void test_get(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
req.path = "/get";
req.http.path = "/get";
req.handshaker = &grpc_httpcli_plaintext;
grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15),
@ -114,7 +114,7 @@ static void test_post(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
req.path = "/post";
req.http.path = "/post";
req.handshaker = &grpc_httpcli_plaintext;
grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5,
@ -161,7 +161,7 @@ int main(int argc, char **argv) {
} else {
arg_shift = 1;
gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root);
gpr_asprintf(&args[1], "%s/../../test/core/httpcli/test_server.py", root);
gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root);
}
/* start the server */

@ -31,7 +31,7 @@
*
*/
#include "src/core/httpcli/httpcli.h"
#include "src/core/http/httpcli.h"
#include <string.h>
@ -84,7 +84,7 @@ static void test_get(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
req.ssl_host_override = "foo.test.google.fr";
req.path = "/get";
req.http.path = "/get";
req.handshaker = &grpc_httpcli_ssl;
grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15),
@ -116,7 +116,7 @@ static void test_post(int port) {
memset(&req, 0, sizeof(req));
req.host = host;
req.ssl_host_override = "foo.test.google.fr";
req.path = "/post";
req.http.path = "/post";
req.handshaker = &grpc_httpcli_ssl;
grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5,
@ -163,7 +163,7 @@ int main(int argc, char **argv) {
} else {
arg_shift = 1;
gpr_asprintf(&args[0], "%s/../../tools/distrib/python_wrapper.sh", root);
gpr_asprintf(&args[1], "%s/../../test/core/httpcli/test_server.py", root);
gpr_asprintf(&args[1], "%s/../../test/core/http/test_server.py", root);
}
/* start the server */

@ -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 @@
*
*/
#include "src/core/httpcli/parser.h"
#include "src/core/http/parser.h"
#include <stdarg.h>
#include <string.h>
@ -43,9 +43,65 @@
#include "test/core/util/slice_splitter.h"
#include "test/core/util/test_config.h"
static void test_request_succeeds(grpc_slice_split_mode split_mode,
char *request, char *expect_method,
grpc_http_version expect_version,
char *expect_path, char *expect_body, ...) {
grpc_http_parser parser;
gpr_slice input_slice = gpr_slice_from_copied_string(request);
size_t num_slices;
size_t i;
gpr_slice *slices;
va_list args;
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
gpr_slice_unref(input_slice);
grpc_http_parser_init(&parser);
for (i = 0; i < num_slices; i++) {
GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i]));
gpr_slice_unref(slices[i]);
}
GPR_ASSERT(grpc_http_parser_eof(&parser));
GPR_ASSERT(GRPC_HTTP_REQUEST == parser.type);
GPR_ASSERT(0 == strcmp(expect_method, parser.http.request.method));
GPR_ASSERT(0 == strcmp(expect_path, parser.http.request.path));
GPR_ASSERT(expect_version == parser.http.request.version);
if (expect_body != NULL) {
GPR_ASSERT(strlen(expect_body) == parser.http.request.body_length);
GPR_ASSERT(0 == memcmp(expect_body, parser.http.request.body,
parser.http.request.body_length));
} else {
GPR_ASSERT(parser.http.request.body_length == 0);
}
va_start(args, expect_body);
i = 0;
for (;;) {
char *expect_key;
char *expect_value;
expect_key = va_arg(args, char *);
if (!expect_key) break;
GPR_ASSERT(i < parser.http.request.hdr_count);
expect_value = va_arg(args, char *);
GPR_ASSERT(expect_value);
GPR_ASSERT(0 == strcmp(expect_key, parser.http.request.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, parser.http.request.hdrs[i].value));
i++;
}
va_end(args);
GPR_ASSERT(i == parser.http.request.hdr_count);
grpc_http_parser_destroy(&parser);
gpr_free(slices);
}
static void test_succeeds(grpc_slice_split_mode split_mode, char *response,
int expect_status, char *expect_body, ...) {
grpc_httpcli_parser parser;
grpc_http_parser parser;
gpr_slice input_slice = gpr_slice_from_copied_string(response);
size_t num_slices;
size_t i;
@ -55,20 +111,22 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response,
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
gpr_slice_unref(input_slice);
grpc_httpcli_parser_init(&parser);
grpc_http_parser_init(&parser);
for (i = 0; i < num_slices; i++) {
GPR_ASSERT(grpc_httpcli_parser_parse(&parser, slices[i]));
GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i]));
gpr_slice_unref(slices[i]);
}
GPR_ASSERT(grpc_httpcli_parser_eof(&parser));
GPR_ASSERT(grpc_http_parser_eof(&parser));
GPR_ASSERT(expect_status == parser.r.status);
GPR_ASSERT(GRPC_HTTP_RESPONSE == parser.type);
GPR_ASSERT(expect_status == parser.http.response.status);
if (expect_body != NULL) {
GPR_ASSERT(strlen(expect_body) == parser.r.body_length);
GPR_ASSERT(0 == memcmp(expect_body, parser.r.body, parser.r.body_length));
GPR_ASSERT(strlen(expect_body) == parser.http.response.body_length);
GPR_ASSERT(0 == memcmp(expect_body, parser.http.response.body,
parser.http.response.body_length));
} else {
GPR_ASSERT(parser.r.body_length == 0);
GPR_ASSERT(parser.http.response.body_length == 0);
}
va_start(args, expect_body);
@ -78,22 +136,22 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response,
char *expect_value;
expect_key = va_arg(args, char *);
if (!expect_key) break;
GPR_ASSERT(i < parser.r.hdr_count);
GPR_ASSERT(i < parser.http.response.hdr_count);
expect_value = va_arg(args, char *);
GPR_ASSERT(expect_value);
GPR_ASSERT(0 == strcmp(expect_key, parser.r.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, parser.r.hdrs[i].value));
GPR_ASSERT(0 == strcmp(expect_key, parser.http.response.hdrs[i].key));
GPR_ASSERT(0 == strcmp(expect_value, parser.http.response.hdrs[i].value));
i++;
}
va_end(args);
GPR_ASSERT(i == parser.r.hdr_count);
GPR_ASSERT(i == parser.http.response.hdr_count);
grpc_httpcli_parser_destroy(&parser);
grpc_http_parser_destroy(&parser);
gpr_free(slices);
}
static void test_fails(grpc_slice_split_mode split_mode, char *response) {
grpc_httpcli_parser parser;
grpc_http_parser parser;
gpr_slice input_slice = gpr_slice_from_copied_string(response);
size_t num_slices;
size_t i;
@ -103,20 +161,20 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response) {
grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices);
gpr_slice_unref(input_slice);
grpc_httpcli_parser_init(&parser);
grpc_http_parser_init(&parser);
for (i = 0; i < num_slices; i++) {
if (!done && !grpc_httpcli_parser_parse(&parser, slices[i])) {
if (!done && !grpc_http_parser_parse(&parser, slices[i])) {
done = 1;
}
gpr_slice_unref(slices[i]);
}
if (!done && !grpc_httpcli_parser_eof(&parser)) {
if (!done && !grpc_http_parser_eof(&parser)) {
done = 1;
}
GPR_ASSERT(done);
grpc_httpcli_parser_destroy(&parser);
grpc_http_parser_destroy(&parser);
gpr_free(slices);
}
@ -145,6 +203,32 @@ int main(int argc, char **argv) {
"\r\n"
"hello world!",
200, "hello world!", "xyz", "abc", NULL);
test_request_succeeds(split_modes[i],
"GET / HTTP/1.0\r\n"
"\r\n",
"GET", GRPC_HTTP_HTTP10, "/", NULL, NULL);
test_request_succeeds(split_modes[i],
"GET / HTTP/1.0\r\n"
"\r\n"
"xyz",
"GET", GRPC_HTTP_HTTP10, "/", "xyz", NULL);
test_request_succeeds(split_modes[i],
"GET / HTTP/1.1\r\n"
"\r\n"
"xyz",
"GET", GRPC_HTTP_HTTP11, "/", "xyz", NULL);
test_request_succeeds(split_modes[i],
"GET / HTTP/2.0\r\n"
"\r\n"
"xyz",
"GET", GRPC_HTTP_HTTP20, "/", "xyz", NULL);
test_request_succeeds(split_modes[i],
"GET / HTTP/1.0\r\n"
"xyz: abc\r\n"
"\r\n"
"xyz",
"GET", GRPC_HTTP_HTTP10, "/", "xyz", "xyz", "abc",
NULL);
test_fails(split_modes[i], "HTTP/1.0\r\n");
test_fails(split_modes[i], "HTTP/1.2\r\n");
test_fails(split_modes[i], "HTTP/1.0 000 XYX\r\n");
@ -157,10 +241,15 @@ int main(int argc, char **argv) {
" def\r\n"
"\r\n"
"hello world!");
test_fails(split_modes[i], "GET\r\n");
test_fails(split_modes[i], "GET /\r\n");
test_fails(split_modes[i], "GET / HTTP/0.0\r\n");
test_fails(split_modes[i], "GET / ____/1.0\r\n");
test_fails(split_modes[i], "GET / HTTP/1.2\r\n");
tmp1 = gpr_malloc(2 * GRPC_HTTPCLI_MAX_HEADER_LENGTH);
memset(tmp1, 'a', 2 * GRPC_HTTPCLI_MAX_HEADER_LENGTH - 1);
tmp1[2 * GRPC_HTTPCLI_MAX_HEADER_LENGTH - 1] = 0;
tmp1 = gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
memset(tmp1, 'a', 2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1);
tmp1[2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1] = 0;
gpr_asprintf(&tmp2, "HTTP/1.0 200 OK\r\nxyz: %s\r\n\r\n", tmp1);
test_fails(split_modes[i], tmp2);
gpr_free(tmp1);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save