Merge branch 'master' of https://github.com/grpc/grpc into slice_to_cstring

pull/2200/head
Julien Boeuf 10 years ago
commit aeff1b9aa0
  1. 2
      .travis.yml
  2. 379
      BUILD
  3. 116
      Makefile
  4. 84
      build.json
  5. 416
      gRPC.podspec
  6. 1
      include/grpc++/impl/call.h
  7. 4
      include/grpc/grpc.h
  8. 2
      include/grpc/support/slice_buffer.h
  9. 21
      src/compiler/objective_c_generator.cc
  10. 2
      src/compiler/python_generator.cc
  11. 2
      src/core/census/context.c
  12. 10
      src/core/channel/client_channel.c
  13. 17
      src/core/channel/http_client_filter.c
  14. 15
      src/core/channel/http_server_filter.c
  15. 4
      src/core/iomgr/iomgr.h
  16. 12
      src/core/iomgr/pollset_windows.c
  17. 1
      src/core/iomgr/pollset_windows.h
  18. 4
      src/core/support/histogram.c
  19. 16
      src/core/support/slice_buffer.c
  20. 61
      src/core/surface/call.c
  21. 16
      src/core/surface/completion_queue.c
  22. 12
      src/core/surface/completion_queue.h
  23. 6
      src/core/surface/lame_client.c
  24. 12
      src/core/surface/server.c
  25. 76
      src/core/transport/chttp2/bin_encoder.c
  26. 20
      src/core/transport/chttp2/frame.h
  27. 27
      src/core/transport/chttp2/frame_data.c
  28. 3
      src/core/transport/chttp2/frame_data.h
  29. 30
      src/core/transport/chttp2/frame_goaway.c
  30. 3
      src/core/transport/chttp2/frame_goaway.h
  31. 20
      src/core/transport/chttp2/frame_ping.c
  32. 3
      src/core/transport/chttp2/frame_ping.h
  33. 13
      src/core/transport/chttp2/frame_rst_stream.c
  34. 3
      src/core/transport/chttp2/frame_rst_stream.h
  35. 15
      src/core/transport/chttp2/frame_settings.c
  36. 3
      src/core/transport/chttp2/frame_settings.h
  37. 23
      src/core/transport/chttp2/frame_window_update.c
  38. 3
      src/core/transport/chttp2/frame_window_update.h
  39. 52
      src/core/transport/chttp2/hpack_parser.c
  40. 4
      src/core/transport/chttp2/hpack_parser.h
  41. 3
      src/core/transport/chttp2/hpack_table.c
  42. 323
      src/core/transport/chttp2/huffsyms.c
  43. 177
      src/core/transport/chttp2/incoming_metadata.c
  44. 80
      src/core/transport/chttp2/incoming_metadata.h
  45. 609
      src/core/transport/chttp2/internal.h
  46. 813
      src/core/transport/chttp2/parsing.c
  47. 352
      src/core/transport/chttp2/stream_lists.c
  48. 44
      src/core/transport/chttp2/stream_map.c
  49. 4
      src/core/transport/chttp2/stream_map.h
  50. 5
      src/core/transport/chttp2/varint.h
  51. 215
      src/core/transport/chttp2/writing.c
  52. 2387
      src/core/transport/chttp2_transport.c
  53. 14
      src/core/transport/stream_op.c
  54. 2
      src/core/transport/stream_op.h
  55. 11
      src/core/transport/transport.c
  56. 16
      src/core/transport/transport.h
  57. 3
      src/core/transport/transport_impl.h
  58. 1
      src/cpp/client/channel.cc
  59. 14
      src/cpp/client/channel_arguments.cc
  60. 54
      src/cpp/client/secure_channel_arguments.cc
  61. 3
      src/cpp/server/insecure_server_credentials.cc
  62. 1
      src/cpp/server/server.cc
  63. 2
      src/cpp/server/server_credentials.cc
  64. 8
      src/objective-c/GRPCClient/private/GRPCSecureChannel.m
  65. 20
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m
  66. 8
      src/objective-c/tests/InteropTests.m
  67. 19
      src/php/README.md
  68. 49
      src/php/bin/determine_extension_dir.sh
  69. 11
      src/php/bin/interop_client.sh
  70. 11
      src/php/bin/run_gen_code_test.sh
  71. 35
      src/php/bin/run_tests.sh
  72. 5
      src/php/ext/grpc/config.m4
  73. 66
      templates/BUILD.template
  74. 44
      templates/gRPC.podspec.template
  75. 2
      templates/tools/doxygen/Doxyfile.include
  76. 33
      templates/tools/run_tests/sources_and_headers.json.template
  77. 9
      test/core/bad_client/gen_build_json.py
  78. 34
      test/core/end2end/gen_build_json.py
  79. 2
      test/core/end2end/tests/invoke_large_request.c
  80. 39
      test/cpp/end2end/end2end_test.cc
  81. 6
      test/cpp/qps/client_async.cc
  82. 2
      test/cpp/qps/qps_worker.cc
  83. 2
      test/cpp/qps/worker.cc
  84. 27
      test/proto/messages.proto
  85. 8
      test/proto/test.proto
  86. 33
      tools/codegen/core/gen_hpack_tables.c
  87. 38
      tools/doxygen/Doxyfile.c++
  88. 69
      tools/doxygen/Doxyfile.c++.internal
  89. 36
      tools/doxygen/Doxyfile.core
  90. 303
      tools/doxygen/Doxyfile.core.internal
  91. 45
      tools/jenkins/docker_run_jenkins.sh
  92. 2
      tools/jenkins/grpc_jenkins_slave/Dockerfile
  93. 33
      tools/jenkins/run_jenkins.sh
  94. 55
      tools/run_tests/check_sources_and_headers.py
  95. 31
      tools/run_tests/jobset.py
  96. 21
      tools/run_tests/run_tests.py
  97. 10600
      tools/run_tests/sources_and_headers.json
  98. 4
      vsprojects/Grpc.mak
  99. 2
      vsprojects/grpc++/grpc++.vcxproj
  100. 3
      vsprojects/grpc++/grpc++.vcxproj.filters
  101. Some files were not shown because too many files have changed in this diff Show More

@ -34,7 +34,7 @@ script:
- if [ ! -z "$USE_GCC" ] ; then export CC=gcc-$USE_GCC ; export CXX=g++-$USE_GCC ; fi - if [ ! -z "$USE_GCC" ] ; then export CC=gcc-$USE_GCC ; export CXX=g++-$USE_GCC ; fi
- ./tools/run_tests/run_tests.py -l $TEST -t -j $JOBS -c $CONFIG -s 4.0 - ./tools/run_tests/run_tests.py -l $TEST -t -j $JOBS -c $CONFIG -s 4.0
after_success: after_success:
- if [ "$CONFIG" = "gcov" ] ; then coveralls --exclude third_party --exclude gens --exclude test --exclude src/compiler -b. --gcov-options '\-p' ; fi - if [ "$CONFIG" = "gcov" ] ; then coveralls --exclude third_party --exclude gens --exclude test --exclude tools --exclude src/compiler -b. --gcov-options '\-p' ; fi
notifications: notifications:
email: false email: false
webhooks: webhooks:

379
BUILD

@ -219,6 +219,8 @@ cc_library(
"src/core/transport/chttp2/hpack_table.h", "src/core/transport/chttp2/hpack_table.h",
"src/core/transport/chttp2/http2_errors.h", "src/core/transport/chttp2/http2_errors.h",
"src/core/transport/chttp2/huffsyms.h", "src/core/transport/chttp2/huffsyms.h",
"src/core/transport/chttp2/incoming_metadata.h",
"src/core/transport/chttp2/internal.h",
"src/core/transport/chttp2/status_conversion.h", "src/core/transport/chttp2/status_conversion.h",
"src/core/transport/chttp2/stream_encoder.h", "src/core/transport/chttp2/stream_encoder.h",
"src/core/transport/chttp2/stream_map.h", "src/core/transport/chttp2/stream_map.h",
@ -336,11 +338,15 @@ cc_library(
"src/core/transport/chttp2/hpack_parser.c", "src/core/transport/chttp2/hpack_parser.c",
"src/core/transport/chttp2/hpack_table.c", "src/core/transport/chttp2/hpack_table.c",
"src/core/transport/chttp2/huffsyms.c", "src/core/transport/chttp2/huffsyms.c",
"src/core/transport/chttp2/incoming_metadata.c",
"src/core/transport/chttp2/parsing.c",
"src/core/transport/chttp2/status_conversion.c", "src/core/transport/chttp2/status_conversion.c",
"src/core/transport/chttp2/stream_encoder.c", "src/core/transport/chttp2/stream_encoder.c",
"src/core/transport/chttp2/stream_lists.c",
"src/core/transport/chttp2/stream_map.c", "src/core/transport/chttp2/stream_map.c",
"src/core/transport/chttp2/timeout_encoding.c", "src/core/transport/chttp2/timeout_encoding.c",
"src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/varint.c",
"src/core/transport/chttp2/writing.c",
"src/core/transport/chttp2_transport.c", "src/core/transport/chttp2_transport.c",
"src/core/transport/metadata.c", "src/core/transport/metadata.c",
"src/core/transport/stream_op.c", "src/core/transport/stream_op.c",
@ -445,6 +451,8 @@ cc_library(
"src/core/transport/chttp2/hpack_table.h", "src/core/transport/chttp2/hpack_table.h",
"src/core/transport/chttp2/http2_errors.h", "src/core/transport/chttp2/http2_errors.h",
"src/core/transport/chttp2/huffsyms.h", "src/core/transport/chttp2/huffsyms.h",
"src/core/transport/chttp2/incoming_metadata.h",
"src/core/transport/chttp2/internal.h",
"src/core/transport/chttp2/status_conversion.h", "src/core/transport/chttp2/status_conversion.h",
"src/core/transport/chttp2/stream_encoder.h", "src/core/transport/chttp2/stream_encoder.h",
"src/core/transport/chttp2/stream_map.h", "src/core/transport/chttp2/stream_map.h",
@ -540,11 +548,15 @@ cc_library(
"src/core/transport/chttp2/hpack_parser.c", "src/core/transport/chttp2/hpack_parser.c",
"src/core/transport/chttp2/hpack_table.c", "src/core/transport/chttp2/hpack_table.c",
"src/core/transport/chttp2/huffsyms.c", "src/core/transport/chttp2/huffsyms.c",
"src/core/transport/chttp2/incoming_metadata.c",
"src/core/transport/chttp2/parsing.c",
"src/core/transport/chttp2/status_conversion.c", "src/core/transport/chttp2/status_conversion.c",
"src/core/transport/chttp2/stream_encoder.c", "src/core/transport/chttp2/stream_encoder.c",
"src/core/transport/chttp2/stream_lists.c",
"src/core/transport/chttp2/stream_map.c", "src/core/transport/chttp2/stream_map.c",
"src/core/transport/chttp2/timeout_encoding.c", "src/core/transport/chttp2/timeout_encoding.c",
"src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/varint.c",
"src/core/transport/chttp2/writing.c",
"src/core/transport/chttp2_transport.c", "src/core/transport/chttp2_transport.c",
"src/core/transport/metadata.c", "src/core/transport/metadata.c",
"src/core/transport/stream_op.c", "src/core/transport/stream_op.c",
@ -578,6 +590,7 @@ cc_library(
"src/cpp/server/secure_server_credentials.h", "src/cpp/server/secure_server_credentials.h",
"src/cpp/client/channel.h", "src/cpp/client/channel.h",
"src/cpp/server/thread_pool.h", "src/cpp/server/thread_pool.h",
"src/cpp/client/secure_channel_arguments.cc",
"src/cpp/client/secure_credentials.cc", "src/cpp/client/secure_credentials.cc",
"src/cpp/server/secure_server_credentials.cc", "src/cpp/server/secure_server_credentials.cc",
"src/cpp/client/channel.cc", "src/cpp/client/channel.cc",
@ -740,6 +753,8 @@ cc_library(
cc_library( cc_library(
name = "grpc_plugin_support", name = "grpc_plugin_support",
srcs = [ srcs = [
"include/grpc++/config.h",
"include/grpc++/config_protobuf.h",
"src/compiler/config.h", "src/compiler/config.h",
"src/compiler/cpp_generator.h", "src/compiler/cpp_generator.h",
"src/compiler/cpp_generator_helpers.h", "src/compiler/cpp_generator_helpers.h",
@ -790,6 +805,342 @@ cc_library(
objc_library(
name = "gpr_objc",
srcs = [
"src/core/support/alloc.c",
"src/core/support/cancellable.c",
"src/core/support/cmdline.c",
"src/core/support/cpu_iphone.c",
"src/core/support/cpu_linux.c",
"src/core/support/cpu_posix.c",
"src/core/support/cpu_windows.c",
"src/core/support/env_linux.c",
"src/core/support/env_posix.c",
"src/core/support/env_win32.c",
"src/core/support/file.c",
"src/core/support/file_posix.c",
"src/core/support/file_win32.c",
"src/core/support/histogram.c",
"src/core/support/host_port.c",
"src/core/support/log.c",
"src/core/support/log_android.c",
"src/core/support/log_linux.c",
"src/core/support/log_posix.c",
"src/core/support/log_win32.c",
"src/core/support/murmur_hash.c",
"src/core/support/slice.c",
"src/core/support/slice_buffer.c",
"src/core/support/string.c",
"src/core/support/string_posix.c",
"src/core/support/string_win32.c",
"src/core/support/subprocess_posix.c",
"src/core/support/sync.c",
"src/core/support/sync_posix.c",
"src/core/support/sync_win32.c",
"src/core/support/thd.c",
"src/core/support/thd_posix.c",
"src/core/support/thd_win32.c",
"src/core/support/time.c",
"src/core/support/time_posix.c",
"src/core/support/time_win32.c",
"src/core/support/tls_pthread.c",
],
hdrs = [
"include/grpc/support/alloc.h",
"include/grpc/support/atm.h",
"include/grpc/support/atm_gcc_atomic.h",
"include/grpc/support/atm_gcc_sync.h",
"include/grpc/support/atm_win32.h",
"include/grpc/support/cancellable_platform.h",
"include/grpc/support/cmdline.h",
"include/grpc/support/cpu.h",
"include/grpc/support/histogram.h",
"include/grpc/support/host_port.h",
"include/grpc/support/log.h",
"include/grpc/support/log_win32.h",
"include/grpc/support/port_platform.h",
"include/grpc/support/slice.h",
"include/grpc/support/slice_buffer.h",
"include/grpc/support/string_util.h",
"include/grpc/support/subprocess.h",
"include/grpc/support/sync.h",
"include/grpc/support/sync_generic.h",
"include/grpc/support/sync_posix.h",
"include/grpc/support/sync_win32.h",
"include/grpc/support/thd.h",
"include/grpc/support/time.h",
"include/grpc/support/tls.h",
"include/grpc/support/tls_gcc.h",
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
"src/core/support/env.h",
"src/core/support/file.h",
"src/core/support/murmur_hash.h",
"src/core/support/string.h",
"src/core/support/string_win32.h",
"src/core/support/thd_internal.h",
],
includes = [
"include",
".",
],
deps = [
],
)
objc_library(
name = "grpc_objc",
srcs = [
"src/core/httpcli/format_request.c",
"src/core/httpcli/httpcli.c",
"src/core/httpcli/httpcli_security_connector.c",
"src/core/httpcli/parser.c",
"src/core/security/base64.c",
"src/core/security/client_auth_filter.c",
"src/core/security/credentials.c",
"src/core/security/credentials_metadata.c",
"src/core/security/credentials_posix.c",
"src/core/security/credentials_win32.c",
"src/core/security/google_default_credentials.c",
"src/core/security/json_token.c",
"src/core/security/secure_endpoint.c",
"src/core/security/secure_transport_setup.c",
"src/core/security/security_connector.c",
"src/core/security/security_context.c",
"src/core/security/server_auth_filter.c",
"src/core/security/server_secure_chttp2.c",
"src/core/surface/init_secure.c",
"src/core/surface/secure_channel_create.c",
"src/core/tsi/fake_transport_security.c",
"src/core/tsi/ssl_transport_security.c",
"src/core/tsi/transport_security.c",
"src/core/census/grpc_context.c",
"src/core/channel/channel_args.c",
"src/core/channel/channel_stack.c",
"src/core/channel/child_channel.c",
"src/core/channel/client_channel.c",
"src/core/channel/client_setup.c",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
"src/core/channel/http_server_filter.c",
"src/core/channel/noop_filter.c",
"src/core/compression/algorithm.c",
"src/core/compression/message_compress.c",
"src/core/debug/trace.c",
"src/core/iomgr/alarm.c",
"src/core/iomgr/alarm_heap.c",
"src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c",
"src/core/iomgr/endpoint_pair_windows.c",
"src/core/iomgr/fd_posix.c",
"src/core/iomgr/iocp_windows.c",
"src/core/iomgr/iomgr.c",
"src/core/iomgr/iomgr_posix.c",
"src/core/iomgr/iomgr_windows.c",
"src/core/iomgr/pollset_kick_posix.c",
"src/core/iomgr/pollset_multipoller_with_epoll.c",
"src/core/iomgr/pollset_multipoller_with_poll_posix.c",
"src/core/iomgr/pollset_posix.c",
"src/core/iomgr/pollset_set_posix.c",
"src/core/iomgr/pollset_set_windows.c",
"src/core/iomgr/pollset_windows.c",
"src/core/iomgr/resolve_address_posix.c",
"src/core/iomgr/resolve_address_windows.c",
"src/core/iomgr/sockaddr_utils.c",
"src/core/iomgr/socket_utils_common_posix.c",
"src/core/iomgr/socket_utils_linux.c",
"src/core/iomgr/socket_utils_posix.c",
"src/core/iomgr/socket_windows.c",
"src/core/iomgr/tcp_client_posix.c",
"src/core/iomgr/tcp_client_windows.c",
"src/core/iomgr/tcp_posix.c",
"src/core/iomgr/tcp_server_posix.c",
"src/core/iomgr/tcp_server_windows.c",
"src/core/iomgr/tcp_windows.c",
"src/core/iomgr/time_averaged_stats.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
"src/core/iomgr/wakeup_fd_posix.c",
"src/core/json/json.c",
"src/core/json/json_reader.c",
"src/core/json/json_string.c",
"src/core/json/json_writer.c",
"src/core/profiling/basic_timers.c",
"src/core/profiling/stap_timers.c",
"src/core/surface/byte_buffer.c",
"src/core/surface/byte_buffer_queue.c",
"src/core/surface/byte_buffer_reader.c",
"src/core/surface/call.c",
"src/core/surface/call_details.c",
"src/core/surface/call_log_batch.c",
"src/core/surface/channel.c",
"src/core/surface/channel_create.c",
"src/core/surface/client.c",
"src/core/surface/completion_queue.c",
"src/core/surface/event_string.c",
"src/core/surface/init.c",
"src/core/surface/lame_client.c",
"src/core/surface/metadata_array.c",
"src/core/surface/server.c",
"src/core/surface/server_chttp2.c",
"src/core/surface/server_create.c",
"src/core/surface/surface_trace.c",
"src/core/transport/chttp2/alpn.c",
"src/core/transport/chttp2/bin_encoder.c",
"src/core/transport/chttp2/frame_data.c",
"src/core/transport/chttp2/frame_goaway.c",
"src/core/transport/chttp2/frame_ping.c",
"src/core/transport/chttp2/frame_rst_stream.c",
"src/core/transport/chttp2/frame_settings.c",
"src/core/transport/chttp2/frame_window_update.c",
"src/core/transport/chttp2/hpack_parser.c",
"src/core/transport/chttp2/hpack_table.c",
"src/core/transport/chttp2/huffsyms.c",
"src/core/transport/chttp2/incoming_metadata.c",
"src/core/transport/chttp2/parsing.c",
"src/core/transport/chttp2/status_conversion.c",
"src/core/transport/chttp2/stream_encoder.c",
"src/core/transport/chttp2/stream_lists.c",
"src/core/transport/chttp2/stream_map.c",
"src/core/transport/chttp2/timeout_encoding.c",
"src/core/transport/chttp2/varint.c",
"src/core/transport/chttp2/writing.c",
"src/core/transport/chttp2_transport.c",
"src/core/transport/metadata.c",
"src/core/transport/stream_op.c",
"src/core/transport/transport.c",
"src/core/transport/transport_op_string.c",
"src/core/census/context.c",
"src/core/census/initialize.c",
],
hdrs = [
"include/grpc/grpc_security.h",
"include/grpc/byte_buffer.h",
"include/grpc/byte_buffer_reader.h",
"include/grpc/compression.h",
"include/grpc/grpc.h",
"include/grpc/status.h",
"include/grpc/census.h",
"src/core/httpcli/format_request.h",
"src/core/httpcli/httpcli.h",
"src/core/httpcli/httpcli_security_connector.h",
"src/core/httpcli/parser.h",
"src/core/security/auth_filters.h",
"src/core/security/base64.h",
"src/core/security/credentials.h",
"src/core/security/json_token.h",
"src/core/security/secure_endpoint.h",
"src/core/security/secure_transport_setup.h",
"src/core/security/security_connector.h",
"src/core/security/security_context.h",
"src/core/tsi/fake_transport_security.h",
"src/core/tsi/ssl_transport_security.h",
"src/core/tsi/transport_security.h",
"src/core/tsi/transport_security_interface.h",
"src/core/census/grpc_context.h",
"src/core/channel/census_filter.h",
"src/core/channel/channel_args.h",
"src/core/channel/channel_stack.h",
"src/core/channel/child_channel.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_setup.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
"src/core/channel/http_client_filter.h",
"src/core/channel/http_server_filter.h",
"src/core/channel/noop_filter.h",
"src/core/compression/message_compress.h",
"src/core/debug/trace.h",
"src/core/iomgr/alarm.h",
"src/core/iomgr/alarm_heap.h",
"src/core/iomgr/alarm_internal.h",
"src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h",
"src/core/iomgr/fd_posix.h",
"src/core/iomgr/iocp_windows.h",
"src/core/iomgr/iomgr.h",
"src/core/iomgr/iomgr_internal.h",
"src/core/iomgr/iomgr_posix.h",
"src/core/iomgr/pollset.h",
"src/core/iomgr/pollset_kick_posix.h",
"src/core/iomgr/pollset_posix.h",
"src/core/iomgr/pollset_set.h",
"src/core/iomgr/pollset_set_posix.h",
"src/core/iomgr/pollset_set_windows.h",
"src/core/iomgr/pollset_windows.h",
"src/core/iomgr/resolve_address.h",
"src/core/iomgr/sockaddr.h",
"src/core/iomgr/sockaddr_posix.h",
"src/core/iomgr/sockaddr_utils.h",
"src/core/iomgr/sockaddr_win32.h",
"src/core/iomgr/socket_utils_posix.h",
"src/core/iomgr/socket_windows.h",
"src/core/iomgr/tcp_client.h",
"src/core/iomgr/tcp_posix.h",
"src/core/iomgr/tcp_server.h",
"src/core/iomgr/tcp_windows.h",
"src/core/iomgr/time_averaged_stats.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/json/json.h",
"src/core/json/json_common.h",
"src/core/json/json_reader.h",
"src/core/json/json_writer.h",
"src/core/profiling/timers.h",
"src/core/profiling/timers_preciseclock.h",
"src/core/surface/byte_buffer_queue.h",
"src/core/surface/call.h",
"src/core/surface/channel.h",
"src/core/surface/client.h",
"src/core/surface/completion_queue.h",
"src/core/surface/event_string.h",
"src/core/surface/init.h",
"src/core/surface/server.h",
"src/core/surface/surface_trace.h",
"src/core/transport/chttp2/alpn.h",
"src/core/transport/chttp2/bin_encoder.h",
"src/core/transport/chttp2/frame.h",
"src/core/transport/chttp2/frame_data.h",
"src/core/transport/chttp2/frame_goaway.h",
"src/core/transport/chttp2/frame_ping.h",
"src/core/transport/chttp2/frame_rst_stream.h",
"src/core/transport/chttp2/frame_settings.h",
"src/core/transport/chttp2/frame_window_update.h",
"src/core/transport/chttp2/hpack_parser.h",
"src/core/transport/chttp2/hpack_table.h",
"src/core/transport/chttp2/http2_errors.h",
"src/core/transport/chttp2/huffsyms.h",
"src/core/transport/chttp2/incoming_metadata.h",
"src/core/transport/chttp2/internal.h",
"src/core/transport/chttp2/status_conversion.h",
"src/core/transport/chttp2/stream_encoder.h",
"src/core/transport/chttp2/stream_map.h",
"src/core/transport/chttp2/timeout_encoding.h",
"src/core/transport/chttp2/varint.h",
"src/core/transport/chttp2_transport.h",
"src/core/transport/metadata.h",
"src/core/transport/stream_op.h",
"src/core/transport/transport.h",
"src/core/transport/transport_impl.h",
"src/core/census/context.h",
],
includes = [
"include",
".",
],
deps = [
":gpr_objc",
"//external:libssl_objc",
],
sdk_dylibs = ["libz"],
)
cc_binary( cc_binary(
name = "grpc_cpp_plugin", name = "grpc_cpp_plugin",
srcs = [ srcs = [
@ -854,6 +1205,8 @@ cc_binary(
objc_path = "src/objective-c" objc_path = "src/objective-c"
rx_library_path = objc_path + "/RxLibrary" rx_library_path = objc_path + "/RxLibrary"
@ -880,3 +1233,29 @@ objc_library(
srcs = glob([rx_library_path + "/private/*.m"]), srcs = glob([rx_library_path + "/private/*.m"]),
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
) )
objc_client_path = objc_path + "/GRPCClient"
objc_library(
name = "grpc_client",
hdrs = glob([
objc_client_path + "/*.h",
objc_client_path + "/private/*.h",
]),
srcs = glob([
objc_client_path + "/*.m",
objc_client_path + "/private/*.m",
]),
includes = [objc_path],
bundles = [":gRPCCertificates"],
deps = [
":grpc_objc",
":rx_library",
],
)
objc_bundle_library(
# The choice of name is signicant here, since it determines the bundle name.
name = "gRPCCertificates",
resources = ["etc/roots.pem"],
)

@ -1261,7 +1261,7 @@ privatelibs: privatelibs_c privatelibs_cxx
privatelibs_c: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fake_security.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fullstack_uds_posix.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fullstack_with_poll.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_simple_ssl_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_simple_ssl_fullstack_with_poll.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_simple_ssl_with_oauth2_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair_one_byte_at_a_time.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair_with_grpc_trace.a $(LIBDIR)/$(CONFIG)/libend2end_test_bad_hostname.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_accept.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_accept_and_writes_closed.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_invoke.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_before_invoke.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_in_a_vacuum.a $(LIBDIR)/$(CONFIG)/libend2end_test_census_simple_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_disappearing_server.a $(LIBDIR)/$(CONFIG)/libend2end_test_early_server_shutdown_finishes_inflight_calls.a $(LIBDIR)/$(CONFIG)/libend2end_test_early_server_shutdown_finishes_tags.a $(LIBDIR)/$(CONFIG)/libend2end_test_empty_batch.a $(LIBDIR)/$(CONFIG)/libend2end_test_graceful_server_shutdown.a $(LIBDIR)/$(CONFIG)/libend2end_test_invoke_large_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_max_concurrent_streams.a $(LIBDIR)/$(CONFIG)/libend2end_test_max_message_length.a $(LIBDIR)/$(CONFIG)/libend2end_test_no_op.a $(LIBDIR)/$(CONFIG)/libend2end_test_ping_pong_streaming.a $(LIBDIR)/$(CONFIG)/libend2end_test_registered_call.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_binary_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_payload_and_call_creds.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_trailing_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_with_flags.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_with_large_metadata.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_with_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_server_finishes_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_delayed_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_request_with_high_initial_sequence_number.a $(LIBDIR)/$(CONFIG)/libend2end_certs.a $(LIBDIR)/$(CONFIG)/libbad_client_test.a privatelibs_c: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fake_security.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fullstack_uds_posix.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fullstack_with_poll.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_simple_ssl_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_simple_ssl_fullstack_with_poll.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_simple_ssl_with_oauth2_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair_one_byte_at_a_time.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair_with_grpc_trace.a $(LIBDIR)/$(CONFIG)/libend2end_test_bad_hostname.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_accept.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_accept_and_writes_closed.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_invoke.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_before_invoke.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_in_a_vacuum.a $(LIBDIR)/$(CONFIG)/libend2end_test_census_simple_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_disappearing_server.a $(LIBDIR)/$(CONFIG)/libend2end_test_early_server_shutdown_finishes_inflight_calls.a $(LIBDIR)/$(CONFIG)/libend2end_test_early_server_shutdown_finishes_tags.a $(LIBDIR)/$(CONFIG)/libend2end_test_empty_batch.a $(LIBDIR)/$(CONFIG)/libend2end_test_graceful_server_shutdown.a $(LIBDIR)/$(CONFIG)/libend2end_test_invoke_large_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_max_concurrent_streams.a $(LIBDIR)/$(CONFIG)/libend2end_test_max_message_length.a $(LIBDIR)/$(CONFIG)/libend2end_test_no_op.a $(LIBDIR)/$(CONFIG)/libend2end_test_ping_pong_streaming.a $(LIBDIR)/$(CONFIG)/libend2end_test_registered_call.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_binary_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_payload_and_call_creds.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_trailing_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_with_flags.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_with_large_metadata.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_with_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_server_finishes_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_delayed_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_request_with_high_initial_sequence_number.a $(LIBDIR)/$(CONFIG)/libend2end_certs.a $(LIBDIR)/$(CONFIG)/libbad_client_test.a
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a
buildtests: buildtests_c buildtests_cxx buildtests: buildtests_c buildtests_cxx
@ -3093,11 +3093,15 @@ LIBGRPC_SRC = \
src/core/transport/chttp2/hpack_parser.c \ src/core/transport/chttp2/hpack_parser.c \
src/core/transport/chttp2/hpack_table.c \ src/core/transport/chttp2/hpack_table.c \
src/core/transport/chttp2/huffsyms.c \ src/core/transport/chttp2/huffsyms.c \
src/core/transport/chttp2/incoming_metadata.c \
src/core/transport/chttp2/parsing.c \
src/core/transport/chttp2/status_conversion.c \ src/core/transport/chttp2/status_conversion.c \
src/core/transport/chttp2/stream_encoder.c \ src/core/transport/chttp2/stream_encoder.c \
src/core/transport/chttp2/stream_lists.c \
src/core/transport/chttp2/stream_map.c \ src/core/transport/chttp2/stream_map.c \
src/core/transport/chttp2/timeout_encoding.c \ src/core/transport/chttp2/timeout_encoding.c \
src/core/transport/chttp2/varint.c \ src/core/transport/chttp2/varint.c \
src/core/transport/chttp2/writing.c \
src/core/transport/chttp2_transport.c \ src/core/transport/chttp2_transport.c \
src/core/transport/metadata.c \ src/core/transport/metadata.c \
src/core/transport/stream_op.c \ src/core/transport/stream_op.c \
@ -3339,11 +3343,15 @@ LIBGRPC_UNSECURE_SRC = \
src/core/transport/chttp2/hpack_parser.c \ src/core/transport/chttp2/hpack_parser.c \
src/core/transport/chttp2/hpack_table.c \ src/core/transport/chttp2/hpack_table.c \
src/core/transport/chttp2/huffsyms.c \ src/core/transport/chttp2/huffsyms.c \
src/core/transport/chttp2/incoming_metadata.c \
src/core/transport/chttp2/parsing.c \
src/core/transport/chttp2/status_conversion.c \ src/core/transport/chttp2/status_conversion.c \
src/core/transport/chttp2/stream_encoder.c \ src/core/transport/chttp2/stream_encoder.c \
src/core/transport/chttp2/stream_lists.c \
src/core/transport/chttp2/stream_map.c \ src/core/transport/chttp2/stream_map.c \
src/core/transport/chttp2/timeout_encoding.c \ src/core/transport/chttp2/timeout_encoding.c \
src/core/transport/chttp2/varint.c \ src/core/transport/chttp2/varint.c \
src/core/transport/chttp2/writing.c \
src/core/transport/chttp2_transport.c \ src/core/transport/chttp2_transport.c \
src/core/transport/metadata.c \ src/core/transport/metadata.c \
src/core/transport/stream_op.c \ src/core/transport/stream_op.c \
@ -3397,6 +3405,7 @@ endif
LIBGRPC++_SRC = \ LIBGRPC++_SRC = \
src/cpp/client/secure_channel_arguments.cc \
src/cpp/client/secure_credentials.cc \ src/cpp/client/secure_credentials.cc \
src/cpp/server/secure_server_credentials.cc \ src/cpp/server/secure_server_credentials.cc \
src/cpp/client/channel.cc \ src/cpp/client/channel.cc \
@ -3533,57 +3542,6 @@ endif
endif endif
LIBGRPC++_BENCHMARK_CONFIG_SRC = \
$(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc \
test/cpp/qps/report.cc \
test/cpp/util/benchmark_config.cc \
LIBGRPC++_BENCHMARK_CONFIG_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_BENCHMARK_CONFIG_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure libraries if you don't have OpenSSL with ALPN.
$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: protobuf_dep_error
else
$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_BENCHMARK_CONFIG_OBJS)
$(E) "[AR] Creating $@"
$(Q) mkdir -p `dirname $@`
$(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a
$(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBGRPC++_BENCHMARK_CONFIG_OBJS)
ifeq ($(SYSTEM),Darwin)
$(Q) ranlib $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a
endif
endif
endif
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(LIBGRPC++_BENCHMARK_CONFIG_OBJS:.o=.dep)
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
LIBGRPC++_TEST_CONFIG_SRC = \ LIBGRPC++_TEST_CONFIG_SRC = \
test/cpp/util/test_config.cc \ test/cpp/util/test_config.cc \
@ -4100,9 +4058,11 @@ LIBQPS_SRC = \
test/cpp/qps/client_sync.cc \ test/cpp/qps/client_sync.cc \
test/cpp/qps/driver.cc \ test/cpp/qps/driver.cc \
test/cpp/qps/qps_worker.cc \ test/cpp/qps/qps_worker.cc \
test/cpp/qps/report.cc \
test/cpp/qps/server_async.cc \ test/cpp/qps/server_async.cc \
test/cpp/qps/server_sync.cc \ test/cpp/qps/server_sync.cc \
test/cpp/qps/timer.cc \ test/cpp/qps/timer.cc \
test/cpp/util/benchmark_config.cc \
LIBQPS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBQPS_SRC)))) LIBQPS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBQPS_SRC))))
@ -4150,9 +4110,11 @@ $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/test/cpp/qps/qpstest.
$(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc
LIBGRPC_CSHARP_EXT_SRC = \ LIBGRPC_CSHARP_EXT_SRC = \
@ -5691,7 +5653,7 @@ endif
GEN_HPACK_TABLES_SRC = \ GEN_HPACK_TABLES_SRC = \
src/core/transport/chttp2/gen_hpack_tables.c \ tools/codegen/core/gen_hpack_tables.c \
GEN_HPACK_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_HPACK_TABLES_SRC)))) GEN_HPACK_TABLES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GEN_HPACK_TABLES_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
@ -5702,14 +5664,14 @@ $(BINDIR)/$(CONFIG)/gen_hpack_tables: openssl_dep_error
else else
$(BINDIR)/$(CONFIG)/gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(BINDIR)/$(CONFIG)/gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_hpack_tables $(Q) $(LD) $(LDFLAGS) $(GEN_HPACK_TABLES_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gen_hpack_tables
endif endif
$(OBJDIR)/$(CONFIG)/src/core/transport/chttp2/gen_hpack_tables.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(OBJDIR)/$(CONFIG)/tools/codegen/core/gen_hpack_tables.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a
deps_gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS:.o=.dep) deps_gen_hpack_tables: $(GEN_HPACK_TABLES_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
@ -7346,16 +7308,16 @@ $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test: $(PROTOBUF_DEP) $(ASYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test: $(PROTOBUF_DEP) $(ASYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(ASYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test $(Q) $(LDXX) $(LDFLAGS) $(ASYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/async_streaming_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/async_streaming_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_async_streaming_ping_pong_test: $(ASYNC_STREAMING_PING_PONG_TEST_OBJS:.o=.dep) deps_async_streaming_ping_pong_test: $(ASYNC_STREAMING_PING_PONG_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
@ -7386,16 +7348,16 @@ $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/async_unary_ping_pong_test: $(PROTOBUF_DEP) $(ASYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test: $(PROTOBUF_DEP) $(ASYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(ASYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test $(Q) $(LDXX) $(LDFLAGS) $(ASYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/async_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/async_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_async_unary_ping_pong_test: $(ASYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep) deps_async_unary_ping_pong_test: $(ASYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
@ -8264,16 +8226,16 @@ $(BINDIR)/$(CONFIG)/qps_driver: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/qps_driver: $(PROTOBUF_DEP) $(QPS_DRIVER_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(BINDIR)/$(CONFIG)/qps_driver: $(PROTOBUF_DEP) $(QPS_DRIVER_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(QPS_DRIVER_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_driver $(Q) $(LDXX) $(LDFLAGS) $(QPS_DRIVER_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_driver
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_driver.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_driver.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
deps_qps_driver: $(QPS_DRIVER_OBJS:.o=.dep) deps_qps_driver: $(QPS_DRIVER_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
@ -8344,16 +8306,16 @@ $(BINDIR)/$(CONFIG)/qps_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/qps_test: $(PROTOBUF_DEP) $(QPS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(BINDIR)/$(CONFIG)/qps_test: $(PROTOBUF_DEP) $(QPS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(QPS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_test $(Q) $(LDXX) $(LDFLAGS) $(QPS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
deps_qps_test: $(QPS_TEST_OBJS:.o=.dep) deps_qps_test: $(QPS_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
@ -8384,16 +8346,16 @@ $(BINDIR)/$(CONFIG)/qps_test_openloop: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/qps_test_openloop: $(PROTOBUF_DEP) $(QPS_TEST_OPENLOOP_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(BINDIR)/$(CONFIG)/qps_test_openloop: $(PROTOBUF_DEP) $(QPS_TEST_OPENLOOP_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(QPS_TEST_OPENLOOP_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_test_openloop $(Q) $(LDXX) $(LDFLAGS) $(QPS_TEST_OPENLOOP_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_test_openloop
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_test_openloop.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_test_openloop.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a
deps_qps_test_openloop: $(QPS_TEST_OPENLOOP_OBJS:.o=.dep) deps_qps_test_openloop: $(QPS_TEST_OPENLOOP_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
@ -8584,16 +8546,16 @@ $(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test: $(PROTOBUF_DEP) $(SYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test: $(PROTOBUF_DEP) $(SYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(SYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test $(Q) $(LDXX) $(LDFLAGS) $(SYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/sync_streaming_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/sync_streaming_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_sync_streaming_ping_pong_test: $(SYNC_STREAMING_PING_PONG_TEST_OBJS:.o=.dep) deps_sync_streaming_ping_pong_test: $(SYNC_STREAMING_PING_PONG_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
@ -8624,16 +8586,16 @@ $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test: protobuf_dep_error
else else
$(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test: $(PROTOBUF_DEP) $(SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test: $(PROTOBUF_DEP) $(SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test $(Q) $(LDXX) $(LDFLAGS) $(SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test
endif endif
endif endif
$(OBJDIR)/$(CONFIG)/test/cpp/qps/sync_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/cpp/qps/sync_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_sync_unary_ping_pong_test: $(SYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep) deps_sync_unary_ping_pong_test: $(SYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)

@ -180,6 +180,8 @@
"src/core/transport/chttp2/hpack_table.h", "src/core/transport/chttp2/hpack_table.h",
"src/core/transport/chttp2/http2_errors.h", "src/core/transport/chttp2/http2_errors.h",
"src/core/transport/chttp2/huffsyms.h", "src/core/transport/chttp2/huffsyms.h",
"src/core/transport/chttp2/incoming_metadata.h",
"src/core/transport/chttp2/internal.h",
"src/core/transport/chttp2/status_conversion.h", "src/core/transport/chttp2/status_conversion.h",
"src/core/transport/chttp2/stream_encoder.h", "src/core/transport/chttp2/stream_encoder.h",
"src/core/transport/chttp2/stream_map.h", "src/core/transport/chttp2/stream_map.h",
@ -275,11 +277,15 @@
"src/core/transport/chttp2/hpack_parser.c", "src/core/transport/chttp2/hpack_parser.c",
"src/core/transport/chttp2/hpack_table.c", "src/core/transport/chttp2/hpack_table.c",
"src/core/transport/chttp2/huffsyms.c", "src/core/transport/chttp2/huffsyms.c",
"src/core/transport/chttp2/incoming_metadata.c",
"src/core/transport/chttp2/parsing.c",
"src/core/transport/chttp2/status_conversion.c", "src/core/transport/chttp2/status_conversion.c",
"src/core/transport/chttp2/stream_encoder.c", "src/core/transport/chttp2/stream_encoder.c",
"src/core/transport/chttp2/stream_lists.c",
"src/core/transport/chttp2/stream_map.c", "src/core/transport/chttp2/stream_map.c",
"src/core/transport/chttp2/timeout_encoding.c", "src/core/transport/chttp2/timeout_encoding.c",
"src/core/transport/chttp2/varint.c", "src/core/transport/chttp2/varint.c",
"src/core/transport/chttp2/writing.c",
"src/core/transport/chttp2_transport.c", "src/core/transport/chttp2_transport.c",
"src/core/transport/metadata.c", "src/core/transport/metadata.c",
"src/core/transport/stream_op.c", "src/core/transport/stream_op.c",
@ -289,6 +295,14 @@
}, },
{ {
"name": "grpc_test_util_base", "name": "grpc_test_util_base",
"headers": [
"test/core/end2end/cq_verifier.h",
"test/core/iomgr/endpoint_tests.h",
"test/core/util/grpc_profiler.h",
"test/core/util/parse_hexstring.h",
"test/core/util/port.h",
"test/core/util/slice_splitter.h"
],
"src": [ "src": [
"test/core/end2end/cq_verifier.c", "test/core/end2end/cq_verifier.c",
"test/core/iomgr/endpoint_tests.c", "test/core/iomgr/endpoint_tests.c",
@ -466,6 +480,9 @@
"name": "grpc_test_util", "name": "grpc_test_util",
"build": "private", "build": "private",
"language": "c", "language": "c",
"headers": [
"test/core/end2end/data/ssl_test_data.h"
],
"src": [ "src": [
"test/core/end2end/data/server1_cert.c", "test/core/end2end/data/server1_cert.c",
"test/core/end2end/data/server1_key.c", "test/core/end2end/data/server1_key.c",
@ -523,6 +540,7 @@
"src/cpp/server/secure_server_credentials.h" "src/cpp/server/secure_server_credentials.h"
], ],
"src": [ "src": [
"src/cpp/client/secure_channel_arguments.cc",
"src/cpp/client/secure_credentials.cc", "src/cpp/client/secure_credentials.cc",
"src/cpp/server/secure_server_credentials.cc" "src/cpp/server/secure_server_credentials.cc"
], ],
@ -537,20 +555,13 @@
"secure": "check", "secure": "check",
"vs_project_guid": "{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}" "vs_project_guid": "{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}"
}, },
{
"name": "grpc++_benchmark_config",
"build": "private",
"language": "c++",
"src": [
"test/cpp/qps/qpstest.proto",
"test/cpp/qps/report.cc",
"test/cpp/util/benchmark_config.cc"
]
},
{ {
"name": "grpc++_test_config", "name": "grpc++_test_config",
"build": "private", "build": "private",
"language": "c++", "language": "c++",
"headers": [
"test/cpp/util/test_config.h"
],
"src": [ "src": [
"test/cpp/util/test_config.cc" "test/cpp/util/test_config.cc"
] ]
@ -559,6 +570,12 @@
"name": "grpc++_test_util", "name": "grpc++_test_util",
"build": "private", "build": "private",
"language": "c++", "language": "c++",
"headers": [
"test/cpp/util/cli_call.h",
"test/cpp/util/create_test_channel.h",
"test/cpp/util/fake_credentials.h",
"test/cpp/util/subprocess.h"
],
"src": [ "src": [
"test/cpp/util/messages.proto", "test/cpp/util/messages.proto",
"test/cpp/util/echo.proto", "test/cpp/util/echo.proto",
@ -567,6 +584,10 @@
"test/cpp/util/create_test_channel.cc", "test/cpp/util/create_test_channel.cc",
"test/cpp/util/fake_credentials.cc", "test/cpp/util/fake_credentials.cc",
"test/cpp/util/subprocess.cc" "test/cpp/util/subprocess.cc"
],
"deps": [
"grpc++",
"grpc_test_util"
] ]
}, },
{ {
@ -589,6 +610,8 @@
"build": "protoc", "build": "protoc",
"language": "c++", "language": "c++",
"headers": [ "headers": [
"include/grpc++/config.h",
"include/grpc++/config_protobuf.h",
"src/compiler/config.h", "src/compiler/config.h",
"src/compiler/cpp_generator.h", "src/compiler/cpp_generator.h",
"src/compiler/cpp_generator_helpers.h", "src/compiler/cpp_generator_helpers.h",
@ -618,6 +641,9 @@
"name": "interop_client_helper", "name": "interop_client_helper",
"build": "private", "build": "private",
"language": "c++", "language": "c++",
"headers": [
"test/cpp/interop/client_helper.h"
],
"src": [ "src": [
"test/cpp/interop/client_helper.cc" "test/cpp/interop/client_helper.cc"
], ],
@ -633,6 +659,9 @@
"name": "interop_client_main", "name": "interop_client_main",
"build": "private", "build": "private",
"language": "c++", "language": "c++",
"headers": [
"test/cpp/interop/interop_client.h"
],
"src": [ "src": [
"test/proto/empty.proto", "test/proto/empty.proto",
"test/proto/messages.proto", "test/proto/messages.proto",
@ -641,6 +670,7 @@
"test/cpp/interop/interop_client.cc" "test/cpp/interop/interop_client.cc"
], ],
"deps": [ "deps": [
"interop_client_helper",
"grpc++_test_util", "grpc++_test_util",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
@ -654,6 +684,9 @@
"name": "interop_server_helper", "name": "interop_server_helper",
"build": "private", "build": "private",
"language": "c++", "language": "c++",
"headers": [
"test/cpp/interop/server_helper.h"
],
"src": [ "src": [
"test/cpp/interop/server_helper.cc" "test/cpp/interop/server_helper.cc"
], ],
@ -675,6 +708,7 @@
"test/cpp/interop/server.cc" "test/cpp/interop/server.cc"
], ],
"deps": [ "deps": [
"interop_server_helper",
"grpc++_test_util", "grpc++_test_util",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
@ -688,6 +722,10 @@
"name": "pubsub_client_lib", "name": "pubsub_client_lib",
"build": "do_not_build", "build": "do_not_build",
"language": "c++", "language": "c++",
"headers": [
"examples/pubsub/publisher.h",
"examples/pubsub/subscriber.h"
],
"src": [ "src": [
"examples/pubsub/label.proto", "examples/pubsub/label.proto",
"examples/pubsub/empty.proto", "examples/pubsub/empty.proto",
@ -706,11 +744,16 @@
"build": "private", "build": "private",
"language": "c++", "language": "c++",
"headers": [ "headers": [
"test/cpp/qps/client.h",
"test/cpp/qps/driver.h", "test/cpp/qps/driver.h",
"test/cpp/qps/histogram.h",
"test/cpp/qps/interarrival.h", "test/cpp/qps/interarrival.h",
"test/cpp/qps/qps_worker.h", "test/cpp/qps/qps_worker.h",
"test/cpp/qps/report.h", "test/cpp/qps/report.h",
"test/cpp/qps/timer.h" "test/cpp/qps/server.h",
"test/cpp/qps/stats.h",
"test/cpp/qps/timer.h",
"test/cpp/util/benchmark_config.h"
], ],
"src": [ "src": [
"test/cpp/qps/qpstest.proto", "test/cpp/qps/qpstest.proto",
@ -718,13 +761,16 @@
"test/cpp/qps/client_sync.cc", "test/cpp/qps/client_sync.cc",
"test/cpp/qps/driver.cc", "test/cpp/qps/driver.cc",
"test/cpp/qps/qps_worker.cc", "test/cpp/qps/qps_worker.cc",
"test/cpp/qps/report.cc",
"test/cpp/qps/server_async.cc", "test/cpp/qps/server_async.cc",
"test/cpp/qps/server_sync.cc", "test/cpp/qps/server_sync.cc",
"test/cpp/qps/timer.cc" "test/cpp/qps/timer.cc",
"test/cpp/util/benchmark_config.cc"
], ],
"deps": [ "deps": [
"grpc_test_util", "grpc_test_util",
"grpc++_test_util" "grpc++_test_util",
"grpc++"
] ]
}, },
{ {
@ -957,10 +1003,9 @@
"build": "tool", "build": "tool",
"language": "c", "language": "c",
"src": [ "src": [
"src/core/transport/chttp2/gen_hpack_tables.c" "tools/codegen/core/gen_hpack_tables.c"
], ],
"deps": [ "deps": [
"grpc_test_util",
"gpr", "gpr",
"grpc" "grpc"
] ]
@ -1729,7 +1774,6 @@
"deps": [ "deps": [
"qps", "qps",
"grpc++_test_util", "grpc++_test_util",
"grpc++_benchmark_config",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
"grpc", "grpc",
@ -1747,7 +1791,6 @@
"deps": [ "deps": [
"qps", "qps",
"grpc++_test_util", "grpc++_test_util",
"grpc++_benchmark_config",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
"grpc", "grpc",
@ -2123,8 +2166,7 @@
"grpc", "grpc",
"gpr_test_util", "gpr_test_util",
"gpr", "gpr",
"grpc++_test_config", "grpc++_test_config"
"grpc++_benchmark_config"
] ]
}, },
{ {
@ -2155,7 +2197,6 @@
"deps": [ "deps": [
"qps", "qps",
"grpc++_test_util", "grpc++_test_util",
"grpc++_benchmark_config",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
"grpc", "grpc",
@ -2174,7 +2215,6 @@
"deps": [ "deps": [
"qps", "qps",
"grpc++_test_util", "grpc++_test_util",
"grpc++_benchmark_config",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
"grpc", "grpc",
@ -2263,7 +2303,6 @@
"deps": [ "deps": [
"qps", "qps",
"grpc++_test_util", "grpc++_test_util",
"grpc++_benchmark_config",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
"grpc", "grpc",
@ -2281,7 +2320,6 @@
"deps": [ "deps": [
"qps", "qps",
"grpc++_test_util", "grpc++_test_util",
"grpc++_benchmark_config",
"grpc_test_util", "grpc_test_util",
"grpc++", "grpc++",
"grpc", "grpc",

File diff suppressed because one or more lines are too long

@ -41,6 +41,7 @@
#include <grpc++/status.h> #include <grpc++/status.h>
#include <grpc++/impl/serialization_traits.h> #include <grpc++/impl/serialization_traits.h>
#include <functional>
#include <memory> #include <memory>
#include <map> #include <map>

@ -396,7 +396,9 @@ grpc_call *grpc_channel_create_registered_call(
completion of type 'tag' to the completion queue bound to the call. completion of type 'tag' to the completion queue bound to the call.
The order of ops specified in the batch has no significance. The order of ops specified in the batch has no significance.
Only one operation of each type can be active at once in any given Only one operation of each type can be active at once in any given
batch. batch. You must call grpc_completion_queue_next or
grpc_completion_queue_pluck on the completion queue associated with 'call'
for work to be performed.
THREAD SAFETY: access to grpc_call_start_batch in multi-threaded environment THREAD SAFETY: access to grpc_call_start_batch in multi-threaded environment
needs to be synchronized. As an optimization, you may synchronize batches needs to be synchronized. As an optimization, you may synchronize batches
containing just send operations independently from batches containing just containing just send operations independently from batches containing just

@ -84,6 +84,8 @@ void gpr_slice_buffer_pop(gpr_slice_buffer *sb);
void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb); void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb);
/* swap the contents of two slice buffers */ /* swap the contents of two slice buffers */
void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b); void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b);
/* move all of the elements of src into dst */
void gpr_slice_buffer_move_into(gpr_slice_buffer *src, gpr_slice_buffer *dst);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -68,18 +68,19 @@ void PrintMethodSignature(Printer *printer,
printer->Print(vars, "- ($return_type$)$method_name$With"); printer->Print(vars, "- ($return_type$)$method_name$With");
if (method->client_streaming()) { if (method->client_streaming()) {
printer->Print("RequestsWriter:(id<GRXWriter>)request"); printer->Print("RequestsWriter:(id<GRXWriter>)requestWriter");
} else { } else {
printer->Print(vars, "Request:($request_class$ *)request"); printer->Print(vars, "Request:($request_class$ *)request");
} }
// TODO(jcanizales): Put this on a new line and align colons. // TODO(jcanizales): Put this on a new line and align colons.
// TODO(jcanizales): eventHandler for server streaming?
printer->Print(" handler:(void(^)(");
if (method->server_streaming()) { if (method->server_streaming()) {
printer->Print("BOOL done, "); printer->Print(vars, " eventHandler:(void(^)(BOOL done, "
"$response_class$ *response, NSError *error))eventHandler");
} else {
printer->Print(vars, " handler:(void(^)($response_class$ *response, "
"NSError *error))handler");
} }
printer->Print(vars, "$response_class$ *response, NSError *error))handler");
} }
void PrintSimpleSignature(Printer *printer, void PrintSimpleSignature(Printer *printer,
@ -125,11 +126,15 @@ void PrintSimpleImplementation(Printer *printer,
printer->Print("{\n"); printer->Print("{\n");
printer->Print(vars, " [[self RPCTo$method_name$With"); printer->Print(vars, " [[self RPCTo$method_name$With");
if (method->client_streaming()) { if (method->client_streaming()) {
printer->Print("RequestsWriter:request"); printer->Print("RequestsWriter:requestWriter");
} else { } else {
printer->Print("Request:request"); printer->Print("Request:request");
} }
if (method->server_streaming()) {
printer->Print(" eventHandler:eventHandler] start];\n");
} else {
printer->Print(" handler:handler] start];\n"); printer->Print(" handler:handler] start];\n");
}
printer->Print("}\n"); printer->Print("}\n");
} }
@ -141,7 +146,7 @@ void PrintAdvancedImplementation(Printer *printer,
printer->Print(" requestsWriter:"); printer->Print(" requestsWriter:");
if (method->client_streaming()) { if (method->client_streaming()) {
printer->Print("request\n"); printer->Print("requestWriter\n");
} else { } else {
printer->Print("[GRXWriter writerWithValue:request]\n"); printer->Print("[GRXWriter writerWithValue:request]\n");
} }
@ -150,7 +155,7 @@ void PrintAdvancedImplementation(Printer *printer,
printer->Print(" responsesWriteable:[GRXWriteable "); printer->Print(" responsesWriteable:[GRXWriteable ");
if (method->server_streaming()) { if (method->server_streaming()) {
printer->Print("writeableWithStreamHandler:handler]];\n"); printer->Print("writeableWithStreamHandler:eventHandler]];\n");
} else { } else {
printer->Print("writeableWithSingleValueHandler:handler]];\n"); printer->Print("writeableWithSingleValueHandler:handler]];\n");
} }

@ -42,7 +42,7 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include "grpc++/config.h" #include <grpc++/config.h>
#include "src/compiler/config.h" #include "src/compiler/config.h"
#include "src/compiler/generator_helpers.h" #include "src/compiler/generator_helpers.h"
#include "src/compiler/python_generator.h" #include "src/compiler/python_generator.h"

@ -31,7 +31,7 @@
* *
*/ */
#include "context.h" #include "src/core/census/context.h"
#include <string.h> #include <string.h>
#include <grpc/census.h> #include <grpc/census.h>

@ -157,7 +157,7 @@ static void handle_op_after_cancellation(grpc_call_element *elem,
channel_data *chand = elem->channel_data; channel_data *chand = elem->channel_data;
if (op->send_ops) { if (op->send_ops) {
grpc_stream_ops_unref_owned_objects(op->send_ops->ops, op->send_ops->nops); grpc_stream_ops_unref_owned_objects(op->send_ops->ops, op->send_ops->nops);
op->on_done_send(op->send_user_data, 0); op->on_done_send->cb(op->on_done_send->cb_arg, 0);
} }
if (op->recv_ops) { if (op->recv_ops) {
char status[GPR_LTOA_MIN_BUFSIZE]; char status[GPR_LTOA_MIN_BUFSIZE];
@ -176,10 +176,10 @@ static void handle_op_after_cancellation(grpc_call_element *elem,
mdb.deadline = gpr_inf_future; mdb.deadline = gpr_inf_future;
grpc_sopb_add_metadata(op->recv_ops, mdb); grpc_sopb_add_metadata(op->recv_ops, mdb);
*op->recv_state = GRPC_STREAM_CLOSED; *op->recv_state = GRPC_STREAM_CLOSED;
op->on_done_recv(op->recv_user_data, 1); op->on_done_recv->cb(op->on_done_recv->cb_arg, 1);
} }
if (op->on_consumed) { if (op->on_consumed) {
op->on_consumed(op->on_consumed_user_data, 0); op->on_consumed->cb(op->on_consumed->cb_arg, 0);
} }
} }
@ -266,17 +266,15 @@ static void cc_start_transport_op(grpc_call_element *elem,
calld->s.waiting_op.send_ops = op->send_ops; calld->s.waiting_op.send_ops = op->send_ops;
calld->s.waiting_op.is_last_send = op->is_last_send; calld->s.waiting_op.is_last_send = op->is_last_send;
calld->s.waiting_op.on_done_send = op->on_done_send; calld->s.waiting_op.on_done_send = op->on_done_send;
calld->s.waiting_op.send_user_data = op->send_user_data;
} }
if (op->recv_ops) { if (op->recv_ops) {
calld->s.waiting_op.recv_ops = op->recv_ops; calld->s.waiting_op.recv_ops = op->recv_ops;
calld->s.waiting_op.recv_state = op->recv_state; calld->s.waiting_op.recv_state = op->recv_state;
calld->s.waiting_op.on_done_recv = op->on_done_recv; calld->s.waiting_op.on_done_recv = op->on_done_recv;
calld->s.waiting_op.recv_user_data = op->recv_user_data;
} }
gpr_mu_unlock(&chand->mu); gpr_mu_unlock(&chand->mu);
if (op->on_consumed) { if (op->on_consumed) {
op->on_consumed(op->on_consumed_user_data, 0); op->on_consumed->cb(op->on_consumed->cb_arg, 0);
} }
} }
break; break;

@ -43,8 +43,13 @@ typedef struct call_data {
int got_initial_metadata; int got_initial_metadata;
grpc_stream_op_buffer *recv_ops; grpc_stream_op_buffer *recv_ops;
void (*on_done_recv)(void *user_data, int success);
void *recv_user_data; /** Closure to call when finished with the hc_on_recv hook */
grpc_iomgr_closure *on_done_recv;
/** Receive closures are chained: we inject this closure as the on_done_recv
up-call on transport_op, and remember to call our on_done_recv member
after handling it. */
grpc_iomgr_closure hc_on_recv;
} call_data; } call_data;
typedef struct channel_data { typedef struct channel_data {
@ -84,7 +89,7 @@ static void hc_on_recv(void *user_data, int success) {
grpc_metadata_batch_filter(&op->data.metadata, client_filter, elem); grpc_metadata_batch_filter(&op->data.metadata, client_filter, elem);
} }
} }
calld->on_done_recv(calld->recv_user_data, success); calld->on_done_recv->cb(calld->on_done_recv->cb_arg, success);
} }
static void hc_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { static void hc_mutate_op(grpc_call_element *elem, grpc_transport_op *op) {
@ -117,9 +122,7 @@ static void hc_mutate_op(grpc_call_element *elem, grpc_transport_op *op) {
/* substitute our callback for the higher callback */ /* substitute our callback for the higher callback */
calld->recv_ops = op->recv_ops; calld->recv_ops = op->recv_ops;
calld->on_done_recv = op->on_done_recv; calld->on_done_recv = op->on_done_recv;
calld->recv_user_data = op->recv_user_data; op->on_done_recv = &calld->hc_on_recv;
op->on_done_recv = hc_on_recv;
op->recv_user_data = elem;
} }
} }
@ -154,6 +157,8 @@ static void init_call_elem(grpc_call_element *elem,
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
calld->sent_initial_metadata = 0; calld->sent_initial_metadata = 0;
calld->got_initial_metadata = 0; calld->got_initial_metadata = 0;
calld->on_done_recv = NULL;
grpc_iomgr_closure_init(&calld->hc_on_recv, hc_on_recv, elem);
if (initial_op) hc_mutate_op(elem, initial_op); if (initial_op) hc_mutate_op(elem, initial_op);
} }

@ -47,8 +47,12 @@ typedef struct call_data {
grpc_linked_mdelem status; grpc_linked_mdelem status;
grpc_stream_op_buffer *recv_ops; grpc_stream_op_buffer *recv_ops;
void (*on_done_recv)(void *user_data, int success); /** Closure to call when finished with the hs_on_recv hook */
void *recv_user_data; grpc_iomgr_closure *on_done_recv;
/** Receive closures are chained: we inject this closure as the on_done_recv
up-call on transport_op, and remember to call our on_done_recv member
after handling it. */
grpc_iomgr_closure hs_on_recv;
} call_data; } call_data;
typedef struct channel_data { typedef struct channel_data {
@ -174,7 +178,7 @@ static void hs_on_recv(void *user_data, int success) {
} }
} }
} }
calld->on_done_recv(calld->recv_user_data, success); calld->on_done_recv->cb(calld->on_done_recv->cb_arg, success);
} }
static void hs_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { static void hs_mutate_op(grpc_call_element *elem, grpc_transport_op *op) {
@ -200,9 +204,7 @@ static void hs_mutate_op(grpc_call_element *elem, grpc_transport_op *op) {
/* substitute our callback for the higher callback */ /* substitute our callback for the higher callback */
calld->recv_ops = op->recv_ops; calld->recv_ops = op->recv_ops;
calld->on_done_recv = op->on_done_recv; calld->on_done_recv = op->on_done_recv;
calld->recv_user_data = op->recv_user_data; op->on_done_recv = &calld->hs_on_recv;
op->on_done_recv = hs_on_recv;
op->recv_user_data = elem;
} }
} }
@ -238,6 +240,7 @@ static void init_call_elem(grpc_call_element *elem,
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
/* initialize members */ /* initialize members */
memset(calld, 0, sizeof(*calld)); memset(calld, 0, sizeof(*calld));
grpc_iomgr_closure_init(&calld->hs_on_recv, hs_on_recv, elem);
if (initial_op) hs_mutate_op(elem, initial_op); if (initial_op) hs_mutate_op(elem, initial_op);
} }

@ -73,4 +73,8 @@ void grpc_iomgr_shutdown(void);
* Can be called from within a callback or from anywhere else */ * Can be called from within a callback or from anywhere else */
void grpc_iomgr_add_callback(grpc_iomgr_closure *closure); void grpc_iomgr_add_callback(grpc_iomgr_closure *closure);
/** As per grpc_iomgr_add_callback, with the ability to set the success
argument. */
void grpc_iomgr_add_delayed_callback(grpc_iomgr_closure *iocb, int success);
#endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_H */ #endif /* GRPC_INTERNAL_CORE_IOMGR_IOMGR_H */

@ -39,6 +39,7 @@
#include "src/core/iomgr/alarm_internal.h" #include "src/core/iomgr/alarm_internal.h"
#include "src/core/iomgr/iomgr_internal.h" #include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/pollset.h"
#include "src/core/iomgr/pollset_windows.h" #include "src/core/iomgr/pollset_windows.h"
/* There isn't really any such thing as a pollset under Windows, due to the /* There isn't really any such thing as a pollset under Windows, due to the
@ -47,6 +48,7 @@
won't actually do any polling, and return as quickly as possible. */ won't actually do any polling, and return as quickly as possible. */
void grpc_pollset_init(grpc_pollset *pollset) { void grpc_pollset_init(grpc_pollset *pollset) {
memset(pollset, 0, sizeof(*pollset));
gpr_mu_init(&pollset->mu); gpr_mu_init(&pollset->mu);
gpr_cv_init(&pollset->cv); gpr_cv_init(&pollset->cv);
} }
@ -54,6 +56,10 @@ void grpc_pollset_init(grpc_pollset *pollset) {
void grpc_pollset_shutdown(grpc_pollset *pollset, void grpc_pollset_shutdown(grpc_pollset *pollset,
void (*shutdown_done)(void *arg), void (*shutdown_done)(void *arg),
void *shutdown_done_arg) { void *shutdown_done_arg) {
gpr_mu_lock(&pollset->mu);
pollset->shutting_down = 1;
gpr_cv_broadcast(&pollset->cv);
gpr_mu_unlock(&pollset->mu);
shutdown_done(shutdown_done_arg); shutdown_done(shutdown_done_arg);
} }
@ -68,13 +74,15 @@ int grpc_pollset_work(grpc_pollset *pollset, gpr_timespec deadline) {
if (gpr_time_cmp(now, deadline) > 0) { if (gpr_time_cmp(now, deadline) > 0) {
return 0 /* GPR_FALSE */; return 0 /* GPR_FALSE */;
} }
if (grpc_maybe_call_delayed_callbacks(NULL, 1 /* GPR_TRUE */)) { if (grpc_maybe_call_delayed_callbacks(&pollset->mu, 1 /* GPR_TRUE */)) {
return 1 /* GPR_TRUE */; return 1 /* GPR_TRUE */;
} }
if (grpc_alarm_check(NULL, now, &deadline)) { if (grpc_alarm_check(&pollset->mu, now, &deadline)) {
return 1 /* GPR_TRUE */; return 1 /* GPR_TRUE */;
} }
if (!pollset->shutting_down) {
gpr_cv_wait(&pollset->cv, &pollset->mu, deadline); gpr_cv_wait(&pollset->cv, &pollset->mu, deadline);
}
return 1 /* GPR_TRUE */; return 1 /* GPR_TRUE */;
} }

@ -46,6 +46,7 @@
typedef struct grpc_pollset { typedef struct grpc_pollset {
gpr_mu mu; gpr_mu mu;
gpr_cv cv; gpr_cv cv;
int shutting_down;
} grpc_pollset; } grpc_pollset;
#define GRPC_POLLSET_MU(pollset) (&(pollset)->mu) #define GRPC_POLLSET_MU(pollset) (&(pollset)->mu)

@ -164,7 +164,9 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) {
size_t lower_idx; size_t lower_idx;
size_t upper_idx; size_t upper_idx;
GPR_ASSERT(h->count >= 1); if (h->count == 0) {
return 0.0;
}
if (count_below <= 0) { if (count_below <= 0) {
return h->min_seen; return h->min_seen;

@ -190,3 +190,19 @@ void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b) {
GPR_SWAP(gpr_slice *, a->slices, b->slices); GPR_SWAP(gpr_slice *, a->slices, b->slices);
} }
} }
void gpr_slice_buffer_move_into(gpr_slice_buffer *src, gpr_slice_buffer *dst) {
/* anything to move? */
if (src->count == 0) {
return;
}
/* anything in dst? */
if (dst->count == 0) {
gpr_slice_buffer_swap(src, dst);
return;
}
/* both buffers have data - copy, and reset src */
gpr_slice_buffer_addn(dst, src->slices, src->count);
src->count = 0;
src->length = 0;
}

@ -150,12 +150,17 @@ struct grpc_call {
gpr_uint8 receiving; gpr_uint8 receiving;
/* are we currently completing requests */ /* are we currently completing requests */
gpr_uint8 completing; gpr_uint8 completing;
/** has grpc_call_destroy been called */
gpr_uint8 destroy_called;
/* pairs with completed_requests */ /* pairs with completed_requests */
gpr_uint8 num_completed_requests; gpr_uint8 num_completed_requests;
/* are we currently reading a message? */ /* are we currently reading a message? */
gpr_uint8 reading_message; gpr_uint8 reading_message;
/* have we bound a pollset yet? */ /* have we bound a pollset yet? */
gpr_uint8 bound_pollset; gpr_uint8 bound_pollset;
/* is an error status set */
gpr_uint8 error_status_set;
/* flags with bits corresponding to write states allowing us to determine /* flags with bits corresponding to write states allowing us to determine
what was sent */ what was sent */
gpr_uint16 last_send_contains; gpr_uint16 last_send_contains;
@ -214,7 +219,7 @@ struct grpc_call {
/* Received call statuses from various sources */ /* Received call statuses from various sources */
received_status status[STATUS_SOURCE_COUNT]; received_status status[STATUS_SOURCE_COUNT];
/** Compression level for the call */ /* Compression level for the call */
grpc_compression_level compression_level; grpc_compression_level compression_level;
/* Contexts for various subsystems (security, tracing, ...). */ /* Contexts for various subsystems (security, tracing, ...). */
@ -240,6 +245,9 @@ struct grpc_call {
gpr_uint32 incoming_message_length; gpr_uint32 incoming_message_length;
gpr_uint32 incoming_message_flags; gpr_uint32 incoming_message_flags;
grpc_iomgr_closure destroy_closure; grpc_iomgr_closure destroy_closure;
grpc_iomgr_closure on_done_recv;
grpc_iomgr_closure on_done_send;
grpc_iomgr_closure on_done_bind;
}; };
#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) #define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1))
@ -258,6 +266,7 @@ static void recv_metadata(grpc_call *call, grpc_metadata_batch *metadata);
static void finish_read_ops(grpc_call *call); static void finish_read_ops(grpc_call *call);
static grpc_call_error cancel_with_status(grpc_call *c, grpc_status_code status, static grpc_call_error cancel_with_status(grpc_call *c, grpc_status_code status,
const char *description); const char *description);
static void finished_loose_op(void *call, int success);
static void lock(grpc_call *call); static void lock(grpc_call *call);
static void unlock(grpc_call *call); static void unlock(grpc_call *call);
@ -301,16 +310,18 @@ grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq,
grpc_sopb_init(&call->send_ops); grpc_sopb_init(&call->send_ops);
grpc_sopb_init(&call->recv_ops); grpc_sopb_init(&call->recv_ops);
gpr_slice_buffer_init(&call->incoming_message); gpr_slice_buffer_init(&call->incoming_message);
/* dropped in destroy */ grpc_iomgr_closure_init(&call->on_done_recv, call_on_done_recv, call);
gpr_ref_init(&call->internal_refcount, 1); grpc_iomgr_closure_init(&call->on_done_send, call_on_done_send, call);
grpc_iomgr_closure_init(&call->on_done_bind, finished_loose_op, call);
/* dropped in destroy and when READ_STATE_STREAM_CLOSED received */
gpr_ref_init(&call->internal_refcount, 2);
/* server hack: start reads immediately so we can get initial metadata. /* server hack: start reads immediately so we can get initial metadata.
TODO(ctiller): figure out a cleaner solution */ TODO(ctiller): figure out a cleaner solution */
if (!call->is_client) { if (!call->is_client) {
memset(&initial_op, 0, sizeof(initial_op)); memset(&initial_op, 0, sizeof(initial_op));
initial_op.recv_ops = &call->recv_ops; initial_op.recv_ops = &call->recv_ops;
initial_op.recv_state = &call->recv_state; initial_op.recv_state = &call->recv_state;
initial_op.on_done_recv = call_on_done_recv; initial_op.on_done_recv = &call->on_done_recv;
initial_op.recv_user_data = call;
initial_op.context = call->context; initial_op.context = call->context;
call->receiving = 1; call->receiving = 1;
GRPC_CALL_INTERNAL_REF(call, "receiving"); GRPC_CALL_INTERNAL_REF(call, "receiving");
@ -409,6 +420,7 @@ static void set_status_code(grpc_call *call, status_source source,
call->status[source].is_set = 1; call->status[source].is_set = 1;
call->status[source].code = status; call->status[source].code = status;
call->error_status_set = status != GRPC_STATUS_OK;
if (status != GRPC_STATUS_OK && !grpc_bbq_empty(&call->incoming_queue)) { if (status != GRPC_STATUS_OK && !grpc_bbq_empty(&call->incoming_queue)) {
grpc_bbq_flush(&call->incoming_queue); grpc_bbq_flush(&call->incoming_queue);
@ -450,7 +462,8 @@ static int need_more_data(grpc_call *call) {
(is_op_live(call, GRPC_IOREQ_RECV_CLOSE) && (is_op_live(call, GRPC_IOREQ_RECV_CLOSE) &&
grpc_bbq_empty(&call->incoming_queue)) || grpc_bbq_empty(&call->incoming_queue)) ||
(call->write_state == WRITE_STATE_INITIAL && !call->is_client) || (call->write_state == WRITE_STATE_INITIAL && !call->is_client) ||
(call->cancel_with_status != GRPC_STATUS_OK); (call->cancel_with_status != GRPC_STATUS_OK) ||
call->destroy_called;
} }
static void unlock(grpc_call *call) { static void unlock(grpc_call *call) {
@ -469,8 +482,7 @@ static void unlock(grpc_call *call) {
if (!call->receiving && need_more_data(call)) { if (!call->receiving && need_more_data(call)) {
op.recv_ops = &call->recv_ops; op.recv_ops = &call->recv_ops;
op.recv_state = &call->recv_state; op.recv_state = &call->recv_state;
op.on_done_recv = call_on_done_recv; op.on_done_recv = &call->on_done_recv;
op.recv_user_data = call;
call->receiving = 1; call->receiving = 1;
GRPC_CALL_INTERNAL_REF(call, "receiving"); GRPC_CALL_INTERNAL_REF(call, "receiving");
start_op = 1; start_op = 1;
@ -686,13 +698,13 @@ static void call_on_done_send(void *pc, int success) {
} }
static void finish_message(grpc_call *call) { static void finish_message(grpc_call *call) {
if (call->error_status_set == 0) {
/* TODO(ctiller): this could be a lot faster if coded directly */ /* TODO(ctiller): this could be a lot faster if coded directly */
grpc_byte_buffer *byte_buffer = grpc_raw_byte_buffer_create( grpc_byte_buffer *byte_buffer = grpc_raw_byte_buffer_create(
call->incoming_message.slices, call->incoming_message.count); call->incoming_message.slices, call->incoming_message.count);
gpr_slice_buffer_reset_and_unref(&call->incoming_message);
grpc_bbq_push(&call->incoming_queue, byte_buffer); grpc_bbq_push(&call->incoming_queue, byte_buffer);
}
gpr_slice_buffer_reset_and_unref(&call->incoming_message);
GPR_ASSERT(call->incoming_message.count == 0); GPR_ASSERT(call->incoming_message.count == 0);
call->reading_message = 0; call->reading_message = 0;
} }
@ -797,6 +809,7 @@ static void call_on_done_recv(void *pc, int success) {
grpc_alarm_cancel(&call->alarm); grpc_alarm_cancel(&call->alarm);
call->have_alarm = 0; call->have_alarm = 0;
} }
GRPC_CALL_INTERNAL_UNREF(call, "closed", 0);
} }
finish_read_ops(call); finish_read_ops(call);
} else { } else {
@ -940,8 +953,7 @@ static int fill_send_ops(grpc_call *call, grpc_transport_op *op) {
break; break;
} }
if (op->send_ops) { if (op->send_ops) {
op->on_done_send = call_on_done_send; op->on_done_send = &call->on_done_send;
op->send_user_data = call;
} }
return op->send_ops != NULL; return op->send_ops != NULL;
} }
@ -1071,6 +1083,8 @@ grpc_call_error grpc_call_start_ioreq_and_call_back(
void grpc_call_destroy(grpc_call *c) { void grpc_call_destroy(grpc_call *c) {
int cancel; int cancel;
lock(c); lock(c);
GPR_ASSERT(!c->destroy_called);
c->destroy_called = 1;
if (c->have_alarm) { if (c->have_alarm) {
grpc_alarm_cancel(&c->alarm); grpc_alarm_cancel(&c->alarm);
c->have_alarm = 0; c->have_alarm = 0;
@ -1115,14 +1129,31 @@ static void finished_loose_op(void *call, int success_ignored) {
GRPC_CALL_INTERNAL_UNREF(call, "loose-op", 0); GRPC_CALL_INTERNAL_UNREF(call, "loose-op", 0);
} }
typedef struct {
grpc_call *call;
grpc_iomgr_closure closure;
} finished_loose_op_allocated_args;
static void finished_loose_op_allocated(void *alloc, int success) {
finished_loose_op_allocated_args *args = alloc;
finished_loose_op(args->call, success);
gpr_free(args);
}
static void execute_op(grpc_call *call, grpc_transport_op *op) { static void execute_op(grpc_call *call, grpc_transport_op *op) {
grpc_call_element *elem; grpc_call_element *elem;
GPR_ASSERT(op->on_consumed == NULL); GPR_ASSERT(op->on_consumed == NULL);
if (op->cancel_with_status != GRPC_STATUS_OK || op->bind_pollset) { if (op->cancel_with_status != GRPC_STATUS_OK || op->bind_pollset) {
GRPC_CALL_INTERNAL_REF(call, "loose-op"); GRPC_CALL_INTERNAL_REF(call, "loose-op");
op->on_consumed = finished_loose_op; if (op->bind_pollset) {
op->on_consumed_user_data = call; op->on_consumed = &call->on_done_bind;
} else {
finished_loose_op_allocated_args *args = gpr_malloc(sizeof(*args));
args->call = call;
grpc_iomgr_closure_init(&args->closure, finished_loose_op_allocated, args);
op->on_consumed = &args->closure;
}
} }
elem = CALL_ELEM_FROM_CALL(call, 0); elem = CALL_ELEM_FROM_CALL(call, 0);

@ -88,9 +88,11 @@ grpc_completion_queue *grpc_completion_queue_create(void) {
} }
#ifdef GRPC_CQ_REF_COUNT_DEBUG #ifdef GRPC_CQ_REF_COUNT_DEBUG
void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason) { void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason,
gpr_log(GPR_DEBUG, "CQ:%p ref %d -> %d %s", cc, (int)cc->owning_refs.count, const char *file, int line) {
(int)cc->owning_refs.count + 1, reason); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "CQ:%p ref %d -> %d %s",
cc, (int)cc->owning_refs.count, (int)cc->owning_refs.count + 1,
reason);
#else #else
void grpc_cq_internal_ref(grpc_completion_queue *cc) { void grpc_cq_internal_ref(grpc_completion_queue *cc) {
#endif #endif
@ -103,9 +105,11 @@ static void on_pollset_destroy_done(void *arg) {
} }
#ifdef GRPC_CQ_REF_COUNT_DEBUG #ifdef GRPC_CQ_REF_COUNT_DEBUG
void grpc_cq_internal_unref(grpc_completion_queue *cc, const char *reason) { void grpc_cq_internal_unref(grpc_completion_queue *cc, const char *reason,
gpr_log(GPR_DEBUG, "CQ:%p unref %d -> %d %s", cc, (int)cc->owning_refs.count, const char *file, int line) {
(int)cc->owning_refs.count - 1, reason); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "CQ:%p unref %d -> %d %s",
cc, (int)cc->owning_refs.count, (int)cc->owning_refs.count - 1,
reason);
#else #else
void grpc_cq_internal_unref(grpc_completion_queue *cc) { void grpc_cq_internal_unref(grpc_completion_queue *cc) {
#endif #endif

@ -40,10 +40,14 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#ifdef GRPC_CQ_REF_COUNT_DEBUG #ifdef GRPC_CQ_REF_COUNT_DEBUG
void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason); void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason,
void grpc_cq_internal_unref(grpc_completion_queue *cc, const char *reason); const char *file, int line);
#define GRPC_CQ_INTERNAL_REF(cc, reason) grpc_cq_internal_ref(cc, reason) void grpc_cq_internal_unref(grpc_completion_queue *cc, const char *reason,
#define GRPC_CQ_INTERNAL_UNREF(cc, reason) grpc_cq_internal_unref(cc, reason) const char *file, int line);
#define GRPC_CQ_INTERNAL_REF(cc, reason) \
grpc_cq_internal_ref(cc, reason, __FILE__, __LINE__)
#define GRPC_CQ_INTERNAL_UNREF(cc, reason) \
grpc_cq_internal_unref(cc, reason, __FILE__, __LINE__)
#else #else
void grpc_cq_internal_ref(grpc_completion_queue *cc); void grpc_cq_internal_ref(grpc_completion_queue *cc);
void grpc_cq_internal_unref(grpc_completion_queue *cc); void grpc_cq_internal_unref(grpc_completion_queue *cc);

@ -56,7 +56,7 @@ static void lame_start_transport_op(grpc_call_element *elem,
GRPC_CALL_LOG_OP(GPR_INFO, elem, op); GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
if (op->send_ops) { if (op->send_ops) {
grpc_stream_ops_unref_owned_objects(op->send_ops->ops, op->send_ops->nops); grpc_stream_ops_unref_owned_objects(op->send_ops->ops, op->send_ops->nops);
op->on_done_send(op->send_user_data, 0); op->on_done_send->cb(op->on_done_send->cb_arg, 0);
} }
if (op->recv_ops) { if (op->recv_ops) {
char tmp[GPR_LTOA_MIN_BUFSIZE]; char tmp[GPR_LTOA_MIN_BUFSIZE];
@ -75,10 +75,10 @@ static void lame_start_transport_op(grpc_call_element *elem,
mdb.deadline = gpr_inf_future; mdb.deadline = gpr_inf_future;
grpc_sopb_add_metadata(op->recv_ops, mdb); grpc_sopb_add_metadata(op->recv_ops, mdb);
*op->recv_state = GRPC_STREAM_CLOSED; *op->recv_state = GRPC_STREAM_CLOSED;
op->on_done_recv(op->recv_user_data, 1); op->on_done_recv->cb(op->on_done_recv->cb_arg, 1);
} }
if (op->on_consumed) { if (op->on_consumed) {
op->on_consumed(op->on_consumed_user_data, 0); op->on_consumed->cb(op->on_consumed->cb_arg, 0);
} }
} }

@ -191,9 +191,9 @@ struct call_data {
grpc_stream_op_buffer *recv_ops; grpc_stream_op_buffer *recv_ops;
grpc_stream_state *recv_state; grpc_stream_state *recv_state;
void (*on_done_recv)(void *user_data, int success); grpc_iomgr_closure *on_done_recv;
void *recv_user_data;
grpc_iomgr_closure server_on_recv;
grpc_iomgr_closure kill_zombie_closure; grpc_iomgr_closure kill_zombie_closure;
call_data **root[CALL_LIST_COUNT]; call_data **root[CALL_LIST_COUNT];
@ -523,7 +523,7 @@ static void server_on_recv(void *ptr, int success) {
break; break;
} }
calld->on_done_recv(calld->recv_user_data, success); calld->on_done_recv->cb(calld->on_done_recv->cb_arg, success);
} }
static void server_mutate_op(grpc_call_element *elem, grpc_transport_op *op) { static void server_mutate_op(grpc_call_element *elem, grpc_transport_op *op) {
@ -534,9 +534,7 @@ static void server_mutate_op(grpc_call_element *elem, grpc_transport_op *op) {
calld->recv_ops = op->recv_ops; calld->recv_ops = op->recv_ops;
calld->recv_state = op->recv_state; calld->recv_state = op->recv_state;
calld->on_done_recv = op->on_done_recv; calld->on_done_recv = op->on_done_recv;
calld->recv_user_data = op->recv_user_data; op->on_done_recv = &calld->server_on_recv;
op->on_done_recv = server_on_recv;
op->recv_user_data = elem;
} }
} }
@ -632,6 +630,8 @@ static void init_call_elem(grpc_call_element *elem,
calld->deadline = gpr_inf_future; calld->deadline = gpr_inf_future;
calld->call = grpc_call_from_top_element(elem); calld->call = grpc_call_from_top_element(elem);
grpc_iomgr_closure_init(&calld->server_on_recv, server_on_recv, elem);
gpr_mu_lock(&chand->server->mu_call); gpr_mu_lock(&chand->server->mu_call);
call_list_join(&chand->server->lists[ALL_CALLS], calld, ALL_CALLS); call_list_join(&chand->server->lists[ALL_CALLS], calld, ALL_CALLS);
gpr_mu_unlock(&chand->server->mu_call); gpr_mu_unlock(&chand->server->mu_call);

@ -46,70 +46,18 @@ typedef struct {
gpr_uint8 length; gpr_uint8 length;
} b64_huff_sym; } b64_huff_sym;
static const b64_huff_sym huff_alphabet[64] = {{0x21, 6}, static const b64_huff_sym huff_alphabet[64] = {
{0x5d, 7}, {0x21, 6}, {0x5d, 7}, {0x5e, 7}, {0x5f, 7}, {0x60, 7}, {0x61, 7},
{0x5e, 7}, {0x62, 7}, {0x63, 7}, {0x64, 7}, {0x65, 7}, {0x66, 7}, {0x67, 7},
{0x5f, 7}, {0x68, 7}, {0x69, 7}, {0x6a, 7}, {0x6b, 7}, {0x6c, 7}, {0x6d, 7},
{0x60, 7}, {0x6e, 7}, {0x6f, 7}, {0x70, 7}, {0x71, 7}, {0x72, 7}, {0xfc, 8},
{0x61, 7}, {0x73, 7}, {0xfd, 8}, {0x3, 5}, {0x23, 6}, {0x4, 5}, {0x24, 6},
{0x62, 7}, {0x5, 5}, {0x25, 6}, {0x26, 6}, {0x27, 6}, {0x6, 5}, {0x74, 7},
{0x63, 7}, {0x75, 7}, {0x28, 6}, {0x29, 6}, {0x2a, 6}, {0x7, 5}, {0x2b, 6},
{0x64, 7}, {0x76, 7}, {0x2c, 6}, {0x8, 5}, {0x9, 5}, {0x2d, 6}, {0x77, 7},
{0x65, 7}, {0x78, 7}, {0x79, 7}, {0x7a, 7}, {0x7b, 7}, {0x0, 5}, {0x1, 5},
{0x66, 7}, {0x2, 5}, {0x19, 6}, {0x1a, 6}, {0x1b, 6}, {0x1c, 6}, {0x1d, 6},
{0x67, 7}, {0x1e, 6}, {0x1f, 6}, {0x7fb, 11}, {0x18, 6}};
{0x68, 7},
{0x69, 7},
{0x6a, 7},
{0x6b, 7},
{0x6c, 7},
{0x6d, 7},
{0x6e, 7},
{0x6f, 7},
{0x70, 7},
{0x71, 7},
{0x72, 7},
{0xfc, 8},
{0x73, 7},
{0xfd, 8},
{0x3, 5},
{0x23, 6},
{0x4, 5},
{0x24, 6},
{0x5, 5},
{0x25, 6},
{0x26, 6},
{0x27, 6},
{0x6, 5},
{0x74, 7},
{0x75, 7},
{0x28, 6},
{0x29, 6},
{0x2a, 6},
{0x7, 5},
{0x2b, 6},
{0x76, 7},
{0x2c, 6},
{0x8, 5},
{0x9, 5},
{0x2d, 6},
{0x77, 7},
{0x78, 7},
{0x79, 7},
{0x7a, 7},
{0x7b, 7},
{0x0, 5},
{0x1, 5},
{0x2, 5},
{0x19, 6},
{0x1a, 6},
{0x1b, 6},
{0x1c, 6},
{0x1d, 6},
{0x1e, 6},
{0x1f, 6},
{0x7fb, 11},
{0x18, 6}};
static const gpr_uint8 tail_xtra[3] = {0, 2, 3}; static const gpr_uint8 tail_xtra[3] = {0, 2, 3};

@ -45,23 +45,9 @@ typedef enum {
GRPC_CHTTP2_CONNECTION_ERROR GRPC_CHTTP2_CONNECTION_ERROR
} grpc_chttp2_parse_error; } grpc_chttp2_parse_error;
typedef struct { /* defined in internal.h */
gpr_uint8 end_of_stream; typedef struct grpc_chttp2_stream_parsing grpc_chttp2_stream_parsing;
gpr_uint8 need_flush_reads; typedef struct grpc_chttp2_transport_parsing grpc_chttp2_transport_parsing;
gpr_uint8 metadata_boundary;
gpr_uint8 ack_settings;
gpr_uint8 send_ping_ack;
gpr_uint8 process_ping_reply;
gpr_uint8 goaway;
gpr_uint8 rst_stream;
gpr_int64 initial_window_update;
gpr_uint32 window_update;
gpr_uint32 goaway_last_stream_index;
gpr_uint32 goaway_error;
gpr_slice goaway_text;
gpr_uint32 rst_stream_reason;
} grpc_chttp2_parse_state;
#define GRPC_CHTTP2_FRAME_DATA 0 #define GRPC_CHTTP2_FRAME_DATA 0
#define GRPC_CHTTP2_FRAME_HEADER 1 #define GRPC_CHTTP2_FRAME_HEADER 1

@ -35,6 +35,7 @@
#include <string.h> #include <string.h>
#include "src/core/transport/chttp2/internal.h"
#include "src/core/support/string.h" #include "src/core/support/string.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -69,16 +70,15 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
} }
grpc_chttp2_parse_error grpc_chttp2_data_parser_parse( grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, void *parser, grpc_chttp2_transport_parsing *transport_parsing,
int is_last) { grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice); gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
gpr_uint8 *const end = GPR_SLICE_END_PTR(slice); gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
gpr_uint8 *cur = beg; gpr_uint8 *cur = beg;
grpc_chttp2_data_parser *p = parser; grpc_chttp2_data_parser *p = parser;
if (is_last && p->is_last_frame) { if (is_last && p->is_last_frame) {
state->end_of_stream = 1; stream_parsing->received_close = 1;
state->need_flush_reads = 1;
} }
if (cur == end) { if (cur == end) {
@ -105,51 +105,52 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
} }
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_DATA_FH_1: case GRPC_CHTTP2_DATA_FH_1:
p->frame_size = ((gpr_uint32) * cur) << 24; p->frame_size = ((gpr_uint32)*cur) << 24;
if (++cur == end) { if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_2; p->state = GRPC_CHTTP2_DATA_FH_2;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_DATA_FH_2: case GRPC_CHTTP2_DATA_FH_2:
p->frame_size |= ((gpr_uint32) * cur) << 16; p->frame_size |= ((gpr_uint32)*cur) << 16;
if (++cur == end) { if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_3; p->state = GRPC_CHTTP2_DATA_FH_3;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_DATA_FH_3: case GRPC_CHTTP2_DATA_FH_3:
p->frame_size |= ((gpr_uint32) * cur) << 8; p->frame_size |= ((gpr_uint32)*cur) << 8;
if (++cur == end) { if (++cur == end) {
p->state = GRPC_CHTTP2_DATA_FH_4; p->state = GRPC_CHTTP2_DATA_FH_4;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_DATA_FH_4: case GRPC_CHTTP2_DATA_FH_4:
p->frame_size |= ((gpr_uint32) * cur); p->frame_size |= ((gpr_uint32)*cur);
p->state = GRPC_CHTTP2_DATA_FRAME; p->state = GRPC_CHTTP2_DATA_FRAME;
++cur; ++cur;
state->need_flush_reads = 1;
grpc_sopb_add_begin_message(&p->incoming_sopb, p->frame_size, 0); grpc_sopb_add_begin_message(&p->incoming_sopb, p->frame_size, 0);
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_DATA_FRAME: case GRPC_CHTTP2_DATA_FRAME:
if (cur == end) { if (cur == end) {
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} else if ((gpr_uint32)(end - cur) == p->frame_size) { }
state->need_flush_reads = 1; grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
if ((gpr_uint32)(end - cur) == p->frame_size) {
grpc_sopb_add_slice(&p->incoming_sopb, grpc_sopb_add_slice(&p->incoming_sopb,
gpr_slice_sub(slice, cur - beg, end - beg)); gpr_slice_sub(slice, cur - beg, end - beg));
p->state = GRPC_CHTTP2_DATA_FH_0; p->state = GRPC_CHTTP2_DATA_FH_0;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} else if ((gpr_uint32)(end - cur) > p->frame_size) { } else if ((gpr_uint32)(end - cur) > p->frame_size) {
state->need_flush_reads = 1;
grpc_sopb_add_slice( grpc_sopb_add_slice(
&p->incoming_sopb, &p->incoming_sopb,
gpr_slice_sub(slice, cur - beg, cur + p->frame_size - beg)); gpr_slice_sub(slice, cur - beg, cur + p->frame_size - beg));
cur += p->frame_size; cur += p->frame_size;
goto fh_0; /* loop */ goto fh_0; /* loop */
} else { } else {
state->need_flush_reads = 1;
grpc_sopb_add_slice(&p->incoming_sopb, grpc_sopb_add_slice(&p->incoming_sopb,
gpr_slice_sub(slice, cur - beg, end - beg)); gpr_slice_sub(slice, cur - beg, end - beg));
p->frame_size -= (end - cur); p->frame_size -= (end - cur);

@ -72,7 +72,8 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_begin_frame(
/* handle a slice of a data frame - is_last indicates the last slice of a /* handle a slice of a data frame - is_last indicates the last slice of a
frame */ frame */
grpc_chttp2_parse_error grpc_chttp2_data_parser_parse( grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); void *parser, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
/* create a slice with an empty data frame and is_last set */ /* create a slice with an empty data frame and is_last set */
gpr_slice grpc_chttp2_data_frame_create_empty_close(gpr_uint32 id); gpr_slice grpc_chttp2_data_frame_create_empty_close(gpr_uint32 id);

@ -32,6 +32,7 @@
*/ */
#include "src/core/transport/chttp2/frame_goaway.h" #include "src/core/transport/chttp2/frame_goaway.h"
#include "src/core/transport/chttp2/internal.h"
#include <string.h> #include <string.h>
@ -62,8 +63,8 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
} }
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse( grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, void *parser, grpc_chttp2_transport_parsing *transport_parsing,
int is_last) { grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice); gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
gpr_uint8 *const end = GPR_SLICE_END_PTR(slice); gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
gpr_uint8 *cur = beg; gpr_uint8 *cur = beg;
@ -75,7 +76,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI0; p->state = GRPC_CHTTP2_GOAWAY_LSI0;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
p->last_stream_id = ((gpr_uint32) * cur) << 24; p->last_stream_id = ((gpr_uint32)*cur) << 24;
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI1: case GRPC_CHTTP2_GOAWAY_LSI1:
@ -83,7 +84,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI1; p->state = GRPC_CHTTP2_GOAWAY_LSI1;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
p->last_stream_id |= ((gpr_uint32) * cur) << 16; p->last_stream_id |= ((gpr_uint32)*cur) << 16;
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI2: case GRPC_CHTTP2_GOAWAY_LSI2:
@ -91,7 +92,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI2; p->state = GRPC_CHTTP2_GOAWAY_LSI2;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
p->last_stream_id |= ((gpr_uint32) * cur) << 8; p->last_stream_id |= ((gpr_uint32)*cur) << 8;
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_LSI3: case GRPC_CHTTP2_GOAWAY_LSI3:
@ -99,7 +100,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_LSI3; p->state = GRPC_CHTTP2_GOAWAY_LSI3;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
p->last_stream_id |= ((gpr_uint32) * cur); p->last_stream_id |= ((gpr_uint32)*cur);
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR0: case GRPC_CHTTP2_GOAWAY_ERR0:
@ -107,7 +108,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR0; p->state = GRPC_CHTTP2_GOAWAY_ERR0;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
p->error_code = ((gpr_uint32) * cur) << 24; p->error_code = ((gpr_uint32)*cur) << 24;
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR1: case GRPC_CHTTP2_GOAWAY_ERR1:
@ -115,7 +116,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR1; p->state = GRPC_CHTTP2_GOAWAY_ERR1;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
p->error_code |= ((gpr_uint32) * cur) << 16; p->error_code |= ((gpr_uint32)*cur) << 16;
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR2: case GRPC_CHTTP2_GOAWAY_ERR2:
@ -123,7 +124,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR2; p->state = GRPC_CHTTP2_GOAWAY_ERR2;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
p->error_code |= ((gpr_uint32) * cur) << 8; p->error_code |= ((gpr_uint32)*cur) << 8;
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_ERR3: case GRPC_CHTTP2_GOAWAY_ERR3:
@ -131,7 +132,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->state = GRPC_CHTTP2_GOAWAY_ERR3; p->state = GRPC_CHTTP2_GOAWAY_ERR3;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
p->error_code |= ((gpr_uint32) * cur); p->error_code |= ((gpr_uint32)*cur);
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_DEBUG: case GRPC_CHTTP2_GOAWAY_DEBUG:
@ -139,10 +140,11 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
p->debug_pos += end - cur; p->debug_pos += end - cur;
p->state = GRPC_CHTTP2_GOAWAY_DEBUG; p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) { if (is_last) {
state->goaway = 1; transport_parsing->goaway_received = 1;
state->goaway_last_stream_index = p->last_stream_id; transport_parsing->goaway_last_stream_index = p->last_stream_id;
state->goaway_error = p->error_code; gpr_slice_unref(transport_parsing->goaway_text);
state->goaway_text = transport_parsing->goaway_error = p->error_code;
transport_parsing->goaway_text =
gpr_slice_new(p->debug_data, p->debug_length, gpr_free); gpr_slice_new(p->debug_data, p->debug_length, gpr_free);
p->debug_data = NULL; p->debug_data = NULL;
} }

@ -65,7 +65,8 @@ void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser *p);
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame( grpc_chttp2_parse_error grpc_chttp2_goaway_parser_begin_frame(
grpc_chttp2_goaway_parser *parser, gpr_uint32 length, gpr_uint8 flags); grpc_chttp2_goaway_parser *parser, gpr_uint32 length, gpr_uint8 flags);
grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse( grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); void *parser, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code, void grpc_chttp2_goaway_append(gpr_uint32 last_stream_id, gpr_uint32 error_code,
gpr_slice debug_data, gpr_slice debug_data,

@ -32,9 +32,11 @@
*/ */
#include "src/core/transport/chttp2/frame_ping.h" #include "src/core/transport/chttp2/frame_ping.h"
#include "src/core/transport/chttp2/internal.h"
#include <string.h> #include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes) { gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes) {
@ -67,12 +69,13 @@ grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame(
} }
grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse( grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, void *parser, grpc_chttp2_transport_parsing *transport_parsing,
int is_last) { grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice); gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
gpr_uint8 *const end = GPR_SLICE_END_PTR(slice); gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
gpr_uint8 *cur = beg; gpr_uint8 *cur = beg;
grpc_chttp2_ping_parser *p = parser; grpc_chttp2_ping_parser *p = parser;
grpc_chttp2_outstanding_ping *ping;
while (p->byte != 8 && cur != end) { while (p->byte != 8 && cur != end) {
p->opaque_8bytes[p->byte] = *cur; p->opaque_8bytes[p->byte] = *cur;
@ -83,9 +86,18 @@ grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
if (p->byte == 8) { if (p->byte == 8) {
GPR_ASSERT(is_last); GPR_ASSERT(is_last);
if (p->is_ack) { if (p->is_ack) {
state->process_ping_reply = 1; for (ping = transport_parsing->pings.next;
ping != &transport_parsing->pings; ping = ping->next) {
if (0 == memcmp(p->opaque_8bytes, ping->id, 8)) {
grpc_iomgr_add_delayed_callback(ping->on_recv, 1);
}
ping->next->prev = ping->prev;
ping->prev->next = ping->next;
gpr_free(ping);
}
} else { } else {
state->send_ping_ack = 1; gpr_slice_buffer_add(&transport_parsing->qbuf,
grpc_chttp2_ping_create(1, p->opaque_8bytes));
} }
} }

@ -48,6 +48,7 @@ gpr_slice grpc_chttp2_ping_create(gpr_uint8 ack, gpr_uint8 *opaque_8bytes);
grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame( grpc_chttp2_parse_error grpc_chttp2_ping_parser_begin_frame(
grpc_chttp2_ping_parser *parser, gpr_uint32 length, gpr_uint8 flags); grpc_chttp2_ping_parser *parser, gpr_uint32 length, gpr_uint8 flags);
grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse( grpc_chttp2_parse_error grpc_chttp2_ping_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); void *parser, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H */ #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_PING_H */

@ -32,6 +32,7 @@
*/ */
#include "src/core/transport/chttp2/frame_rst_stream.h" #include "src/core/transport/chttp2/frame_rst_stream.h"
#include "src/core/transport/chttp2/internal.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -61,7 +62,8 @@ gpr_slice grpc_chttp2_rst_stream_create(gpr_uint32 id, gpr_uint32 code) {
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
grpc_chttp2_rst_stream_parser *parser, gpr_uint32 length, gpr_uint8 flags) { grpc_chttp2_rst_stream_parser *parser, gpr_uint32 length, gpr_uint8 flags) {
if (length != 4) { if (length != 4) {
gpr_log(GPR_ERROR, "invalid rst_stream: length=%d, flags=%02x", length, flags); gpr_log(GPR_ERROR, "invalid rst_stream: length=%d, flags=%02x", length,
flags);
return GRPC_CHTTP2_CONNECTION_ERROR; return GRPC_CHTTP2_CONNECTION_ERROR;
} }
parser->byte = 0; parser->byte = 0;
@ -69,8 +71,8 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
} }
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse( grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, void *parser, grpc_chttp2_transport_parsing *transport_parsing,
int is_last) { grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice); gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
gpr_uint8 *const end = GPR_SLICE_END_PTR(slice); gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
gpr_uint8 *cur = beg; gpr_uint8 *cur = beg;
@ -84,8 +86,9 @@ grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
if (p->byte == 4) { if (p->byte == 4) {
GPR_ASSERT(is_last); GPR_ASSERT(is_last);
state->rst_stream = 1; stream_parsing->received_close = 1;
state->rst_stream_reason = stream_parsing->saw_rst_stream = 1;
stream_parsing->rst_stream_reason =
(((gpr_uint32)p->reason_bytes[0]) << 24) | (((gpr_uint32)p->reason_bytes[0]) << 24) |
(((gpr_uint32)p->reason_bytes[1]) << 16) | (((gpr_uint32)p->reason_bytes[1]) << 16) |
(((gpr_uint32)p->reason_bytes[2]) << 8) | (((gpr_uint32)p->reason_bytes[2]) << 8) |

@ -47,6 +47,7 @@ gpr_slice grpc_chttp2_rst_stream_create(gpr_uint32 stream_id, gpr_uint32 code);
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_begin_frame(
grpc_chttp2_rst_stream_parser *parser, gpr_uint32 length, gpr_uint8 flags); grpc_chttp2_rst_stream_parser *parser, gpr_uint32 length, gpr_uint8 flags);
grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse( grpc_chttp2_parse_error grpc_chttp2_rst_stream_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); void *parser, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H */ #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_RST_STREAM_H */

@ -32,6 +32,7 @@
*/ */
#include "src/core/transport/chttp2/frame_settings.h" #include "src/core/transport/chttp2/frame_settings.h"
#include "src/core/transport/chttp2/internal.h"
#include <string.h> #include <string.h>
@ -137,7 +138,8 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame(
} }
grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse( grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
void *p, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last) { void *p, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
grpc_chttp2_settings_parser *parser = p; grpc_chttp2_settings_parser *parser = p;
const gpr_uint8 *cur = GPR_SLICE_START_PTR(slice); const gpr_uint8 *cur = GPR_SLICE_START_PTR(slice);
const gpr_uint8 *end = GPR_SLICE_END_PTR(slice); const gpr_uint8 *end = GPR_SLICE_END_PTR(slice);
@ -152,9 +154,11 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
if (cur == end) { if (cur == end) {
parser->state = GRPC_CHTTP2_SPS_ID0; parser->state = GRPC_CHTTP2_SPS_ID0;
if (is_last) { if (is_last) {
transport_parsing->settings_updated = 1;
memcpy(parser->target_settings, parser->incoming_settings, memcpy(parser->target_settings, parser->incoming_settings,
GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32)); GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32));
state->ack_settings = 1; gpr_slice_buffer_add(&transport_parsing->qbuf,
grpc_chttp2_settings_ack_create());
} }
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }
@ -220,15 +224,16 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
} }
if (parser->id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE && if (parser->id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE &&
parser->incoming_settings[parser->id] != parser->value) { parser->incoming_settings[parser->id] != parser->value) {
state->initial_window_update = transport_parsing->initial_window_update =
(gpr_int64)parser->value - (gpr_int64)parser->value -
parser->incoming_settings[parser->id]; parser->incoming_settings[parser->id];
gpr_log(GPR_DEBUG, "adding %d for initial_window change", gpr_log(GPR_DEBUG, "adding %d for initial_window change",
(int)state->initial_window_update); (int)transport_parsing->initial_window_update);
} }
parser->incoming_settings[parser->id] = parser->value; parser->incoming_settings[parser->id] = parser->value;
if (grpc_http_trace) { if (grpc_http_trace) {
gpr_log(GPR_DEBUG, "CHTTP2: got setting %d = %d", parser->id, gpr_log(GPR_DEBUG, "CHTTP2:%s: got setting %d = %d",
transport_parsing->is_client ? "CLI" : "SVR", parser->id,
parser->value); parser->value);
} }
} else { } else {

@ -94,6 +94,7 @@ grpc_chttp2_parse_error grpc_chttp2_settings_parser_begin_frame(
grpc_chttp2_settings_parser *parser, gpr_uint32 length, gpr_uint8 flags, grpc_chttp2_settings_parser *parser, gpr_uint32 length, gpr_uint8 flags,
gpr_uint32 *settings); gpr_uint32 *settings);
grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse( grpc_chttp2_parse_error grpc_chttp2_settings_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); void *parser, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H */ #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_SETTINGS_H */

@ -32,6 +32,7 @@
*/ */
#include "src/core/transport/chttp2/frame_window_update.h" #include "src/core/transport/chttp2/frame_window_update.h"
#include "src/core/transport/chttp2/internal.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -73,15 +74,15 @@ grpc_chttp2_parse_error grpc_chttp2_window_update_parser_begin_frame(
} }
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse( grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, void *parser, grpc_chttp2_transport_parsing *transport_parsing,
int is_last) { grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice); gpr_uint8 *const beg = GPR_SLICE_START_PTR(slice);
gpr_uint8 *const end = GPR_SLICE_END_PTR(slice); gpr_uint8 *const end = GPR_SLICE_END_PTR(slice);
gpr_uint8 *cur = beg; gpr_uint8 *cur = beg;
grpc_chttp2_window_update_parser *p = parser; grpc_chttp2_window_update_parser *p = parser;
while (p->byte != 4 && cur != end) { while (p->byte != 4 && cur != end) {
p->amount |= ((gpr_uint32) * cur) << (8 * (3 - p->byte)); p->amount |= ((gpr_uint32)*cur) << (8 * (3 - p->byte));
cur++; cur++;
p->byte++; p->byte++;
} }
@ -92,7 +93,21 @@ grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
return GRPC_CHTTP2_CONNECTION_ERROR; return GRPC_CHTTP2_CONNECTION_ERROR;
} }
GPR_ASSERT(is_last); GPR_ASSERT(is_last);
state->window_update = p->amount;
if (transport_parsing->incoming_stream_id) {
if (stream_parsing) {
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM("update", transport_parsing,
stream_parsing, outgoing_window_update,
p->amount);
stream_parsing->outgoing_window_update += p->amount;
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
}
} else {
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT("update", transport_parsing,
outgoing_window_update, p->amount);
transport_parsing->outgoing_window_update += p->amount;
}
} }
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;

@ -50,6 +50,7 @@ grpc_chttp2_parse_error grpc_chttp2_window_update_parser_begin_frame(
grpc_chttp2_window_update_parser *parser, gpr_uint32 length, grpc_chttp2_window_update_parser *parser, gpr_uint32 length,
gpr_uint8 flags); gpr_uint8 flags);
grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse( grpc_chttp2_parse_error grpc_chttp2_window_update_parser_parse(
void *parser, grpc_chttp2_parse_state *state, gpr_slice slice, int is_last); void *parser, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H */ #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_FRAME_WINDOW_UPDATE_H */

@ -32,6 +32,7 @@
*/ */
#include "src/core/transport/chttp2/hpack_parser.h" #include "src/core/transport/chttp2/hpack_parser.h"
#include "src/core/transport/chttp2/internal.h"
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
@ -149,10 +150,12 @@ typedef enum {
/* jump table of parse state functions -- order must match first_byte_type /* jump table of parse state functions -- order must match first_byte_type
above */ above */
static const grpc_chttp2_hpack_parser_state first_byte_action[] = { static const grpc_chttp2_hpack_parser_state first_byte_action[] = {
parse_indexed_field, parse_indexed_field_x, parse_lithdr_incidx, parse_indexed_field, parse_indexed_field_x,
parse_lithdr_incidx_x, parse_lithdr_incidx_v, parse_lithdr_notidx, parse_lithdr_incidx, parse_lithdr_incidx_x,
parse_lithdr_notidx_x, parse_lithdr_notidx_v, parse_lithdr_nvridx, parse_lithdr_incidx_v, parse_lithdr_notidx,
parse_lithdr_nvridx_x, parse_lithdr_nvridx_v, parse_max_tbl_size, parse_lithdr_notidx_x, parse_lithdr_notidx_v,
parse_lithdr_nvridx, parse_lithdr_nvridx_x,
parse_lithdr_nvridx_v, parse_max_tbl_size,
parse_max_tbl_size_x, parse_error}; parse_max_tbl_size_x, parse_error};
/* indexes the first byte to a parse state function - generated by /* indexes the first byte to a parse state function - generated by
@ -221,7 +224,8 @@ static const gpr_uint8 first_byte_lut[256] = {
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD,
INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD_X, }; INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD, INDEXED_FIELD_X,
};
/* state table for huffman decoding: given a state, gives an index/16 into /* state table for huffman decoding: given a state, gives an index/16 into
next_sub_tbl. Taking that index and adding the value of the nibble being next_sub_tbl. Taking that index and adding the value of the nibble being
@ -241,7 +245,8 @@ static const gpr_uint8 next_tbl[256] = {
38, 1, 1, 1, 1, 1, 1, 1, 15, 2, 2, 2, 2, 26, 3, 3, 39, 1, 1, 1, 38, 1, 1, 1, 1, 1, 1, 1, 15, 2, 2, 2, 2, 26, 3, 3, 39, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 7, 3, 3, 3, 40, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 7, 3, 3, 3, 40, 2,
41, 1, 1, 1, 42, 43, 1, 1, 44, 1, 1, 1, 1, 15, 2, 2, 2, 2, 2, 2, 41, 1, 1, 1, 42, 43, 1, 1, 44, 1, 1, 1, 1, 15, 2, 2, 2, 2, 2, 2,
3, 3, 3, 45, 46, 1, 1, 2, 2, 2, 35, 3, 3, 18, 47, 2, }; 3, 3, 3, 45, 46, 1, 1, 2, 2, 2, 35, 3, 3, 18, 47, 2,
};
/* next state, based upon current state and the current nibble: see above. /* next state, based upon current state and the current nibble: see above.
generated by gen_hpack_tables.c */ generated by gen_hpack_tables.c */
static const gpr_int16 next_sub_tbl[48 * 16] = { static const gpr_int16 next_sub_tbl[48 * 16] = {
@ -296,7 +301,8 @@ static const gpr_int16 next_sub_tbl[48 * 16] = {
4, 8, 4, 8, 4, 8, 4, 8, 4, 8, 0, 0, 0, 0, 0, 4, 8, 4, 8, 4, 8, 4, 8, 4, 8, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 245, 246, 247, 248, 249, 250, 251, 252, 0, 0, 0, 0, 0, 0, 0, 245, 246, 247, 248, 249, 250, 251, 252,
253, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253, 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 255, }; 0, 0, 255,
};
/* emission table: indexed like next_tbl, ultimately gives the byte to be /* emission table: indexed like next_tbl, ultimately gives the byte to be
emitted, or -1 for no byte, or 256 for end of stream emitted, or -1 for no byte, or 256 for end of stream
@ -319,7 +325,8 @@ static const gpr_uint16 emit_tbl[256] = {
204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218,
219, 220, 221, 0, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 219, 220, 221, 0, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
248, }; 248,
};
/* generated by gen_hpack_tables.c */ /* generated by gen_hpack_tables.c */
static const gpr_int16 emit_sub_tbl[249 * 16] = { static const gpr_int16 emit_sub_tbl[249 * 16] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@ -587,7 +594,8 @@ static const gpr_int16 emit_sub_tbl[249 * 16] = {
251, 251, 252, 252, 253, 253, 254, 254, 2, 3, 4, 5, 6, 7, 8, 251, 251, 252, 252, 253, 253, 254, 254, 2, 3, 4, 5, 6, 7, 8,
11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27,
28, 29, 30, 31, 127, 220, 249, -1, 10, 10, 10, 10, 13, 13, 13, 28, 29, 30, 31, 127, 220, 249, -1, 10, 10, 10, 10, 13, 13, 13,
13, 22, 22, 22, 22, 256, 256, 256, 256, }; 13, 22, 22, 22, 22, 256, 256, 256, 256,
};
static const gpr_uint8 inverse_base64[256] = { static const gpr_uint8 inverse_base64[256] = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
@ -607,7 +615,8 @@ static const gpr_uint8 inverse_base64[256] = {
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, }; 255,
};
/* emission helpers */ /* emission helpers */
static void on_hdr(grpc_chttp2_hpack_parser *p, grpc_mdelem *md, static void on_hdr(grpc_chttp2_hpack_parser *p, grpc_mdelem *md,
@ -945,7 +954,7 @@ static int parse_value1(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return 1; return 1;
} }
*p->parsing.value += (((gpr_uint32) * cur) & 0x7f) << 7; *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 7;
if ((*cur) & 0x80) { if ((*cur) & 0x80) {
return parse_value2(p, cur + 1, end); return parse_value2(p, cur + 1, end);
@ -963,7 +972,7 @@ static int parse_value2(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return 1; return 1;
} }
*p->parsing.value += (((gpr_uint32) * cur) & 0x7f) << 14; *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 14;
if ((*cur) & 0x80) { if ((*cur) & 0x80) {
return parse_value3(p, cur + 1, end); return parse_value3(p, cur + 1, end);
@ -981,7 +990,7 @@ static int parse_value3(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
return 1; return 1;
} }
*p->parsing.value += (((gpr_uint32) * cur) & 0x7f) << 21; *p->parsing.value += (((gpr_uint32)*cur) & 0x7f) << 21;
if ((*cur) & 0x80) { if ((*cur) & 0x80) {
return parse_value4(p, cur + 1, end); return parse_value4(p, cur + 1, end);
@ -1366,8 +1375,8 @@ int grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p,
} }
grpc_chttp2_parse_error grpc_chttp2_header_parser_parse( grpc_chttp2_parse_error grpc_chttp2_header_parser_parse(
void *hpack_parser, grpc_chttp2_parse_state *state, gpr_slice slice, void *hpack_parser, grpc_chttp2_transport_parsing *transport_parsing,
int is_last) { grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
grpc_chttp2_hpack_parser *parser = hpack_parser; grpc_chttp2_hpack_parser *parser = hpack_parser;
if (!grpc_chttp2_hpack_parser_parse(parser, GPR_SLICE_START_PTR(slice), if (!grpc_chttp2_hpack_parser_parse(parser, GPR_SLICE_START_PTR(slice),
GPR_SLICE_END_PTR(slice))) { GPR_SLICE_END_PTR(slice))) {
@ -1379,9 +1388,16 @@ grpc_chttp2_parse_error grpc_chttp2_header_parser_parse(
"end of header frame not aligned with a hpack record boundary"); "end of header frame not aligned with a hpack record boundary");
return GRPC_CHTTP2_CONNECTION_ERROR; return GRPC_CHTTP2_CONNECTION_ERROR;
} }
state->metadata_boundary = parser->is_boundary; if (parser->is_boundary) {
state->end_of_stream = parser->is_eof; grpc_chttp2_incoming_metadata_buffer_place_metadata_batch_into(
state->need_flush_reads = parser->is_eof; &stream_parsing->incoming_metadata,
&stream_parsing->data_parser.incoming_sopb);
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
}
if (parser->is_eof) {
stream_parsing->received_close = 1;
}
parser->on_header = on_header_not_set; parser->on_header = on_header_not_set;
parser->on_header_user_data = NULL; parser->on_header_user_data = NULL;
parser->is_boundary = 0xde; parser->is_boundary = 0xde;

@ -107,7 +107,7 @@ int grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p,
/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for /* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
the transport */ the transport */
grpc_chttp2_parse_error grpc_chttp2_header_parser_parse( grpc_chttp2_parse_error grpc_chttp2_header_parser_parse(
void *hpack_parser, grpc_chttp2_parse_state *state, gpr_slice slice, void *hpack_parser, grpc_chttp2_transport_parsing *transport_parsing,
int is_last); grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H */ #endif /* GRPC_INTERNAL_CORE_TRANSPORT_CHTTP2_HPACK_PARSER_H */

@ -104,7 +104,8 @@ static struct {
/* 58: */ {"user-agent", ""}, /* 58: */ {"user-agent", ""},
/* 59: */ {"vary", ""}, /* 59: */ {"vary", ""},
/* 60: */ {"via", ""}, /* 60: */ {"via", ""},
/* 61: */ {"www-authenticate", ""}, }; /* 61: */ {"www-authenticate", ""},
};
void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl, grpc_mdctx *mdctx) { void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl *tbl, grpc_mdctx *mdctx) {
size_t i; size_t i;

@ -37,260 +37,69 @@
command: command:
:%s/.* \([0-9a-f]\+\) \[ *\([0-9]\+\)\]/{0x\1, \2},/g */ :%s/.* \([0-9a-f]\+\) \[ *\([0-9]\+\)\]/{0x\1, \2},/g */
const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS] = { const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS] = {
{0x1ff8, 13}, {0x1ff8, 13}, {0x7fffd8, 23}, {0xfffffe2, 28}, {0xfffffe3, 28},
{0x7fffd8, 23}, {0xfffffe4, 28}, {0xfffffe5, 28}, {0xfffffe6, 28}, {0xfffffe7, 28},
{0xfffffe2, 28}, {0xfffffe8, 28}, {0xffffea, 24}, {0x3ffffffc, 30}, {0xfffffe9, 28},
{0xfffffe3, 28}, {0xfffffea, 28}, {0x3ffffffd, 30}, {0xfffffeb, 28}, {0xfffffec, 28},
{0xfffffe4, 28}, {0xfffffed, 28}, {0xfffffee, 28}, {0xfffffef, 28}, {0xffffff0, 28},
{0xfffffe5, 28}, {0xffffff1, 28}, {0xffffff2, 28}, {0x3ffffffe, 30}, {0xffffff3, 28},
{0xfffffe6, 28}, {0xffffff4, 28}, {0xffffff5, 28}, {0xffffff6, 28}, {0xffffff7, 28},
{0xfffffe7, 28}, {0xffffff8, 28}, {0xffffff9, 28}, {0xffffffa, 28}, {0xffffffb, 28},
{0xfffffe8, 28}, {0x14, 6}, {0x3f8, 10}, {0x3f9, 10}, {0xffa, 12},
{0xffffea, 24}, {0x1ff9, 13}, {0x15, 6}, {0xf8, 8}, {0x7fa, 11},
{0x3ffffffc, 30}, {0x3fa, 10}, {0x3fb, 10}, {0xf9, 8}, {0x7fb, 11},
{0xfffffe9, 28}, {0xfa, 8}, {0x16, 6}, {0x17, 6}, {0x18, 6},
{0xfffffea, 28}, {0x0, 5}, {0x1, 5}, {0x2, 5}, {0x19, 6},
{0x3ffffffd, 30}, {0x1a, 6}, {0x1b, 6}, {0x1c, 6}, {0x1d, 6},
{0xfffffeb, 28}, {0x1e, 6}, {0x1f, 6}, {0x5c, 7}, {0xfb, 8},
{0xfffffec, 28}, {0x7ffc, 15}, {0x20, 6}, {0xffb, 12}, {0x3fc, 10},
{0xfffffed, 28}, {0x1ffa, 13}, {0x21, 6}, {0x5d, 7}, {0x5e, 7},
{0xfffffee, 28}, {0x5f, 7}, {0x60, 7}, {0x61, 7}, {0x62, 7},
{0xfffffef, 28}, {0x63, 7}, {0x64, 7}, {0x65, 7}, {0x66, 7},
{0xffffff0, 28}, {0x67, 7}, {0x68, 7}, {0x69, 7}, {0x6a, 7},
{0xffffff1, 28}, {0x6b, 7}, {0x6c, 7}, {0x6d, 7}, {0x6e, 7},
{0xffffff2, 28}, {0x6f, 7}, {0x70, 7}, {0x71, 7}, {0x72, 7},
{0x3ffffffe, 30}, {0xfc, 8}, {0x73, 7}, {0xfd, 8}, {0x1ffb, 13},
{0xffffff3, 28}, {0x7fff0, 19}, {0x1ffc, 13}, {0x3ffc, 14}, {0x22, 6},
{0xffffff4, 28}, {0x7ffd, 15}, {0x3, 5}, {0x23, 6}, {0x4, 5},
{0xffffff5, 28}, {0x24, 6}, {0x5, 5}, {0x25, 6}, {0x26, 6},
{0xffffff6, 28}, {0x27, 6}, {0x6, 5}, {0x74, 7}, {0x75, 7},
{0xffffff7, 28}, {0x28, 6}, {0x29, 6}, {0x2a, 6}, {0x7, 5},
{0xffffff8, 28}, {0x2b, 6}, {0x76, 7}, {0x2c, 6}, {0x8, 5},
{0xffffff9, 28}, {0x9, 5}, {0x2d, 6}, {0x77, 7}, {0x78, 7},
{0xffffffa, 28}, {0x79, 7}, {0x7a, 7}, {0x7b, 7}, {0x7ffe, 15},
{0xffffffb, 28}, {0x7fc, 11}, {0x3ffd, 14}, {0x1ffd, 13}, {0xffffffc, 28},
{0x14, 6}, {0xfffe6, 20}, {0x3fffd2, 22}, {0xfffe7, 20}, {0xfffe8, 20},
{0x3f8, 10}, {0x3fffd3, 22}, {0x3fffd4, 22}, {0x3fffd5, 22}, {0x7fffd9, 23},
{0x3f9, 10}, {0x3fffd6, 22}, {0x7fffda, 23}, {0x7fffdb, 23}, {0x7fffdc, 23},
{0xffa, 12}, {0x7fffdd, 23}, {0x7fffde, 23}, {0xffffeb, 24}, {0x7fffdf, 23},
{0x1ff9, 13}, {0xffffec, 24}, {0xffffed, 24}, {0x3fffd7, 22}, {0x7fffe0, 23},
{0x15, 6}, {0xffffee, 24}, {0x7fffe1, 23}, {0x7fffe2, 23}, {0x7fffe3, 23},
{0xf8, 8}, {0x7fffe4, 23}, {0x1fffdc, 21}, {0x3fffd8, 22}, {0x7fffe5, 23},
{0x7fa, 11}, {0x3fffd9, 22}, {0x7fffe6, 23}, {0x7fffe7, 23}, {0xffffef, 24},
{0x3fa, 10}, {0x3fffda, 22}, {0x1fffdd, 21}, {0xfffe9, 20}, {0x3fffdb, 22},
{0x3fb, 10}, {0x3fffdc, 22}, {0x7fffe8, 23}, {0x7fffe9, 23}, {0x1fffde, 21},
{0xf9, 8}, {0x7fffea, 23}, {0x3fffdd, 22}, {0x3fffde, 22}, {0xfffff0, 24},
{0x7fb, 11}, {0x1fffdf, 21}, {0x3fffdf, 22}, {0x7fffeb, 23}, {0x7fffec, 23},
{0xfa, 8}, {0x1fffe0, 21}, {0x1fffe1, 21}, {0x3fffe0, 22}, {0x1fffe2, 21},
{0x16, 6}, {0x7fffed, 23}, {0x3fffe1, 22}, {0x7fffee, 23}, {0x7fffef, 23},
{0x17, 6}, {0xfffea, 20}, {0x3fffe2, 22}, {0x3fffe3, 22}, {0x3fffe4, 22},
{0x18, 6}, {0x7ffff0, 23}, {0x3fffe5, 22}, {0x3fffe6, 22}, {0x7ffff1, 23},
{0x0, 5}, {0x3ffffe0, 26}, {0x3ffffe1, 26}, {0xfffeb, 20}, {0x7fff1, 19},
{0x1, 5}, {0x3fffe7, 22}, {0x7ffff2, 23}, {0x3fffe8, 22}, {0x1ffffec, 25},
{0x2, 5}, {0x3ffffe2, 26}, {0x3ffffe3, 26}, {0x3ffffe4, 26}, {0x7ffffde, 27},
{0x19, 6}, {0x7ffffdf, 27}, {0x3ffffe5, 26}, {0xfffff1, 24}, {0x1ffffed, 25},
{0x1a, 6}, {0x7fff2, 19}, {0x1fffe3, 21}, {0x3ffffe6, 26}, {0x7ffffe0, 27},
{0x1b, 6}, {0x7ffffe1, 27}, {0x3ffffe7, 26}, {0x7ffffe2, 27}, {0xfffff2, 24},
{0x1c, 6}, {0x1fffe4, 21}, {0x1fffe5, 21}, {0x3ffffe8, 26}, {0x3ffffe9, 26},
{0x1d, 6}, {0xffffffd, 28}, {0x7ffffe3, 27}, {0x7ffffe4, 27}, {0x7ffffe5, 27},
{0x1e, 6}, {0xfffec, 20}, {0xfffff3, 24}, {0xfffed, 20}, {0x1fffe6, 21},
{0x1f, 6}, {0x3fffe9, 22}, {0x1fffe7, 21}, {0x1fffe8, 21}, {0x7ffff3, 23},
{0x5c, 7}, {0x3fffea, 22}, {0x3fffeb, 22}, {0x1ffffee, 25}, {0x1ffffef, 25},
{0xfb, 8}, {0xfffff4, 24}, {0xfffff5, 24}, {0x3ffffea, 26}, {0x7ffff4, 23},
{0x7ffc, 15}, {0x3ffffeb, 26}, {0x7ffffe6, 27}, {0x3ffffec, 26}, {0x3ffffed, 26},
{0x20, 6}, {0x7ffffe7, 27}, {0x7ffffe8, 27}, {0x7ffffe9, 27}, {0x7ffffea, 27},
{0xffb, 12}, {0x7ffffeb, 27}, {0xffffffe, 28}, {0x7ffffec, 27}, {0x7ffffed, 27},
{0x3fc, 10}, {0x7ffffee, 27}, {0x7ffffef, 27}, {0x7fffff0, 27}, {0x3ffffee, 26},
{0x1ffa, 13}, {0x3fffffff, 30},
{0x21, 6}, };
{0x5d, 7},
{0x5e, 7},
{0x5f, 7},
{0x60, 7},
{0x61, 7},
{0x62, 7},
{0x63, 7},
{0x64, 7},
{0x65, 7},
{0x66, 7},
{0x67, 7},
{0x68, 7},
{0x69, 7},
{0x6a, 7},
{0x6b, 7},
{0x6c, 7},
{0x6d, 7},
{0x6e, 7},
{0x6f, 7},
{0x70, 7},
{0x71, 7},
{0x72, 7},
{0xfc, 8},
{0x73, 7},
{0xfd, 8},
{0x1ffb, 13},
{0x7fff0, 19},
{0x1ffc, 13},
{0x3ffc, 14},
{0x22, 6},
{0x7ffd, 15},
{0x3, 5},
{0x23, 6},
{0x4, 5},
{0x24, 6},
{0x5, 5},
{0x25, 6},
{0x26, 6},
{0x27, 6},
{0x6, 5},
{0x74, 7},
{0x75, 7},
{0x28, 6},
{0x29, 6},
{0x2a, 6},
{0x7, 5},
{0x2b, 6},
{0x76, 7},
{0x2c, 6},
{0x8, 5},
{0x9, 5},
{0x2d, 6},
{0x77, 7},
{0x78, 7},
{0x79, 7},
{0x7a, 7},
{0x7b, 7},
{0x7ffe, 15},
{0x7fc, 11},
{0x3ffd, 14},
{0x1ffd, 13},
{0xffffffc, 28},
{0xfffe6, 20},
{0x3fffd2, 22},
{0xfffe7, 20},
{0xfffe8, 20},
{0x3fffd3, 22},
{0x3fffd4, 22},
{0x3fffd5, 22},
{0x7fffd9, 23},
{0x3fffd6, 22},
{0x7fffda, 23},
{0x7fffdb, 23},
{0x7fffdc, 23},
{0x7fffdd, 23},
{0x7fffde, 23},
{0xffffeb, 24},
{0x7fffdf, 23},
{0xffffec, 24},
{0xffffed, 24},
{0x3fffd7, 22},
{0x7fffe0, 23},
{0xffffee, 24},
{0x7fffe1, 23},
{0x7fffe2, 23},
{0x7fffe3, 23},
{0x7fffe4, 23},
{0x1fffdc, 21},
{0x3fffd8, 22},
{0x7fffe5, 23},
{0x3fffd9, 22},
{0x7fffe6, 23},
{0x7fffe7, 23},
{0xffffef, 24},
{0x3fffda, 22},
{0x1fffdd, 21},
{0xfffe9, 20},
{0x3fffdb, 22},
{0x3fffdc, 22},
{0x7fffe8, 23},
{0x7fffe9, 23},
{0x1fffde, 21},
{0x7fffea, 23},
{0x3fffdd, 22},
{0x3fffde, 22},
{0xfffff0, 24},
{0x1fffdf, 21},
{0x3fffdf, 22},
{0x7fffeb, 23},
{0x7fffec, 23},
{0x1fffe0, 21},
{0x1fffe1, 21},
{0x3fffe0, 22},
{0x1fffe2, 21},
{0x7fffed, 23},
{0x3fffe1, 22},
{0x7fffee, 23},
{0x7fffef, 23},
{0xfffea, 20},
{0x3fffe2, 22},
{0x3fffe3, 22},
{0x3fffe4, 22},
{0x7ffff0, 23},
{0x3fffe5, 22},
{0x3fffe6, 22},
{0x7ffff1, 23},
{0x3ffffe0, 26},
{0x3ffffe1, 26},
{0xfffeb, 20},
{0x7fff1, 19},
{0x3fffe7, 22},
{0x7ffff2, 23},
{0x3fffe8, 22},
{0x1ffffec, 25},
{0x3ffffe2, 26},
{0x3ffffe3, 26},
{0x3ffffe4, 26},
{0x7ffffde, 27},
{0x7ffffdf, 27},
{0x3ffffe5, 26},
{0xfffff1, 24},
{0x1ffffed, 25},
{0x7fff2, 19},
{0x1fffe3, 21},
{0x3ffffe6, 26},
{0x7ffffe0, 27},
{0x7ffffe1, 27},
{0x3ffffe7, 26},
{0x7ffffe2, 27},
{0xfffff2, 24},
{0x1fffe4, 21},
{0x1fffe5, 21},
{0x3ffffe8, 26},
{0x3ffffe9, 26},
{0xffffffd, 28},
{0x7ffffe3, 27},
{0x7ffffe4, 27},
{0x7ffffe5, 27},
{0xfffec, 20},
{0xfffff3, 24},
{0xfffed, 20},
{0x1fffe6, 21},
{0x3fffe9, 22},
{0x1fffe7, 21},
{0x1fffe8, 21},
{0x7ffff3, 23},
{0x3fffea, 22},
{0x3fffeb, 22},
{0x1ffffee, 25},
{0x1ffffef, 25},
{0xfffff4, 24},
{0xfffff5, 24},
{0x3ffffea, 26},
{0x7ffff4, 23},
{0x3ffffeb, 26},
{0x7ffffe6, 27},
{0x3ffffec, 26},
{0x3ffffed, 26},
{0x7ffffe7, 27},
{0x7ffffe8, 27},
{0x7ffffe9, 27},
{0x7ffffea, 27},
{0x7ffffeb, 27},
{0xffffffe, 28},
{0x7ffffec, 27},
{0x7ffffed, 27},
{0x7ffffee, 27},
{0x7ffffef, 27},
{0x7fffff0, 27},
{0x3ffffee, 26},
{0x3fffffff, 30}, };

@ -0,0 +1,177 @@
/*
*
* 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/transport/chttp2/incoming_metadata.h"
#include <string.h>
#include "src/core/transport/chttp2/internal.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
void grpc_chttp2_incoming_metadata_buffer_init(
grpc_chttp2_incoming_metadata_buffer *buffer) {
buffer->deadline = gpr_inf_future;
}
void grpc_chttp2_incoming_metadata_buffer_destroy(
grpc_chttp2_incoming_metadata_buffer *buffer) {
gpr_free(buffer->elems);
}
void grpc_chttp2_incoming_metadata_buffer_add(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem *elem) {
if (buffer->capacity == buffer->count) {
buffer->capacity = GPR_MAX(8, 2 * buffer->capacity);
buffer->elems =
gpr_realloc(buffer->elems, sizeof(*buffer->elems) * buffer->capacity);
}
buffer->elems[buffer->count++].md = elem;
}
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline) {
buffer->deadline = deadline;
}
void grpc_chttp2_incoming_metadata_live_op_buffer_end(
grpc_chttp2_incoming_metadata_live_op_buffer *buffer) {
gpr_free(buffer->elems);
buffer->elems = NULL;
}
void grpc_chttp2_incoming_metadata_buffer_place_metadata_batch_into(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_stream_op_buffer *sopb) {
grpc_metadata_batch b;
b.list.head = NULL;
/* Store away the last element of the list, so that in patch_metadata_ops
we can reconstitute the list.
We can't do list building here as later incoming metadata may reallocate
the underlying array. */
b.list.tail = (void *)(gpr_intptr)buffer->count;
b.garbage.head = b.garbage.tail = NULL;
b.deadline = buffer->deadline;
buffer->deadline = gpr_inf_future;
grpc_sopb_add_metadata(sopb, b);
}
void grpc_chttp2_incoming_metadata_buffer_swap(
grpc_chttp2_incoming_metadata_buffer *a,
grpc_chttp2_incoming_metadata_buffer *b) {
GPR_SWAP(grpc_chttp2_incoming_metadata_buffer, *a, *b);
}
void grpc_incoming_metadata_buffer_move_to_referencing_sopb(
grpc_chttp2_incoming_metadata_buffer *src,
grpc_chttp2_incoming_metadata_buffer *dst, grpc_stream_op_buffer *sopb) {
size_t delta;
size_t i;
dst->deadline = gpr_time_min(src->deadline, dst->deadline);
if (src->count == 0) {
return;
}
if (dst->count == 0) {
grpc_chttp2_incoming_metadata_buffer_swap(src, dst);
return;
}
delta = dst->count;
if (dst->capacity < src->count + dst->count) {
dst->capacity = GPR_MAX(dst->capacity * 2, src->count + dst->count);
dst->elems = gpr_realloc(dst->elems, dst->capacity * sizeof(*dst->elems));
}
memcpy(dst->elems + dst->count, src->elems, src->count * sizeof(*src->elems));
dst->count += src->count;
for (i = 0; i < sopb->nops; i++) {
if (sopb->ops[i].type != GRPC_OP_METADATA) continue;
sopb->ops[i].data.metadata.list.tail =
(void *)(delta + (gpr_intptr)sopb->ops[i].data.metadata.list.tail);
}
}
void grpc_chttp2_incoming_metadata_buffer_postprocess_sopb_and_begin_live_op(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_stream_op_buffer *sopb,
grpc_chttp2_incoming_metadata_live_op_buffer *live_op_buffer) {
grpc_stream_op *ops = sopb->ops;
size_t nops = sopb->nops;
size_t i;
size_t j;
size_t mdidx = 0;
size_t last_mdidx;
int found_metadata = 0;
/* rework the array of metadata into a linked list, making use
of the breadcrumbs we left in metadata batches during
add_metadata_batch */
for (i = 0; i < nops; i++) {
grpc_stream_op *op = &ops[i];
if (op->type != GRPC_OP_METADATA) continue;
found_metadata = 1;
/* we left a breadcrumb indicating where the end of this list is,
and since we add sequentially, we know from the end of the last
segment where this segment begins */
last_mdidx = (size_t)(gpr_intptr)(op->data.metadata.list.tail);
GPR_ASSERT(last_mdidx > mdidx);
GPR_ASSERT(last_mdidx <= buffer->count);
/* turn the array into a doubly linked list */
op->data.metadata.list.head = &buffer->elems[mdidx];
op->data.metadata.list.tail = &buffer->elems[last_mdidx - 1];
for (j = mdidx + 1; j < last_mdidx; j++) {
buffer->elems[j].prev = &buffer->elems[j - 1];
buffer->elems[j - 1].next = &buffer->elems[j];
}
buffer->elems[mdidx].prev = NULL;
buffer->elems[last_mdidx - 1].next = NULL;
/* track where we're up to */
mdidx = last_mdidx;
}
if (found_metadata) {
live_op_buffer->elems = buffer->elems;
if (mdidx != buffer->count) {
/* we have a partially read metadata batch still in incoming_metadata */
size_t new_count = buffer->count - mdidx;
size_t copy_bytes = sizeof(*buffer->elems) * new_count;
GPR_ASSERT(mdidx < buffer->count);
buffer->elems = gpr_malloc(copy_bytes);
memcpy(live_op_buffer->elems + mdidx, buffer->elems, copy_bytes);
buffer->count = buffer->capacity = new_count;
} else {
buffer->elems = NULL;
buffer->count = 0;
buffer->capacity = 0;
}
}
}

@ -0,0 +1,80 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_INTERNAL_CORE_CHTTP2_INCOMING_METADATA_H
#define GRPC_INTERNAL_CORE_CHTTP2_INCOMING_METADATA_H
#include "src/core/transport/transport.h"
typedef struct {
grpc_linked_mdelem *elems;
size_t count;
size_t capacity;
gpr_timespec deadline;
} grpc_chttp2_incoming_metadata_buffer;
typedef struct {
grpc_linked_mdelem *elems;
} grpc_chttp2_incoming_metadata_live_op_buffer;
/** assumes everything initially zeroed */
void grpc_chttp2_incoming_metadata_buffer_init(
grpc_chttp2_incoming_metadata_buffer *buffer);
void grpc_chttp2_incoming_metadata_buffer_destroy(
grpc_chttp2_incoming_metadata_buffer *buffer);
void grpc_chttp2_incoming_metadata_buffer_reset(
grpc_chttp2_incoming_metadata_buffer *buffer);
void grpc_chttp2_incoming_metadata_buffer_add(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem *elem);
void grpc_chttp2_incoming_metadata_buffer_set_deadline(
grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline);
/** extend sopb with a metadata batch; this must be post-processed by
grpc_chttp2_incoming_metadata_buffer_postprocess_sopb before being handed
out of the transport */
void grpc_chttp2_incoming_metadata_buffer_place_metadata_batch_into(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_stream_op_buffer *sopb);
void grpc_incoming_metadata_buffer_move_to_referencing_sopb(
grpc_chttp2_incoming_metadata_buffer *src,
grpc_chttp2_incoming_metadata_buffer *dst, grpc_stream_op_buffer *sopb);
void grpc_chttp2_incoming_metadata_buffer_postprocess_sopb_and_begin_live_op(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_stream_op_buffer *sopb,
grpc_chttp2_incoming_metadata_live_op_buffer *live_op_buffer);
void grpc_chttp2_incoming_metadata_live_op_buffer_end(
grpc_chttp2_incoming_metadata_live_op_buffer *live_op_buffer);
#endif /* GRPC_INTERNAL_CORE_CHTTP2_INCOMING_METADATA_H */

@ -0,0 +1,609 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H
#define GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H
#include "src/core/transport/transport_impl.h"
#include "src/core/iomgr/endpoint.h"
#include "src/core/transport/chttp2/frame.h"
#include "src/core/transport/chttp2/frame_data.h"
#include "src/core/transport/chttp2/frame_goaway.h"
#include "src/core/transport/chttp2/frame_ping.h"
#include "src/core/transport/chttp2/frame_rst_stream.h"
#include "src/core/transport/chttp2/frame_settings.h"
#include "src/core/transport/chttp2/frame_window_update.h"
#include "src/core/transport/chttp2/hpack_parser.h"
#include "src/core/transport/chttp2/incoming_metadata.h"
#include "src/core/transport/chttp2/stream_encoder.h"
#include "src/core/transport/chttp2/stream_map.h"
typedef struct grpc_chttp2_transport grpc_chttp2_transport;
typedef struct grpc_chttp2_stream grpc_chttp2_stream;
/* streams are kept in various linked lists depending on what things need to
happen to them... this enum labels each list */
typedef enum {
GRPC_CHTTP2_LIST_ALL_STREAMS,
GRPC_CHTTP2_LIST_READ_WRITE_STATE_CHANGED,
GRPC_CHTTP2_LIST_WRITABLE,
GRPC_CHTTP2_LIST_WRITING,
GRPC_CHTTP2_LIST_WRITTEN,
GRPC_CHTTP2_LIST_WRITABLE_WINDOW_UPDATE,
GRPC_CHTTP2_LIST_PARSING_SEEN,
GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_PARSING,
GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED,
/** streams that are waiting to start because there are too many concurrent
streams on the connection */
GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY,
STREAM_LIST_COUNT /* must be last */
} grpc_chttp2_stream_list_id;
/* deframer state for the overall http2 stream of bytes */
typedef enum {
/* prefix: one entry per http2 connection prefix byte */
GRPC_DTS_CLIENT_PREFIX_0 = 0,
GRPC_DTS_CLIENT_PREFIX_1,
GRPC_DTS_CLIENT_PREFIX_2,
GRPC_DTS_CLIENT_PREFIX_3,
GRPC_DTS_CLIENT_PREFIX_4,
GRPC_DTS_CLIENT_PREFIX_5,
GRPC_DTS_CLIENT_PREFIX_6,
GRPC_DTS_CLIENT_PREFIX_7,
GRPC_DTS_CLIENT_PREFIX_8,
GRPC_DTS_CLIENT_PREFIX_9,
GRPC_DTS_CLIENT_PREFIX_10,
GRPC_DTS_CLIENT_PREFIX_11,
GRPC_DTS_CLIENT_PREFIX_12,
GRPC_DTS_CLIENT_PREFIX_13,
GRPC_DTS_CLIENT_PREFIX_14,
GRPC_DTS_CLIENT_PREFIX_15,
GRPC_DTS_CLIENT_PREFIX_16,
GRPC_DTS_CLIENT_PREFIX_17,
GRPC_DTS_CLIENT_PREFIX_18,
GRPC_DTS_CLIENT_PREFIX_19,
GRPC_DTS_CLIENT_PREFIX_20,
GRPC_DTS_CLIENT_PREFIX_21,
GRPC_DTS_CLIENT_PREFIX_22,
GRPC_DTS_CLIENT_PREFIX_23,
/* frame header byte 0... */
/* must follow from the prefix states */
GRPC_DTS_FH_0,
GRPC_DTS_FH_1,
GRPC_DTS_FH_2,
GRPC_DTS_FH_3,
GRPC_DTS_FH_4,
GRPC_DTS_FH_5,
GRPC_DTS_FH_6,
GRPC_DTS_FH_7,
/* ... frame header byte 8 */
GRPC_DTS_FH_8,
/* inside a http2 frame */
GRPC_DTS_FRAME
} grpc_chttp2_deframe_transport_state;
typedef enum {
GRPC_WRITE_STATE_OPEN,
GRPC_WRITE_STATE_QUEUED_CLOSE,
GRPC_WRITE_STATE_SENT_CLOSE
} grpc_chttp2_write_state;
typedef enum {
GRPC_DONT_SEND_CLOSED = 0,
GRPC_SEND_CLOSED,
GRPC_SEND_CLOSED_WITH_RST_STREAM
} grpc_chttp2_send_closed;
typedef struct {
grpc_chttp2_stream *head;
grpc_chttp2_stream *tail;
} grpc_chttp2_stream_list;
typedef struct {
grpc_chttp2_stream *next;
grpc_chttp2_stream *prev;
} grpc_chttp2_stream_link;
typedef enum {
GRPC_CHTTP2_ERROR_STATE_NONE,
GRPC_CHTTP2_ERROR_STATE_SEEN,
GRPC_CHTTP2_ERROR_STATE_NOTIFIED
} grpc_chttp2_error_state;
/* We keep several sets of connection wide parameters */
typedef enum {
/* The settings our peer has asked for (and we have acked) */
GRPC_PEER_SETTINGS = 0,
/* The settings we'd like to have */
GRPC_LOCAL_SETTINGS,
/* The settings we've published to our peer */
GRPC_SENT_SETTINGS,
/* The settings the peer has acked */
GRPC_ACKED_SETTINGS,
GRPC_NUM_SETTING_SETS
} grpc_chttp2_setting_set;
/* Outstanding ping request data */
typedef struct grpc_chttp2_outstanding_ping {
gpr_uint8 id[8];
grpc_iomgr_closure *on_recv;
struct grpc_chttp2_outstanding_ping *next;
struct grpc_chttp2_outstanding_ping *prev;
} grpc_chttp2_outstanding_ping;
typedef struct {
/** data to write next write */
gpr_slice_buffer qbuf;
/** queued callbacks */
grpc_iomgr_closure *pending_closures;
/** window available for us to send to peer */
gpr_uint32 outgoing_window;
/** window available for peer to send to us - updated after parse */
gpr_uint32 incoming_window;
/** how much window would we like to have for incoming_window */
gpr_uint32 connection_window_target;
/** is this transport a client? */
gpr_uint8 is_client;
/** are the local settings dirty and need to be sent? */
gpr_uint8 dirtied_local_settings;
/** have local settings been sent? */
gpr_uint8 sent_local_settings;
/** bitmask of setting indexes to send out */
gpr_uint32 force_send_settings;
/** settings values */
gpr_uint32 settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS];
/** has there been a connection level error, and have we notified
anyone about it? */
grpc_chttp2_error_state error_state;
/** what is the next stream id to be allocated by this peer?
copied to next_stream_id in parsing when parsing commences */
gpr_uint32 next_stream_id;
/** last received stream id */
gpr_uint32 last_incoming_stream_id;
/** pings awaiting responses */
grpc_chttp2_outstanding_ping pings;
/** next payload for an outgoing ping */
gpr_uint64 ping_counter;
/** concurrent stream count: updated when not parsing,
so this is a strict over-estimation on the client */
gpr_uint32 concurrent_stream_count;
/** is there a goaway available? (boolean) */
grpc_chttp2_error_state goaway_state;
/** what is the debug text of the goaway? */
gpr_slice goaway_text;
/** what is the status code of the goaway? */
grpc_status_code goaway_error;
} grpc_chttp2_transport_global;
typedef struct {
/** data to write now */
gpr_slice_buffer outbuf;
/** hpack encoding */
grpc_chttp2_hpack_compressor hpack_compressor;
/** is this a client? */
gpr_uint8 is_client;
} grpc_chttp2_transport_writing;
struct grpc_chttp2_transport_parsing {
/** is this transport a client? (boolean) */
gpr_uint8 is_client;
/** were settings updated? */
gpr_uint8 settings_updated;
/** was a settings ack received? */
gpr_uint8 settings_ack_received;
/** was a goaway frame received? */
gpr_uint8 goaway_received;
/** initial window change */
gpr_int64 initial_window_update;
/** data to write later - after parsing */
gpr_slice_buffer qbuf;
/* metadata object cache */
grpc_mdstr *str_grpc_timeout;
/** parser for headers */
grpc_chttp2_hpack_parser hpack_parser;
/** simple one shot parsers */
union {
grpc_chttp2_window_update_parser window_update;
grpc_chttp2_settings_parser settings;
grpc_chttp2_ping_parser ping;
grpc_chttp2_rst_stream_parser rst_stream;
} simple;
/** parser for goaway frames */
grpc_chttp2_goaway_parser goaway_parser;
/** window available for peer to send to us */
gpr_uint32 incoming_window;
gpr_uint32 incoming_window_delta;
/** next stream id available at the time of beginning parsing */
gpr_uint32 next_stream_id;
gpr_uint32 last_incoming_stream_id;
/* deframing */
grpc_chttp2_deframe_transport_state deframe_state;
gpr_uint8 incoming_frame_type;
gpr_uint8 incoming_frame_flags;
gpr_uint8 header_eof;
gpr_uint32 expect_continuation_stream_id;
gpr_uint32 incoming_frame_size;
gpr_uint32 incoming_stream_id;
/* active parser */
void *parser_data;
grpc_chttp2_stream_parsing *incoming_stream;
grpc_chttp2_parse_error (*parser)(
void *parser_user_data, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last);
/* received settings */
gpr_uint32 settings[GRPC_CHTTP2_NUM_SETTINGS];
/* goaway data */
grpc_status_code goaway_error;
gpr_uint32 goaway_last_stream_index;
gpr_slice goaway_text;
gpr_uint64 outgoing_window_update;
/** pings awaiting responses */
grpc_chttp2_outstanding_ping pings;
};
struct grpc_chttp2_transport {
grpc_transport base; /* must be first */
grpc_endpoint *ep;
grpc_mdctx *metadata_context;
gpr_refcount refs;
gpr_mu mu;
/** is the transport destroying itself? */
gpr_uint8 destroying;
/** has the upper layer closed the transport? */
gpr_uint8 closed;
/** is a thread currently writing */
gpr_uint8 writing_active;
/** is a thread currently parsing */
gpr_uint8 parsing_active;
/** is there a read request to the endpoint outstanding? */
gpr_uint8 endpoint_reading;
/** various lists of streams */
grpc_chttp2_stream_list lists[STREAM_LIST_COUNT];
/** global state for reading/writing */
grpc_chttp2_transport_global global;
/** state only accessible by the chain of execution that
set writing_active=1 */
grpc_chttp2_transport_writing writing;
/** state only accessible by the chain of execution that
set parsing_active=1 */
grpc_chttp2_transport_parsing parsing;
/** maps stream id to grpc_chttp2_stream objects;
owned by the parsing thread when parsing */
grpc_chttp2_stream_map parsing_stream_map;
/** streams created by the client (possibly during parsing);
merged with parsing_stream_map during unlock when no
parsing is occurring */
grpc_chttp2_stream_map new_stream_map;
/** closure to execute writing */
grpc_iomgr_closure writing_action;
/** closure to start reading from the endpoint */
grpc_iomgr_closure reading_action;
/** address to place a newly accepted stream - set and unset by
grpc_chttp2_parsing_accept_stream; used by init_stream to
publish the accepted server stream */
grpc_chttp2_stream **accepting_stream;
struct {
/** is a thread currently performing channel callbacks */
gpr_uint8 executing;
/** transport channel-level callback */
const grpc_transport_callbacks *cb;
/** user data for cb calls */
void *cb_user_data;
/** closure for notifying transport closure */
grpc_iomgr_closure notify_closed;
} channel_callback;
};
typedef struct {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
gpr_uint32 id;
grpc_iomgr_closure *send_done_closure;
grpc_iomgr_closure *recv_done_closure;
/** window available for us to send to peer */
gpr_int64 outgoing_window;
/** window available for peer to send to us - updated after parse */
gpr_uint32 incoming_window;
/** stream ops the transport user would like to send */
grpc_stream_op_buffer *outgoing_sopb;
/** when the application requests writes be closed, the write_closed is
'queued'; when the close is flow controlled into the send path, we are
'sending' it; when the write has been performed it is 'sent' */
grpc_chttp2_write_state write_state;
/** is this stream closed (boolean) */
gpr_uint8 read_closed;
/** has this stream been cancelled? (boolean) */
gpr_uint8 cancelled;
grpc_status_code cancelled_status;
/** have we told the upper layer that this stream is cancelled? */
gpr_uint8 published_cancelled;
/** is this stream in the stream map? (boolean) */
gpr_uint8 in_stream_map;
/** stream state already published to the upper layer */
grpc_stream_state published_state;
/** address to publish next stream state to */
grpc_stream_state *publish_state;
/** pointer to sop buffer to fill in with new stream ops */
grpc_stream_op_buffer *publish_sopb;
grpc_stream_op_buffer incoming_sopb;
/** incoming metadata */
grpc_chttp2_incoming_metadata_buffer incoming_metadata;
grpc_chttp2_incoming_metadata_live_op_buffer outstanding_metadata;
} grpc_chttp2_stream_global;
typedef struct {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
gpr_uint32 id;
/** sops that have passed flow control to be written */
grpc_stream_op_buffer sopb;
/** how strongly should we indicate closure with the next write */
grpc_chttp2_send_closed send_closed;
} grpc_chttp2_stream_writing;
struct grpc_chttp2_stream_parsing {
/** HTTP2 stream id for this stream, or zero if one has not been assigned */
gpr_uint32 id;
/** has this stream received a close */
gpr_uint8 received_close;
/** saw a rst_stream */
gpr_uint8 saw_rst_stream;
/** incoming_window has been reduced by this much during parsing */
gpr_uint32 incoming_window_delta;
/** window available for peer to send to us */
gpr_uint32 incoming_window;
/** parsing state for data frames */
grpc_chttp2_data_parser data_parser;
/** reason give to rst_stream */
gpr_uint32 rst_stream_reason;
/* amount of window given */
gpr_uint64 outgoing_window_update;
/** incoming metadata */
grpc_chttp2_incoming_metadata_buffer incoming_metadata;
};
struct grpc_chttp2_stream {
grpc_chttp2_stream_global global;
grpc_chttp2_stream_writing writing;
grpc_chttp2_stream_parsing parsing;
grpc_chttp2_stream_link links[STREAM_LIST_COUNT];
gpr_uint8 included[STREAM_LIST_COUNT];
};
/** Transport writing call flow:
chttp2_transport.c calls grpc_chttp2_unlocking_check_writes to see if writes
are required;
if they are, chttp2_transport.c calls grpc_chttp2_perform_writes to do the
writes.
Once writes have been completed (meaning another write could potentially be
started),
grpc_chttp2_terminate_writing is called. This will call
grpc_chttp2_cleanup_writing, at which
point the write phase is complete. */
/** Someone is unlocking the transport mutex: check to see if writes
are required, and schedule them if so */
int grpc_chttp2_unlocking_check_writes(grpc_chttp2_transport_global *global,
grpc_chttp2_transport_writing *writing);
void grpc_chttp2_perform_writes(
grpc_chttp2_transport_writing *transport_writing, grpc_endpoint *endpoint);
void grpc_chttp2_terminate_writing(
grpc_chttp2_transport_writing *transport_writing, int success);
void grpc_chttp2_cleanup_writing(grpc_chttp2_transport_global *global,
grpc_chttp2_transport_writing *writing);
void grpc_chttp2_prepare_to_read(grpc_chttp2_transport_global *global,
grpc_chttp2_transport_parsing *parsing);
/** Process one slice of incoming data; return 1 if the connection is still
viable after reading, or 0 if the connection should be torn down */
int grpc_chttp2_perform_read(grpc_chttp2_transport_parsing *transport_parsing,
gpr_slice slice);
void grpc_chttp2_publish_reads(grpc_chttp2_transport_global *global,
grpc_chttp2_transport_parsing *parsing);
/** Get a writable stream
returns non-zero if there was a stream available */
void grpc_chttp2_list_add_writable_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
int grpc_chttp2_list_pop_writable_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_global **stream_global,
grpc_chttp2_stream_writing **stream_writing);
void grpc_chttp2_list_add_incoming_window_updated(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
int grpc_chttp2_list_pop_incoming_window_updated(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_global **stream_global,
grpc_chttp2_stream_parsing **stream_parsing);
void grpc_chttp2_list_remove_incoming_window_updated(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
void grpc_chttp2_list_add_writing_stream(
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_writing *stream_writing);
int grpc_chttp2_list_have_writing_streams(
grpc_chttp2_transport_writing *transport_writing);
int grpc_chttp2_list_pop_writing_stream(
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_writing **stream_writing);
void grpc_chttp2_list_add_written_stream(
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_writing *stream_writing);
int grpc_chttp2_list_pop_written_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_global **stream_global,
grpc_chttp2_stream_writing **stream_writing);
void grpc_chttp2_list_add_writable_window_update_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
int grpc_chttp2_list_pop_writable_window_update_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global);
void grpc_chttp2_list_remove_writable_window_update_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
void grpc_chttp2_list_add_parsing_seen_stream(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing);
int grpc_chttp2_list_pop_parsing_seen_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_global **stream_global,
grpc_chttp2_stream_parsing **stream_parsing);
void grpc_chttp2_list_add_waiting_for_concurrency(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
int grpc_chttp2_list_pop_waiting_for_concurrency(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global);
void grpc_chttp2_list_add_closed_waiting_for_parsing(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
int grpc_chttp2_list_pop_closed_waiting_for_parsing(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global);
void grpc_chttp2_list_add_read_write_state_changed(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global);
int grpc_chttp2_list_pop_read_write_state_changed(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global);
/** schedule a closure to run without the transport lock taken */
void grpc_chttp2_schedule_closure(
grpc_chttp2_transport_global *transport_global, grpc_iomgr_closure *closure,
int success);
grpc_chttp2_stream_parsing *grpc_chttp2_parsing_lookup_stream(
grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id);
grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream(
grpc_chttp2_transport_parsing *transport_parsing, gpr_uint32 id);
void grpc_chttp2_add_incoming_goaway(
grpc_chttp2_transport_global *transport_global, gpr_uint32 goaway_error,
gpr_slice goaway_text);
void grpc_chttp2_register_stream(grpc_chttp2_transport *t,
grpc_chttp2_stream *s);
void grpc_chttp2_unregister_stream(grpc_chttp2_transport *t,
grpc_chttp2_stream *s);
void grpc_chttp2_for_all_streams(
grpc_chttp2_transport_global *transport_global, void *user_data,
void (*cb)(grpc_chttp2_transport_global *transport_global, void *user_data,
grpc_chttp2_stream_global *stream_global));
void grpc_chttp2_parsing_become_skip_parser(
grpc_chttp2_transport_parsing *transport_parsing);
#define GRPC_CHTTP2_CLIENT_CONNECT_STRING "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
#define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \
(sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1)
extern int grpc_http_trace;
extern int grpc_flowctl_trace;
#define GRPC_CHTTP2_IF_TRACING(stmt) \
if (!(grpc_http_trace)) \
; \
else \
stmt
#define GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(reason, transport, context, var, \
delta) \
if (!(grpc_flowctl_trace)) { \
} else { \
grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \
transport->is_client, context->id, context->var, \
delta); \
}
#define GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(reason, context, var, delta) \
if (!(grpc_flowctl_trace)) { \
} else { \
grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \
context->is_client, 0, context->var, delta); \
}
void grpc_chttp2_flowctl_trace(const char *file, int line, const char *reason,
const char *context, const char *var,
int is_client, gpr_uint32 stream_id,
gpr_int64 current_value, gpr_int64 delta);
#endif

@ -0,0 +1,813 @@
/*
*
* 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/transport/chttp2/internal.h"
#include <string.h>
#include "src/core/transport/chttp2/http2_errors.h"
#include "src/core/transport/chttp2/status_conversion.h"
#include "src/core/transport/chttp2/timeout_encoding.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
static int init_frame_parser(grpc_chttp2_transport_parsing *transport_parsing);
static int init_header_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing, int is_continuation);
static int init_data_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing);
static int init_rst_stream_parser(
grpc_chttp2_transport_parsing *transport_parsing);
static int init_settings_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing);
static int init_window_update_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing);
static int init_ping_parser(grpc_chttp2_transport_parsing *transport_parsing);
static int init_goaway_parser(grpc_chttp2_transport_parsing *transport_parsing);
static int init_skip_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing, int is_header);
static int parse_frame_slice(grpc_chttp2_transport_parsing *transport_parsing,
gpr_slice slice, int is_last);
void grpc_chttp2_prepare_to_read(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_parsing *transport_parsing) {
grpc_chttp2_stream_global *stream_global;
grpc_chttp2_stream_parsing *stream_parsing;
transport_parsing->next_stream_id = transport_global->next_stream_id;
/* update the parsing view of incoming window */
if (transport_parsing->incoming_window != transport_global->incoming_window) {
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(
"parse", transport_parsing, incoming_window,
(gpr_int64)transport_global->incoming_window -
(gpr_int64)transport_parsing->incoming_window);
transport_parsing->incoming_window = transport_global->incoming_window;
}
while (grpc_chttp2_list_pop_incoming_window_updated(
transport_global, transport_parsing, &stream_global, &stream_parsing)) {
stream_parsing->id = stream_global->id;
if (stream_parsing->incoming_window != stream_global->incoming_window) {
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(
"parse", transport_parsing, stream_parsing, incoming_window,
(gpr_int64)stream_global->incoming_window -
(gpr_int64)stream_parsing->incoming_window);
stream_parsing->incoming_window = stream_global->incoming_window;
}
}
}
void grpc_chttp2_publish_reads(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_parsing *transport_parsing) {
grpc_chttp2_stream_global *stream_global;
grpc_chttp2_stream_parsing *stream_parsing;
/* transport_parsing->last_incoming_stream_id is used as
last-grpc_chttp2_stream-id when
sending GOAWAY frame.
https://tools.ietf.org/html/draft-ietf-httpbis-http2-17#section-6.8
says that last-grpc_chttp2_stream-id is peer-initiated grpc_chttp2_stream
ID. So,
since we don't have server pushed streams, client should send
GOAWAY last-grpc_chttp2_stream-id=0 in this case. */
if (!transport_parsing->is_client) {
transport_global->last_incoming_stream_id =
transport_parsing->incoming_stream_id;
}
/* TODO(ctiller): re-implement */
GPR_ASSERT(transport_parsing->initial_window_update == 0);
/* copy parsing qbuf to global qbuf */
gpr_slice_buffer_move_into(&transport_parsing->qbuf, &transport_global->qbuf);
/* update global settings */
if (transport_parsing->settings_updated) {
memcpy(transport_global->settings[GRPC_PEER_SETTINGS],
transport_parsing->settings, sizeof(transport_parsing->settings));
transport_parsing->settings_updated = 0;
}
/* update settings based on ack if received */
if (transport_parsing->settings_ack_received) {
memcpy(transport_global->settings[GRPC_ACKED_SETTINGS],
transport_global->settings[GRPC_SENT_SETTINGS],
GRPC_CHTTP2_NUM_SETTINGS * sizeof(gpr_uint32));
transport_parsing->settings_ack_received = 0;
}
/* move goaway to the global state if we received one (it will be
published later */
if (transport_parsing->goaway_received) {
grpc_chttp2_add_incoming_goaway(transport_global,
transport_parsing->goaway_error,
transport_parsing->goaway_text);
transport_parsing->goaway_text = gpr_empty_slice();
transport_parsing->goaway_received = 0;
}
/* propagate flow control tokens to global state */
if (transport_parsing->outgoing_window_update) {
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(
"parsed", transport_global, outgoing_window,
transport_parsing->outgoing_window_update);
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(
"parsed", transport_parsing, outgoing_window_update,
-(gpr_int64)transport_parsing->outgoing_window_update);
transport_global->outgoing_window +=
transport_parsing->outgoing_window_update;
transport_parsing->outgoing_window_update = 0;
}
if (transport_parsing->incoming_window_delta) {
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(
"parsed", transport_global, incoming_window,
-(gpr_int64)transport_parsing->incoming_window_delta);
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(
"parsed", transport_parsing, incoming_window_delta,
-(gpr_int64)transport_parsing->incoming_window_delta);
transport_global->incoming_window -=
transport_parsing->incoming_window_delta;
transport_parsing->incoming_window_delta = 0;
}
/* for each stream that saw an update, fixup global state */
while (grpc_chttp2_list_pop_parsing_seen_stream(
transport_global, transport_parsing, &stream_global, &stream_parsing)) {
/* update incoming flow control window */
if (stream_parsing->incoming_window_delta) {
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(
"parsed", transport_parsing, stream_global, incoming_window,
-(gpr_int64)stream_parsing->incoming_window_delta);
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(
"parsed", transport_parsing, stream_parsing, incoming_window_delta,
-(gpr_int64)stream_parsing->incoming_window_delta);
stream_global->incoming_window -= stream_parsing->incoming_window_delta;
stream_parsing->incoming_window_delta = 0;
grpc_chttp2_list_add_writable_window_update_stream(transport_global,
stream_global);
}
/* update outgoing flow control window */
if (stream_parsing->outgoing_window_update) {
int was_zero = stream_global->outgoing_window <= 0;
int is_zero;
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM("parsed", transport_parsing,
stream_global, outgoing_window,
stream_parsing->outgoing_window_update);
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(
"parsed", transport_parsing, stream_parsing, outgoing_window_update,
-(gpr_int64)stream_parsing->outgoing_window_update);
stream_global->outgoing_window += stream_parsing->outgoing_window_update;
stream_parsing->outgoing_window_update = 0;
is_zero = stream_global->outgoing_window <= 0;
if (was_zero && !is_zero) {
grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
}
}
/* updating closed status */
if (stream_parsing->received_close) {
stream_global->read_closed = 1;
grpc_chttp2_list_add_read_write_state_changed(transport_global,
stream_global);
}
if (stream_parsing->saw_rst_stream) {
stream_global->cancelled = 1;
stream_global->cancelled_status = grpc_chttp2_http2_error_to_grpc_status(stream_parsing->rst_stream_reason);
if (stream_parsing->rst_stream_reason == GRPC_CHTTP2_NO_ERROR) {
stream_global->published_cancelled = 1;
}
grpc_chttp2_list_add_read_write_state_changed(transport_global,
stream_global);
}
/* publish incoming stream ops */
if (stream_parsing->data_parser.incoming_sopb.nops > 0) {
grpc_incoming_metadata_buffer_move_to_referencing_sopb(
&stream_parsing->incoming_metadata, &stream_global->incoming_metadata,
&stream_parsing->data_parser.incoming_sopb);
grpc_sopb_move_to(&stream_parsing->data_parser.incoming_sopb,
&stream_global->incoming_sopb);
grpc_chttp2_list_add_read_write_state_changed(transport_global,
stream_global);
}
}
}
int grpc_chttp2_perform_read(grpc_chttp2_transport_parsing *transport_parsing,
gpr_slice slice) {
gpr_uint8 *beg = GPR_SLICE_START_PTR(slice);
gpr_uint8 *end = GPR_SLICE_END_PTR(slice);
gpr_uint8 *cur = beg;
if (cur == end) return 1;
switch (transport_parsing->deframe_state) {
case GRPC_DTS_CLIENT_PREFIX_0:
case GRPC_DTS_CLIENT_PREFIX_1:
case GRPC_DTS_CLIENT_PREFIX_2:
case GRPC_DTS_CLIENT_PREFIX_3:
case GRPC_DTS_CLIENT_PREFIX_4:
case GRPC_DTS_CLIENT_PREFIX_5:
case GRPC_DTS_CLIENT_PREFIX_6:
case GRPC_DTS_CLIENT_PREFIX_7:
case GRPC_DTS_CLIENT_PREFIX_8:
case GRPC_DTS_CLIENT_PREFIX_9:
case GRPC_DTS_CLIENT_PREFIX_10:
case GRPC_DTS_CLIENT_PREFIX_11:
case GRPC_DTS_CLIENT_PREFIX_12:
case GRPC_DTS_CLIENT_PREFIX_13:
case GRPC_DTS_CLIENT_PREFIX_14:
case GRPC_DTS_CLIENT_PREFIX_15:
case GRPC_DTS_CLIENT_PREFIX_16:
case GRPC_DTS_CLIENT_PREFIX_17:
case GRPC_DTS_CLIENT_PREFIX_18:
case GRPC_DTS_CLIENT_PREFIX_19:
case GRPC_DTS_CLIENT_PREFIX_20:
case GRPC_DTS_CLIENT_PREFIX_21:
case GRPC_DTS_CLIENT_PREFIX_22:
case GRPC_DTS_CLIENT_PREFIX_23:
while (cur != end && transport_parsing->deframe_state != GRPC_DTS_FH_0) {
if (*cur != GRPC_CHTTP2_CLIENT_CONNECT_STRING[transport_parsing
->deframe_state]) {
gpr_log(GPR_INFO,
"Connect string mismatch: expected '%c' (%d) got '%c' (%d) "
"at byte %d",
GRPC_CHTTP2_CLIENT_CONNECT_STRING[transport_parsing
->deframe_state],
(int)(gpr_uint8)GRPC_CHTTP2_CLIENT_CONNECT_STRING
[transport_parsing->deframe_state],
*cur, (int)*cur, transport_parsing->deframe_state);
return 0;
}
++cur;
++transport_parsing->deframe_state;
}
if (cur == end) {
return 1;
}
/* fallthrough */
dts_fh_0:
case GRPC_DTS_FH_0:
GPR_ASSERT(cur < end);
transport_parsing->incoming_frame_size = ((gpr_uint32)*cur) << 16;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_1;
return 1;
}
/* fallthrough */
case GRPC_DTS_FH_1:
GPR_ASSERT(cur < end);
transport_parsing->incoming_frame_size |= ((gpr_uint32)*cur) << 8;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_2;
return 1;
}
/* fallthrough */
case GRPC_DTS_FH_2:
GPR_ASSERT(cur < end);
transport_parsing->incoming_frame_size |= *cur;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_3;
return 1;
}
/* fallthrough */
case GRPC_DTS_FH_3:
GPR_ASSERT(cur < end);
transport_parsing->incoming_frame_type = *cur;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_4;
return 1;
}
/* fallthrough */
case GRPC_DTS_FH_4:
GPR_ASSERT(cur < end);
transport_parsing->incoming_frame_flags = *cur;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_5;
return 1;
}
/* fallthrough */
case GRPC_DTS_FH_5:
GPR_ASSERT(cur < end);
transport_parsing->incoming_stream_id = (((gpr_uint32)*cur) & 0x7f) << 24;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_6;
return 1;
}
/* fallthrough */
case GRPC_DTS_FH_6:
GPR_ASSERT(cur < end);
transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur) << 16;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_7;
return 1;
}
/* fallthrough */
case GRPC_DTS_FH_7:
GPR_ASSERT(cur < end);
transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur) << 8;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_8;
return 1;
}
/* fallthrough */
case GRPC_DTS_FH_8:
GPR_ASSERT(cur < end);
transport_parsing->incoming_stream_id |= ((gpr_uint32)*cur);
transport_parsing->deframe_state = GRPC_DTS_FRAME;
if (!init_frame_parser(transport_parsing)) {
return 0;
}
if (transport_parsing->incoming_stream_id) {
transport_parsing->last_incoming_stream_id =
transport_parsing->incoming_stream_id;
}
if (transport_parsing->incoming_frame_size == 0) {
if (!parse_frame_slice(transport_parsing, gpr_empty_slice(), 1)) {
return 0;
}
transport_parsing->incoming_stream = NULL;
if (++cur == end) {
transport_parsing->deframe_state = GRPC_DTS_FH_0;
return 1;
}
goto dts_fh_0; /* loop */
}
if (++cur == end) {
return 1;
}
/* fallthrough */
case GRPC_DTS_FRAME:
GPR_ASSERT(cur < end);
if ((gpr_uint32)(end - cur) == transport_parsing->incoming_frame_size) {
if (!parse_frame_slice(
transport_parsing,
gpr_slice_sub_no_ref(slice, cur - beg, end - beg), 1)) {
return 0;
}
transport_parsing->deframe_state = GRPC_DTS_FH_0;
transport_parsing->incoming_stream = NULL;
return 1;
} else if ((gpr_uint32)(end - cur) >
transport_parsing->incoming_frame_size) {
if (!parse_frame_slice(
transport_parsing,
gpr_slice_sub_no_ref(
slice, cur - beg,
cur + transport_parsing->incoming_frame_size - beg),
1)) {
return 0;
}
cur += transport_parsing->incoming_frame_size;
transport_parsing->incoming_stream = NULL;
goto dts_fh_0; /* loop */
} else {
if (!parse_frame_slice(
transport_parsing,
gpr_slice_sub_no_ref(slice, cur - beg, end - beg), 0)) {
return 0;
}
transport_parsing->incoming_frame_size -= (end - cur);
return 1;
}
gpr_log(GPR_ERROR, "should never reach here");
abort();
}
gpr_log(GPR_ERROR, "should never reach here");
abort();
return 0;
}
static int init_frame_parser(grpc_chttp2_transport_parsing *transport_parsing) {
if (transport_parsing->expect_continuation_stream_id != 0) {
if (transport_parsing->incoming_frame_type !=
GRPC_CHTTP2_FRAME_CONTINUATION) {
gpr_log(GPR_ERROR, "Expected CONTINUATION frame, got frame type %02x",
transport_parsing->incoming_frame_type);
return 0;
}
if (transport_parsing->expect_continuation_stream_id !=
transport_parsing->incoming_stream_id) {
gpr_log(GPR_ERROR,
"Expected CONTINUATION frame for grpc_chttp2_stream %08x, got "
"grpc_chttp2_stream %08x",
transport_parsing->expect_continuation_stream_id,
transport_parsing->incoming_stream_id);
return 0;
}
return init_header_frame_parser(transport_parsing, 1);
}
switch (transport_parsing->incoming_frame_type) {
case GRPC_CHTTP2_FRAME_DATA:
return init_data_frame_parser(transport_parsing);
case GRPC_CHTTP2_FRAME_HEADER:
return init_header_frame_parser(transport_parsing, 0);
case GRPC_CHTTP2_FRAME_CONTINUATION:
gpr_log(GPR_ERROR, "Unexpected CONTINUATION frame");
return 0;
case GRPC_CHTTP2_FRAME_RST_STREAM:
return init_rst_stream_parser(transport_parsing);
case GRPC_CHTTP2_FRAME_SETTINGS:
return init_settings_frame_parser(transport_parsing);
case GRPC_CHTTP2_FRAME_WINDOW_UPDATE:
return init_window_update_frame_parser(transport_parsing);
case GRPC_CHTTP2_FRAME_PING:
return init_ping_parser(transport_parsing);
case GRPC_CHTTP2_FRAME_GOAWAY:
return init_goaway_parser(transport_parsing);
default:
gpr_log(GPR_ERROR, "Unknown frame type %02x",
transport_parsing->incoming_frame_type);
return init_skip_frame_parser(transport_parsing, 0);
}
}
static grpc_chttp2_parse_error skip_parser(
void *parser, grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing, gpr_slice slice, int is_last) {
return GRPC_CHTTP2_PARSE_OK;
}
static void skip_header(void *tp, grpc_mdelem *md) { grpc_mdelem_unref(md); }
static int init_skip_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing, int is_header) {
if (is_header) {
int is_eoh = transport_parsing->expect_continuation_stream_id != 0;
transport_parsing->parser = grpc_chttp2_header_parser_parse;
transport_parsing->parser_data = &transport_parsing->hpack_parser;
transport_parsing->hpack_parser.on_header = skip_header;
transport_parsing->hpack_parser.on_header_user_data = NULL;
transport_parsing->hpack_parser.is_boundary = is_eoh;
transport_parsing->hpack_parser.is_eof =
is_eoh ? transport_parsing->header_eof : 0;
} else {
transport_parsing->parser = skip_parser;
}
return 1;
}
void grpc_chttp2_parsing_become_skip_parser(
grpc_chttp2_transport_parsing *transport_parsing) {
init_skip_frame_parser(
transport_parsing,
transport_parsing->parser == grpc_chttp2_header_parser_parse);
}
static grpc_chttp2_parse_error update_incoming_window(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing) {
if (transport_parsing->incoming_frame_size >
transport_parsing->incoming_window) {
gpr_log(GPR_ERROR, "frame of size %d overflows incoming window of %d",
transport_parsing->incoming_frame_size,
transport_parsing->incoming_window);
return GRPC_CHTTP2_CONNECTION_ERROR;
}
if (transport_parsing->incoming_frame_size >
stream_parsing->incoming_window) {
gpr_log(GPR_ERROR, "frame of size %d overflows incoming window of %d",
transport_parsing->incoming_frame_size,
stream_parsing->incoming_window);
return GRPC_CHTTP2_CONNECTION_ERROR;
}
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(
"data", transport_parsing, incoming_window,
-(gpr_int64)transport_parsing->incoming_frame_size);
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT("data", transport_parsing,
incoming_window_delta,
transport_parsing->incoming_frame_size);
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(
"data", transport_parsing, stream_parsing, incoming_window,
-(gpr_int64)transport_parsing->incoming_frame_size);
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM("data", transport_parsing, stream_parsing,
incoming_window_delta,
transport_parsing->incoming_frame_size);
transport_parsing->incoming_window -= transport_parsing->incoming_frame_size;
transport_parsing->incoming_window_delta +=
transport_parsing->incoming_frame_size;
stream_parsing->incoming_window -= transport_parsing->incoming_frame_size;
stream_parsing->incoming_window_delta +=
transport_parsing->incoming_frame_size;
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing, stream_parsing);
return GRPC_CHTTP2_PARSE_OK;
}
static int init_data_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing) {
grpc_chttp2_stream_parsing *stream_parsing =
grpc_chttp2_parsing_lookup_stream(transport_parsing,
transport_parsing->incoming_stream_id);
grpc_chttp2_parse_error err = GRPC_CHTTP2_PARSE_OK;
if (!stream_parsing || stream_parsing->received_close)
return init_skip_frame_parser(transport_parsing, 0);
if (err == GRPC_CHTTP2_PARSE_OK) {
err = update_incoming_window(transport_parsing, stream_parsing);
}
if (err == GRPC_CHTTP2_PARSE_OK) {
err = grpc_chttp2_data_parser_begin_frame(
&stream_parsing->data_parser, transport_parsing->incoming_frame_flags);
}
switch (err) {
case GRPC_CHTTP2_PARSE_OK:
transport_parsing->incoming_stream = stream_parsing;
transport_parsing->parser = grpc_chttp2_data_parser_parse;
transport_parsing->parser_data = &stream_parsing->data_parser;
return 1;
case GRPC_CHTTP2_STREAM_ERROR:
stream_parsing->received_close = 1;
stream_parsing->saw_rst_stream = 1;
stream_parsing->rst_stream_reason = GRPC_CHTTP2_PROTOCOL_ERROR;
gpr_slice_buffer_add(
&transport_parsing->qbuf,
grpc_chttp2_rst_stream_create(transport_parsing->incoming_stream_id,
GRPC_CHTTP2_PROTOCOL_ERROR));
return init_skip_frame_parser(transport_parsing, 0);
case GRPC_CHTTP2_CONNECTION_ERROR:
return 0;
}
gpr_log(GPR_ERROR, "should never reach here");
abort();
return 0;
}
static void free_timeout(void *p) { gpr_free(p); }
static void on_header(void *tp, grpc_mdelem *md) {
grpc_chttp2_transport_parsing *transport_parsing = tp;
grpc_chttp2_stream_parsing *stream_parsing =
transport_parsing->incoming_stream;
GPR_ASSERT(stream_parsing);
GRPC_CHTTP2_IF_TRACING(gpr_log(
GPR_INFO, "HTTP:%d:HDR: %s: %s", stream_parsing->id,
transport_parsing->is_client ? "CLI" : "SVR",
grpc_mdstr_as_c_string(md->key), grpc_mdstr_as_c_string(md->value)));
if (md->key == transport_parsing->str_grpc_timeout) {
gpr_timespec *cached_timeout = grpc_mdelem_get_user_data(md, free_timeout);
if (!cached_timeout) {
/* not already parsed: parse it now, and store the result away */
cached_timeout = gpr_malloc(sizeof(gpr_timespec));
if (!grpc_chttp2_decode_timeout(grpc_mdstr_as_c_string(md->value),
cached_timeout)) {
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'",
grpc_mdstr_as_c_string(md->value));
*cached_timeout = gpr_inf_future;
}
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
}
grpc_chttp2_incoming_metadata_buffer_set_deadline(
&stream_parsing->incoming_metadata,
gpr_time_add(gpr_now(), *cached_timeout));
grpc_mdelem_unref(md);
} else {
grpc_chttp2_incoming_metadata_buffer_add(&stream_parsing->incoming_metadata,
md);
}
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing, stream_parsing);
}
static int init_header_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing, int is_continuation) {
int is_eoh = (transport_parsing->incoming_frame_flags &
GRPC_CHTTP2_DATA_FLAG_END_HEADERS) != 0;
int via_accept = 0;
grpc_chttp2_stream_parsing *stream_parsing;
if (is_eoh) {
transport_parsing->expect_continuation_stream_id = 0;
} else {
transport_parsing->expect_continuation_stream_id =
transport_parsing->incoming_stream_id;
}
if (!is_continuation) {
transport_parsing->header_eof = (transport_parsing->incoming_frame_flags &
GRPC_CHTTP2_DATA_FLAG_END_STREAM) != 0;
}
/* could be a new grpc_chttp2_stream or an existing grpc_chttp2_stream */
stream_parsing = grpc_chttp2_parsing_lookup_stream(
transport_parsing, transport_parsing->incoming_stream_id);
if (stream_parsing == NULL) {
if (is_continuation) {
gpr_log(GPR_ERROR,
"grpc_chttp2_stream disbanded before CONTINUATION received");
return init_skip_frame_parser(transport_parsing, 1);
}
if (transport_parsing->is_client) {
if ((transport_parsing->incoming_stream_id & 1) &&
transport_parsing->incoming_stream_id <
transport_parsing->next_stream_id) {
/* this is an old (probably cancelled) grpc_chttp2_stream */
} else {
gpr_log(GPR_ERROR,
"ignoring new grpc_chttp2_stream creation on client");
}
return init_skip_frame_parser(transport_parsing, 1);
} else if (transport_parsing->last_incoming_stream_id >
transport_parsing->incoming_stream_id) {
gpr_log(GPR_ERROR,
"ignoring out of order new grpc_chttp2_stream request on server; "
"last grpc_chttp2_stream "
"id=%d, new grpc_chttp2_stream id=%d",
transport_parsing->last_incoming_stream_id,
transport_parsing->incoming_stream_id);
return init_skip_frame_parser(transport_parsing, 1);
} else if ((transport_parsing->incoming_stream_id & 1) == 0) {
gpr_log(GPR_ERROR,
"ignoring grpc_chttp2_stream with non-client generated index %d",
transport_parsing->incoming_stream_id);
return init_skip_frame_parser(transport_parsing, 1);
}
stream_parsing = transport_parsing->incoming_stream =
grpc_chttp2_parsing_accept_stream(
transport_parsing, transport_parsing->incoming_stream_id);
if (stream_parsing == NULL) {
gpr_log(GPR_ERROR, "grpc_chttp2_stream not accepted");
return init_skip_frame_parser(transport_parsing, 1);
}
via_accept = 1;
} else {
transport_parsing->incoming_stream = stream_parsing;
}
GPR_ASSERT(stream_parsing != NULL && (via_accept == 0 || via_accept == 1));
if (stream_parsing->received_close) {
gpr_log(GPR_ERROR, "skipping already closed grpc_chttp2_stream header");
transport_parsing->incoming_stream = NULL;
return init_skip_frame_parser(transport_parsing, 1);
}
transport_parsing->parser = grpc_chttp2_header_parser_parse;
transport_parsing->parser_data = &transport_parsing->hpack_parser;
transport_parsing->hpack_parser.on_header = on_header;
transport_parsing->hpack_parser.on_header_user_data = transport_parsing;
transport_parsing->hpack_parser.is_boundary = is_eoh;
transport_parsing->hpack_parser.is_eof =
is_eoh ? transport_parsing->header_eof : 0;
if (!is_continuation && (transport_parsing->incoming_frame_flags &
GRPC_CHTTP2_FLAG_HAS_PRIORITY)) {
grpc_chttp2_hpack_parser_set_has_priority(&transport_parsing->hpack_parser);
}
return 1;
}
static int init_window_update_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing) {
int ok = GRPC_CHTTP2_PARSE_OK == grpc_chttp2_window_update_parser_begin_frame(
&transport_parsing->simple.window_update,
transport_parsing->incoming_frame_size,
transport_parsing->incoming_frame_flags);
if (transport_parsing->incoming_stream_id) {
transport_parsing->incoming_stream = grpc_chttp2_parsing_lookup_stream(
transport_parsing, transport_parsing->incoming_stream_id);
}
transport_parsing->parser = grpc_chttp2_window_update_parser_parse;
transport_parsing->parser_data = &transport_parsing->simple.window_update;
return ok;
}
static int init_ping_parser(grpc_chttp2_transport_parsing *transport_parsing) {
int ok = GRPC_CHTTP2_PARSE_OK == grpc_chttp2_ping_parser_begin_frame(
&transport_parsing->simple.ping,
transport_parsing->incoming_frame_size,
transport_parsing->incoming_frame_flags);
transport_parsing->parser = grpc_chttp2_ping_parser_parse;
transport_parsing->parser_data = &transport_parsing->simple.ping;
return ok;
}
static int init_rst_stream_parser(
grpc_chttp2_transport_parsing *transport_parsing) {
int ok = GRPC_CHTTP2_PARSE_OK == grpc_chttp2_rst_stream_parser_begin_frame(
&transport_parsing->simple.rst_stream,
transport_parsing->incoming_frame_size,
transport_parsing->incoming_frame_flags);
transport_parsing->incoming_stream = grpc_chttp2_parsing_lookup_stream(
transport_parsing, transport_parsing->incoming_stream_id);
if (!transport_parsing->incoming_stream) {
return init_skip_frame_parser(transport_parsing, 0);
}
transport_parsing->parser = grpc_chttp2_rst_stream_parser_parse;
transport_parsing->parser_data = &transport_parsing->simple.rst_stream;
return ok;
}
static int init_goaway_parser(
grpc_chttp2_transport_parsing *transport_parsing) {
int ok = GRPC_CHTTP2_PARSE_OK == grpc_chttp2_goaway_parser_begin_frame(
&transport_parsing->goaway_parser,
transport_parsing->incoming_frame_size,
transport_parsing->incoming_frame_flags);
transport_parsing->parser = grpc_chttp2_goaway_parser_parse;
transport_parsing->parser_data = &transport_parsing->goaway_parser;
return ok;
}
static int init_settings_frame_parser(
grpc_chttp2_transport_parsing *transport_parsing) {
int ok;
if (transport_parsing->incoming_stream_id != 0) {
gpr_log(GPR_ERROR, "settings frame received for grpc_chttp2_stream %d",
transport_parsing->incoming_stream_id);
return 0;
}
ok = GRPC_CHTTP2_PARSE_OK == grpc_chttp2_settings_parser_begin_frame(
&transport_parsing->simple.settings,
transport_parsing->incoming_frame_size,
transport_parsing->incoming_frame_flags,
transport_parsing->settings);
if (!ok) {
return 0;
}
if (transport_parsing->incoming_frame_flags & GRPC_CHTTP2_FLAG_ACK) {
transport_parsing->settings_ack_received = 1;
}
transport_parsing->parser = grpc_chttp2_settings_parser_parse;
transport_parsing->parser_data = &transport_parsing->simple.settings;
return ok;
}
/*
static int is_window_update_legal(gpr_int64 window_update, gpr_int64 window) {
return window + window_update < MAX_WINDOW;
}
*/
static int parse_frame_slice(grpc_chttp2_transport_parsing *transport_parsing,
gpr_slice slice, int is_last) {
grpc_chttp2_stream_parsing *stream_parsing =
transport_parsing->incoming_stream;
switch (transport_parsing->parser(transport_parsing->parser_data,
transport_parsing, stream_parsing, slice,
is_last)) {
case GRPC_CHTTP2_PARSE_OK:
if (stream_parsing) {
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
}
return 1;
case GRPC_CHTTP2_STREAM_ERROR:
grpc_chttp2_parsing_become_skip_parser(transport_parsing);
if (stream_parsing) {
stream_parsing->saw_rst_stream = 1;
stream_parsing->rst_stream_reason = GRPC_CHTTP2_PROTOCOL_ERROR;
gpr_slice_buffer_add(
&transport_parsing->qbuf,
grpc_chttp2_rst_stream_create(transport_parsing->incoming_stream_id,
GRPC_CHTTP2_PROTOCOL_ERROR));
}
return 1;
case GRPC_CHTTP2_CONNECTION_ERROR:
return 0;
}
gpr_log(GPR_ERROR, "should never reach here");
abort();
return 0;
}

@ -0,0 +1,352 @@
/*
*
* 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/transport/chttp2/internal.h"
#include <grpc/support/log.h>
#define TRANSPORT_FROM_GLOBAL(tg) \
((grpc_chttp2_transport *)((char *)(tg)-offsetof(grpc_chttp2_transport, \
global)))
#define STREAM_FROM_GLOBAL(sg) \
((grpc_chttp2_stream *)((char *)(sg)-offsetof(grpc_chttp2_stream, global)))
#define TRANSPORT_FROM_WRITING(tw) \
((grpc_chttp2_transport *)((char *)(tw)-offsetof(grpc_chttp2_transport, \
writing)))
#define STREAM_FROM_WRITING(sw) \
((grpc_chttp2_stream *)((char *)(sw)-offsetof(grpc_chttp2_stream, writing)))
#define TRANSPORT_FROM_PARSING(tp) \
((grpc_chttp2_transport *)((char *)(tp)-offsetof(grpc_chttp2_transport, \
parsing)))
#define STREAM_FROM_PARSING(sp) \
((grpc_chttp2_stream *)((char *)(sp)-offsetof(grpc_chttp2_stream, parsing)))
/* core list management */
static int stream_list_empty(grpc_chttp2_transport *t,
grpc_chttp2_stream_list_id id) {
return t->lists[id].head == NULL;
}
static int stream_list_pop(grpc_chttp2_transport *t,
grpc_chttp2_stream **stream,
grpc_chttp2_stream_list_id id) {
grpc_chttp2_stream *s = t->lists[id].head;
if (s) {
grpc_chttp2_stream *new_head = s->links[id].next;
GPR_ASSERT(s->included[id]);
if (new_head) {
t->lists[id].head = new_head;
new_head->links[id].prev = NULL;
} else {
t->lists[id].head = NULL;
t->lists[id].tail = NULL;
}
s->included[id] = 0;
}
*stream = s;
return s != 0;
}
static void stream_list_remove(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
grpc_chttp2_stream_list_id id) {
GPR_ASSERT(s->included[id]);
s->included[id] = 0;
if (s->links[id].prev) {
s->links[id].prev->links[id].next = s->links[id].next;
} else {
GPR_ASSERT(t->lists[id].head == s);
t->lists[id].head = s->links[id].next;
}
if (s->links[id].next) {
s->links[id].next->links[id].prev = s->links[id].prev;
} else {
t->lists[id].tail = s->links[id].prev;
}
}
static void stream_list_maybe_remove(grpc_chttp2_transport *t,
grpc_chttp2_stream *s,
grpc_chttp2_stream_list_id id) {
if (s->included[id]) {
stream_list_remove(t, s, id);
}
}
static void stream_list_add_tail(grpc_chttp2_transport *t,
grpc_chttp2_stream *s,
grpc_chttp2_stream_list_id id) {
grpc_chttp2_stream *old_tail;
GPR_ASSERT(!s->included[id]);
old_tail = t->lists[id].tail;
s->links[id].next = NULL;
s->links[id].prev = old_tail;
if (old_tail) {
old_tail->links[id].next = s;
} else {
s->links[id].prev = NULL;
t->lists[id].head = s;
}
t->lists[id].tail = s;
s->included[id] = 1;
}
static void stream_list_add(grpc_chttp2_transport *t, grpc_chttp2_stream *s,
grpc_chttp2_stream_list_id id) {
if (s->included[id]) {
return;
}
stream_list_add_tail(t, s, id);
}
/* wrappers for specializations */
void grpc_chttp2_list_add_writable_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global),
STREAM_FROM_GLOBAL(stream_global), GRPC_CHTTP2_LIST_WRITABLE);
}
int grpc_chttp2_list_pop_writable_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_global **stream_global,
grpc_chttp2_stream_writing **stream_writing) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_WRITABLE);
*stream_global = &stream->global;
*stream_writing = &stream->writing;
return r;
}
void grpc_chttp2_list_add_writing_stream(
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_writing *stream_writing) {
stream_list_add(TRANSPORT_FROM_WRITING(transport_writing),
STREAM_FROM_WRITING(stream_writing),
GRPC_CHTTP2_LIST_WRITING);
}
int grpc_chttp2_list_have_writing_streams(
grpc_chttp2_transport_writing *transport_writing) {
return !stream_list_empty(TRANSPORT_FROM_WRITING(transport_writing),
GRPC_CHTTP2_LIST_WRITING);
}
int grpc_chttp2_list_pop_writing_stream(
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_writing **stream_writing) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_WRITING(transport_writing), &stream,
GRPC_CHTTP2_LIST_WRITING);
*stream_writing = &stream->writing;
return r;
}
void grpc_chttp2_list_add_written_stream(
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_writing *stream_writing) {
stream_list_add(TRANSPORT_FROM_WRITING(transport_writing),
STREAM_FROM_WRITING(stream_writing),
GRPC_CHTTP2_LIST_WRITTEN);
}
int grpc_chttp2_list_pop_written_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_writing *transport_writing,
grpc_chttp2_stream_global **stream_global,
grpc_chttp2_stream_writing **stream_writing) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_WRITING(transport_writing), &stream,
GRPC_CHTTP2_LIST_WRITTEN);
*stream_global = &stream->global;
*stream_writing = &stream->writing;
return r;
}
void grpc_chttp2_list_add_writable_window_update_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global),
STREAM_FROM_GLOBAL(stream_global),
GRPC_CHTTP2_LIST_WRITABLE_WINDOW_UPDATE);
}
int grpc_chttp2_list_pop_writable_window_update_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_WRITABLE_WINDOW_UPDATE);
*stream_global = &stream->global;
return r;
}
void grpc_chttp2_list_remove_writable_window_update_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global), STREAM_FROM_GLOBAL(stream_global), GRPC_CHTTP2_LIST_WRITABLE_WINDOW_UPDATE);
}
void grpc_chttp2_list_add_parsing_seen_stream(
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_parsing *stream_parsing) {
stream_list_add(TRANSPORT_FROM_PARSING(transport_parsing),
STREAM_FROM_PARSING(stream_parsing),
GRPC_CHTTP2_LIST_PARSING_SEEN);
}
int grpc_chttp2_list_pop_parsing_seen_stream(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_global **stream_global,
grpc_chttp2_stream_parsing **stream_parsing) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_PARSING(transport_parsing), &stream,
GRPC_CHTTP2_LIST_PARSING_SEEN);
*stream_global = &stream->global;
*stream_parsing = &stream->parsing;
return r;
}
void grpc_chttp2_list_add_waiting_for_concurrency(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global),
STREAM_FROM_GLOBAL(stream_global),
GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
}
int grpc_chttp2_list_pop_waiting_for_concurrency(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY);
*stream_global = &stream->global;
return r;
}
void grpc_chttp2_list_add_closed_waiting_for_parsing(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global),
STREAM_FROM_GLOBAL(stream_global),
GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_PARSING);
}
int grpc_chttp2_list_pop_closed_waiting_for_parsing(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_PARSING);
*stream_global = &stream->global;
return r;
}
void grpc_chttp2_list_add_incoming_window_updated(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global),
STREAM_FROM_GLOBAL(stream_global),
GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED);
}
int grpc_chttp2_list_pop_incoming_window_updated(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_parsing *transport_parsing,
grpc_chttp2_stream_global **stream_global,
grpc_chttp2_stream_parsing **stream_parsing) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED);
*stream_global = &stream->global;
*stream_parsing = &stream->parsing;
return r;
}
void grpc_chttp2_list_remove_incoming_window_updated(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
stream_list_maybe_remove(TRANSPORT_FROM_GLOBAL(transport_global),
STREAM_FROM_GLOBAL(stream_global),
GRPC_CHTTP2_LIST_INCOMING_WINDOW_UPDATED);
}
void grpc_chttp2_list_add_read_write_state_changed(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global) {
stream_list_add(TRANSPORT_FROM_GLOBAL(transport_global),
STREAM_FROM_GLOBAL(stream_global),
GRPC_CHTTP2_LIST_READ_WRITE_STATE_CHANGED);
}
int grpc_chttp2_list_pop_read_write_state_changed(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global **stream_global) {
grpc_chttp2_stream *stream;
int r = stream_list_pop(TRANSPORT_FROM_GLOBAL(transport_global), &stream,
GRPC_CHTTP2_LIST_READ_WRITE_STATE_CHANGED);
*stream_global = &stream->global;
return r;
}
void grpc_chttp2_register_stream(grpc_chttp2_transport *t,
grpc_chttp2_stream *s) {
stream_list_add_tail(t, s, GRPC_CHTTP2_LIST_ALL_STREAMS);
}
void grpc_chttp2_unregister_stream(grpc_chttp2_transport *t,
grpc_chttp2_stream *s) {
stream_list_remove(t, s, GRPC_CHTTP2_LIST_ALL_STREAMS);
}
void grpc_chttp2_for_all_streams(
grpc_chttp2_transport_global *transport_global, void *user_data,
void (*cb)(grpc_chttp2_transport_global *transport_global, void *user_data,
grpc_chttp2_stream_global *stream_global)) {
grpc_chttp2_stream *s;
grpc_chttp2_transport *t = TRANSPORT_FROM_GLOBAL(transport_global);
for (s = t->lists[GRPC_CHTTP2_LIST_ALL_STREAMS].head; s != NULL;
s = s->links[GRPC_CHTTP2_LIST_ALL_STREAMS].next) {
cb(transport_global, user_data, &s->global);
}
}

@ -32,8 +32,12 @@
*/ */
#include "src/core/transport/chttp2/stream_map.h" #include "src/core/transport/chttp2/stream_map.h"
#include <string.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/useful.h>
void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map, void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map,
size_t initial_capacity) { size_t initial_capacity) {
@ -92,6 +96,41 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, gpr_uint32 key,
map->count = count + 1; map->count = count + 1;
} }
void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
grpc_chttp2_stream_map *dst) {
/* if src is empty we dont need to do anything */
if (src->count == src->free) {
return;
}
/* if dst is empty we simply need to swap */
if (dst->count == dst->free) {
GPR_SWAP(grpc_chttp2_stream_map, *src, *dst);
return;
}
/* the first element of src must be greater than the last of dst...
* however the maps may need compacting for this property to hold */
if (src->keys[0] <= dst->keys[dst->count - 1]) {
src->count = compact(src->keys, src->values, src->count);
src->free = 0;
dst->count = compact(dst->keys, dst->values, dst->count);
dst->free = 0;
}
GPR_ASSERT(src->keys[0] > dst->keys[dst->count - 1]);
/* if dst doesn't have capacity, resize */
if (dst->count + src->count > dst->capacity) {
dst->capacity = GPR_MAX(dst->capacity * 3 / 2, dst->count + src->count);
dst->keys = gpr_realloc(dst->keys, dst->capacity * sizeof(gpr_uint32));
dst->values = gpr_realloc(dst->values, dst->capacity * sizeof(void *));
}
memcpy(dst->keys + dst->count, src->keys, src->count * sizeof(gpr_uint32));
memcpy(dst->values + dst->count, src->values,
src->count * sizeof(void*));
dst->count += src->count;
dst->free += src->free;
src->count = 0;
src->free = 0;
}
static void **find(grpc_chttp2_stream_map *map, gpr_uint32 key) { static void **find(grpc_chttp2_stream_map *map, gpr_uint32 key) {
size_t min_idx = 0; size_t min_idx = 0;
size_t max_idx = map->count; size_t max_idx = map->count;
@ -127,6 +166,11 @@ void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map,
out = *pvalue; out = *pvalue;
*pvalue = NULL; *pvalue = NULL;
map->free += (out != NULL); map->free += (out != NULL);
/* recognize complete emptyness and ensure we can skip
* defragmentation later */
if (map->free == map->count) {
map->free = map->count = 0;
}
} }
return out; return out;
} }

@ -66,6 +66,10 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, gpr_uint32 key,
void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, void *grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map,
gpr_uint32 key); gpr_uint32 key);
/* Move all elements of src into dst */
void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
grpc_chttp2_stream_map *dst);
/* Return an existing key, or NULL if it does not exist */ /* Return an existing key, or NULL if it does not exist */
void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, gpr_uint32 key); void *grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, gpr_uint32 key);

@ -56,7 +56,7 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ ((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \
? 1 \ ? 1 \
: grpc_chttp2_hpack_varint_length( \ : grpc_chttp2_hpack_varint_length( \
(n) - GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits))) (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits)))
#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \ #define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \
do { \ do { \
@ -66,8 +66,7 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
} else { \ } else { \
(tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ (tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \
grpc_chttp2_hpack_write_varint_tail( \ grpc_chttp2_hpack_write_varint_tail( \
(n) - GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, \ (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \
(length) - 1); \
} \ } \
} while (0) } while (0)

@ -0,0 +1,215 @@
/*
*
* 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/transport/chttp2/internal.h"
#include "src/core/transport/chttp2/http2_errors.h"
#include <grpc/support/log.h>
static void finalize_outbuf(grpc_chttp2_transport_writing *transport_writing);
static void finish_write_cb(void *tw, grpc_endpoint_cb_status write_status);
int grpc_chttp2_unlocking_check_writes(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_writing *transport_writing) {
grpc_chttp2_stream_global *stream_global;
grpc_chttp2_stream_writing *stream_writing;
gpr_uint32 window_delta;
/* simple writes are queued to qbuf, and flushed here */
gpr_slice_buffer_swap(&transport_global->qbuf, &transport_writing->outbuf);
GPR_ASSERT(transport_global->qbuf.count == 0);
if (transport_global->dirtied_local_settings &&
!transport_global->sent_local_settings) {
gpr_slice_buffer_add(
&transport_writing->outbuf,
grpc_chttp2_settings_create(
transport_global->settings[GRPC_SENT_SETTINGS],
transport_global->settings[GRPC_LOCAL_SETTINGS],
transport_global->force_send_settings, GRPC_CHTTP2_NUM_SETTINGS));
transport_global->force_send_settings = 0;
transport_global->dirtied_local_settings = 0;
transport_global->sent_local_settings = 1;
}
/* for each grpc_chttp2_stream that's become writable, frame it's data
(according to
available window sizes) and add to the output buffer */
while (transport_global->outgoing_window &&
grpc_chttp2_list_pop_writable_stream(transport_global,
transport_writing, &stream_global,
&stream_writing) &&
stream_global->outgoing_window > 0) {
stream_writing->id = stream_global->id;
window_delta = grpc_chttp2_preencode(
stream_global->outgoing_sopb->ops, &stream_global->outgoing_sopb->nops,
GPR_MIN(transport_global->outgoing_window,
stream_global->outgoing_window),
&stream_writing->sopb);
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(
"write", transport_global, outgoing_window, -(gpr_int64)window_delta);
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM("write", transport_global, stream_global,
outgoing_window, -(gpr_int64)window_delta);
transport_global->outgoing_window -= window_delta;
stream_global->outgoing_window -= window_delta;
if (stream_global->write_state == GRPC_WRITE_STATE_QUEUED_CLOSE &&
stream_global->outgoing_sopb->nops == 0) {
if (!transport_global->is_client && !stream_global->read_closed) {
stream_writing->send_closed = GRPC_SEND_CLOSED_WITH_RST_STREAM;
} else {
stream_writing->send_closed = GRPC_SEND_CLOSED;
}
}
if (stream_writing->sopb.nops > 0 ||
stream_writing->send_closed != GRPC_DONT_SEND_CLOSED) {
grpc_chttp2_list_add_writing_stream(transport_writing, stream_writing);
}
/* we should either exhaust window or have no ops left, but not both */
if (stream_global->outgoing_sopb->nops == 0) {
stream_global->outgoing_sopb = NULL;
grpc_chttp2_schedule_closure(transport_global,
stream_global->send_done_closure, 1);
} else if (stream_global->outgoing_window > 0) {
grpc_chttp2_list_add_writable_stream(transport_global, stream_global);
}
}
/* for each grpc_chttp2_stream that wants to update its window, add that
* window here */
while (grpc_chttp2_list_pop_writable_window_update_stream(transport_global,
&stream_global)) {
window_delta =
transport_global->settings[GRPC_LOCAL_SETTINGS]
[GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] -
stream_global->incoming_window;
if (!stream_global->read_closed && window_delta > 0) {
gpr_slice_buffer_add(
&transport_writing->outbuf,
grpc_chttp2_window_update_create(stream_global->id, window_delta));
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM("write", transport_global, stream_global,
incoming_window, window_delta);
stream_global->incoming_window += window_delta;
grpc_chttp2_list_add_incoming_window_updated(transport_global,
stream_global);
}
}
/* if the grpc_chttp2_transport is ready to send a window update, do so here
also; 3/4 is a magic number that will likely get tuned soon */
if (transport_global->incoming_window <
transport_global->connection_window_target * 3 / 4) {
window_delta = transport_global->connection_window_target -
transport_global->incoming_window;
gpr_slice_buffer_add(&transport_writing->outbuf,
grpc_chttp2_window_update_create(0, window_delta));
GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT("write", transport_global,
incoming_window, window_delta);
transport_global->incoming_window += window_delta;
}
return transport_writing->outbuf.count > 0 ||
grpc_chttp2_list_have_writing_streams(transport_writing);
}
void grpc_chttp2_perform_writes(
grpc_chttp2_transport_writing *transport_writing, grpc_endpoint *endpoint) {
GPR_ASSERT(transport_writing->outbuf.count > 0 ||
grpc_chttp2_list_have_writing_streams(transport_writing));
finalize_outbuf(transport_writing);
GPR_ASSERT(transport_writing->outbuf.count > 0);
GPR_ASSERT(endpoint);
switch (grpc_endpoint_write(endpoint, transport_writing->outbuf.slices,
transport_writing->outbuf.count, finish_write_cb,
transport_writing)) {
case GRPC_ENDPOINT_WRITE_DONE:
grpc_chttp2_terminate_writing(transport_writing, 1);
break;
case GRPC_ENDPOINT_WRITE_ERROR:
grpc_chttp2_terminate_writing(transport_writing, 0);
break;
case GRPC_ENDPOINT_WRITE_PENDING:
break;
}
}
static void finalize_outbuf(grpc_chttp2_transport_writing *transport_writing) {
grpc_chttp2_stream_writing *stream_writing;
while (
grpc_chttp2_list_pop_writing_stream(transport_writing, &stream_writing)) {
grpc_chttp2_encode(stream_writing->sopb.ops, stream_writing->sopb.nops,
stream_writing->send_closed != GRPC_DONT_SEND_CLOSED,
stream_writing->id, &transport_writing->hpack_compressor,
&transport_writing->outbuf);
stream_writing->sopb.nops = 0;
if (stream_writing->send_closed == GRPC_SEND_CLOSED_WITH_RST_STREAM) {
gpr_slice_buffer_add(&transport_writing->outbuf,
grpc_chttp2_rst_stream_create(stream_writing->id,
GRPC_CHTTP2_NO_ERROR));
}
grpc_chttp2_list_add_written_stream(transport_writing, stream_writing);
}
}
static void finish_write_cb(void *tw, grpc_endpoint_cb_status write_status) {
grpc_chttp2_transport_writing *transport_writing = tw;
grpc_chttp2_terminate_writing(transport_writing,
write_status == GRPC_ENDPOINT_CB_OK);
}
void grpc_chttp2_cleanup_writing(
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_transport_writing *transport_writing) {
grpc_chttp2_stream_writing *stream_writing;
grpc_chttp2_stream_global *stream_global;
while (grpc_chttp2_list_pop_written_stream(
transport_global, transport_writing, &stream_global, &stream_writing)) {
if (stream_writing->send_closed != GRPC_DONT_SEND_CLOSED) {
stream_global->write_state = GRPC_WRITE_STATE_SENT_CLOSE;
if (!transport_global->is_client) {
stream_global->read_closed = 1;
}
grpc_chttp2_list_add_read_write_state_changed(transport_global,
stream_global);
}
}
transport_writing->outbuf.count = 0;
transport_writing->outbuf.length = 0;
}

File diff suppressed because it is too large Load Diff

@ -65,7 +65,7 @@ void grpc_sopb_swap(grpc_stream_op_buffer *a, grpc_stream_op_buffer *b) {
if (a->ops == a->inlined_ops) { if (a->ops == a->inlined_ops) {
if (b->ops == b->inlined_ops) { if (b->ops == b->inlined_ops) {
/* swap contents of inlined buffer */ /* swap contents of inlined buffer */
gpr_slice temp[GRPC_SOPB_INLINE_ELEMENTS]; grpc_stream_op temp[GRPC_SOPB_INLINE_ELEMENTS];
memcpy(temp, a->ops, b->nops * sizeof(grpc_stream_op)); memcpy(temp, a->ops, b->nops * sizeof(grpc_stream_op));
memcpy(a->ops, b->ops, a->nops * sizeof(grpc_stream_op)); memcpy(a->ops, b->ops, a->nops * sizeof(grpc_stream_op));
memcpy(b->ops, temp, b->nops * sizeof(grpc_stream_op)); memcpy(b->ops, temp, b->nops * sizeof(grpc_stream_op));
@ -163,6 +163,18 @@ void grpc_sopb_append(grpc_stream_op_buffer *sopb, grpc_stream_op *ops,
sopb->nops = new_nops; sopb->nops = new_nops;
} }
void grpc_sopb_move_to(grpc_stream_op_buffer *src, grpc_stream_op_buffer *dst) {
if (src->nops == 0) {
return;
}
if (dst->nops == 0) {
grpc_sopb_swap(src, dst);
return;
}
grpc_sopb_append(dst, src->ops, src->nops);
src->nops = 0;
}
static void assert_valid_list(grpc_mdelem_list *list) { static void assert_valid_list(grpc_mdelem_list *list) {
#ifndef NDEBUG #ifndef NDEBUG
grpc_linked_mdelem *l; grpc_linked_mdelem *l;

@ -199,6 +199,8 @@ void grpc_sopb_add_slice(grpc_stream_op_buffer *sopb, gpr_slice slice);
void grpc_sopb_append(grpc_stream_op_buffer *sopb, grpc_stream_op *ops, void grpc_sopb_append(grpc_stream_op_buffer *sopb, grpc_stream_op *ops,
size_t nops); size_t nops);
void grpc_sopb_move_to(grpc_stream_op_buffer *src, grpc_stream_op_buffer *dst);
char *grpc_sopb_string(grpc_stream_op_buffer *sopb); char *grpc_sopb_string(grpc_stream_op_buffer *sopb);
#endif /* GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H */ #endif /* GRPC_INTERNAL_CORE_TRANSPORT_STREAM_OP_H */

@ -73,9 +73,8 @@ void grpc_transport_destroy_stream(grpc_transport *transport,
transport->vtable->destroy_stream(transport, stream); transport->vtable->destroy_stream(transport, stream);
} }
void grpc_transport_ping(grpc_transport *transport, void (*cb)(void *user_data), void grpc_transport_ping(grpc_transport *transport, grpc_iomgr_closure *cb) {
void *user_data) { transport->vtable->ping(transport, cb);
transport->vtable->ping(transport, cb, user_data);
} }
void grpc_transport_setup_cancel(grpc_transport_setup *setup) { void grpc_transport_setup_cancel(grpc_transport_setup *setup) {
@ -98,13 +97,13 @@ void grpc_transport_setup_del_interested_party(grpc_transport_setup *setup,
void grpc_transport_op_finish_with_failure(grpc_transport_op *op) { void grpc_transport_op_finish_with_failure(grpc_transport_op *op) {
if (op->send_ops) { if (op->send_ops) {
op->on_done_send(op->send_user_data, 0); op->on_done_send->cb(op->on_done_send->cb_arg, 0);
} }
if (op->recv_ops) { if (op->recv_ops) {
op->on_done_recv(op->recv_user_data, 0); op->on_done_recv->cb(op->on_done_recv->cb_arg, 0);
} }
if (op->on_consumed) { if (op->on_consumed) {
op->on_consumed(op->on_consumed_user_data, 0); op->on_consumed->cb(op->on_consumed->cb_arg, 0);
} }
} }

@ -64,18 +64,15 @@ typedef enum grpc_stream_state {
/* Transport op: a set of operations to perform on a transport */ /* Transport op: a set of operations to perform on a transport */
typedef struct grpc_transport_op { typedef struct grpc_transport_op {
void (*on_consumed)(void *user_data, int success); grpc_iomgr_closure *on_consumed;
void *on_consumed_user_data;
grpc_stream_op_buffer *send_ops; grpc_stream_op_buffer *send_ops;
int is_last_send; int is_last_send;
void (*on_done_send)(void *user_data, int success); grpc_iomgr_closure *on_done_send;
void *send_user_data;
grpc_stream_op_buffer *recv_ops; grpc_stream_op_buffer *recv_ops;
grpc_stream_state *recv_state; grpc_stream_state *recv_state;
void (*on_done_recv)(void *user_data, int success); grpc_iomgr_closure *on_done_recv;
void *recv_user_data;
grpc_pollset *bind_pollset; grpc_pollset *bind_pollset;
@ -167,11 +164,8 @@ void grpc_transport_perform_op(grpc_transport *transport, grpc_stream *stream,
/* Send a ping on a transport /* Send a ping on a transport
Calls cb with user data when a response is received. Calls cb with user data when a response is received. */
cb *MAY* be called with arbitrary transport level locks held. It is not safe void grpc_transport_ping(grpc_transport *transport, grpc_iomgr_closure *cb);
to call into the transport during cb. */
void grpc_transport_ping(grpc_transport *transport, void (*cb)(void *user_data),
void *user_data);
/* Advise peer of pending connection termination. */ /* Advise peer of pending connection termination. */
void grpc_transport_goaway(grpc_transport *transport, grpc_status_code status, void grpc_transport_goaway(grpc_transport *transport, grpc_status_code status,

@ -63,8 +63,7 @@ typedef struct grpc_transport_vtable {
void (*close)(grpc_transport *self); void (*close)(grpc_transport *self);
/* implementation of grpc_transport_ping */ /* implementation of grpc_transport_ping */
void (*ping)(grpc_transport *self, void (*cb)(void *user_data), void (*ping)(grpc_transport *self, grpc_iomgr_closure *cb);
void *user_data);
/* implementation of grpc_transport_destroy */ /* implementation of grpc_transport_destroy */
void (*destroy)(grpc_transport *self); void (*destroy)(grpc_transport *self);

@ -36,7 +36,6 @@
#include <memory> #include <memory>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/slice.h> #include <grpc/support/slice.h>

@ -33,28 +33,14 @@
#include <grpc++/channel_arguments.h> #include <grpc++/channel_arguments.h>
#include <grpc/grpc_security.h>
#include "src/core/channel/channel_args.h" #include "src/core/channel/channel_args.h"
namespace grpc { namespace grpc {
void ChannelArguments::SetSslTargetNameOverride(const grpc::string& name) {
SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name);
}
void ChannelArguments::SetCompressionLevel(grpc_compression_level level) { void ChannelArguments::SetCompressionLevel(grpc_compression_level level) {
SetInt(GRPC_COMPRESSION_LEVEL_ARG, level); SetInt(GRPC_COMPRESSION_LEVEL_ARG, level);
} }
grpc::string ChannelArguments::GetSslTargetNameOverride() const {
for (unsigned int i = 0; i < args_.size(); i++) {
if (grpc::string(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == args_[i].key) {
return args_[i].value.string;
}
}
return "";
}
void ChannelArguments::SetInt(const grpc::string& key, int value) { void ChannelArguments::SetInt(const grpc::string& key, int value) {
grpc_arg arg; grpc_arg arg;
arg.type = GRPC_ARG_INTEGER; arg.type = GRPC_ARG_INTEGER;

@ -0,0 +1,54 @@
/*
*
* 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 <grpc++/channel_arguments.h>
#include <grpc/grpc_security.h>
#include "src/core/channel/channel_args.h"
namespace grpc {
void ChannelArguments::SetSslTargetNameOverride(const grpc::string& name) {
SetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, name);
}
grpc::string ChannelArguments::GetSslTargetNameOverride() const {
for (unsigned int i = 0; i < args_.size(); i++) {
if (grpc::string(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG) == args_[i].key) {
return args_[i].value.string;
}
}
return "";
}
} // namespace grpc

@ -31,9 +31,10 @@
* *
*/ */
#include <grpc/grpc_security.h>
#include <grpc++/server_credentials.h> #include <grpc++/server_credentials.h>
#include <grpc/grpc.h>
namespace grpc { namespace grpc {
namespace { namespace {
class InsecureServerCredentialsImpl GRPC_FINAL : public ServerCredentials { class InsecureServerCredentialsImpl GRPC_FINAL : public ServerCredentials {

@ -35,7 +35,6 @@
#include <utility> #include <utility>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc++/completion_queue.h> #include <grpc++/completion_queue.h>

@ -31,8 +31,6 @@
* *
*/ */
#include <grpc/grpc_security.h>
#include <grpc++/server_credentials.h> #include <grpc++/server_credentials.h>
namespace grpc { namespace grpc {

@ -38,13 +38,17 @@
@implementation GRPCSecureChannel @implementation GRPCSecureChannel
- (instancetype)initWithHost:(NSString *)host { - (instancetype)initWithHost:(NSString *)host {
static const grpc_credentials *kCredentials; static grpc_credentials *kCredentials;
static dispatch_once_t loading; static dispatch_once_t loading;
dispatch_once(&loading, ^{ dispatch_once(&loading, ^{
// Do not use NSBundle.mainBundle, as it's nil for tests of library projects. // Do not use NSBundle.mainBundle, as it's nil for tests of library projects.
NSBundle *bundle = [NSBundle bundleForClass:self.class]; NSBundle *bundle = [NSBundle bundleForClass:self.class];
NSString *certsPath = [bundle pathForResource:@"gRPC.bundle/roots" ofType:@"pem"]; NSString *certsPath = [bundle pathForResource:@"gRPCCertificates.bundle/roots" ofType:@"pem"];
NSAssert(certsPath.length,
@"gRPCCertificates.bundle/roots.pem not found under %@. This file, with the root "
"certificates, is needed to establish TLS (HTTPS) connections.", bundle.bundlePath);
NSData *certsData = [NSData dataWithContentsOfFile:certsPath]; NSData *certsData = [NSData dataWithContentsOfFile:certsPath];
NSAssert(certsData.length, @"No data read from %@", certsPath);
NSString *certsString = [[NSString alloc] initWithData:certsData encoding:NSUTF8StringEncoding]; NSString *certsString = [[NSString alloc] initWithData:certsData encoding:NSUTF8StringEncoding];
kCredentials = grpc_ssl_credentials_create(certsString.UTF8String, NULL); kCredentials = grpc_ssl_credentials_create(certsString.UTF8String, NULL);
}); });

@ -132,8 +132,12 @@
grpc_metadata_array_init(&_headers); grpc_metadata_array_init(&_headers);
_op.data.recv_initial_metadata = &_headers; _op.data.recv_initial_metadata = &_headers;
if (handler) { if (handler) {
// Prevent reference cycle with _handler
__weak typeof(self) weakSelf = self;
_handler = ^{ _handler = ^{
NSDictionary *metadata = [NSDictionary grpc_dictionaryFromMetadataArray:_headers]; __strong typeof(self) strongSelf = weakSelf;
NSDictionary *metadata = [NSDictionary
grpc_dictionaryFromMetadataArray:strongSelf->_headers];
handler(metadata); handler(metadata);
}; };
} }
@ -160,8 +164,11 @@
_op.op = GRPC_OP_RECV_MESSAGE; _op.op = GRPC_OP_RECV_MESSAGE;
_op.data.recv_message = &_receivedMessage; _op.data.recv_message = &_receivedMessage;
if (handler) { if (handler) {
// Prevent reference cycle with _handler
__weak typeof(self) weakSelf = self;
_handler = ^{ _handler = ^{
handler(_receivedMessage); __strong typeof(self) strongSelf = weakSelf;
handler(strongSelf->_receivedMessage);
}; };
} }
} }
@ -190,9 +197,14 @@
grpc_metadata_array_init(&_trailers); grpc_metadata_array_init(&_trailers);
_op.data.recv_status_on_client.trailing_metadata = &_trailers; _op.data.recv_status_on_client.trailing_metadata = &_trailers;
if (handler) { if (handler) {
// Prevent reference cycle with _handler
__weak typeof(self) weakSelf = self;
_handler = ^{ _handler = ^{
NSError *error = [NSError grpc_errorFromStatusCode:_statusCode details:_details]; __strong typeof(self) strongSelf = weakSelf;
NSDictionary *trailers = [NSDictionary grpc_dictionaryFromMetadataArray:_trailers]; NSError *error = [NSError grpc_errorFromStatusCode:strongSelf->_statusCode
details:strongSelf->_details];
NSDictionary *trailers = [NSDictionary
grpc_dictionaryFromMetadataArray:strongSelf->_trailers];
handler(error, trailers); handler(error, trailers);
}; };
} }

@ -174,7 +174,7 @@
__block int index = 0; __block int index = 0;
[_service streamingOutputCallWithRequest:request [_service streamingOutputCallWithRequest:request
handler:^(BOOL done, eventHandler:^(BOOL done,
RMTStreamingOutputCallResponse *response, RMTStreamingOutputCallResponse *response,
NSError *error){ NSError *error){
XCTAssertNil(error, @"Finished with unexpected error: %@", error); XCTAssertNil(error, @"Finished with unexpected error: %@", error);
@ -211,7 +211,7 @@
[requestsBuffer writeValue:request]; [requestsBuffer writeValue:request];
[_service fullDuplexCallWithRequestsWriter:requestsBuffer [_service fullDuplexCallWithRequestsWriter:requestsBuffer
handler:^(BOOL done, eventHandler:^(BOOL done,
RMTStreamingOutputCallResponse *response, RMTStreamingOutputCallResponse *response,
NSError *error) { NSError *error) {
XCTAssertNil(error, @"Finished with unexpected error: %@", error); XCTAssertNil(error, @"Finished with unexpected error: %@", error);
@ -242,7 +242,7 @@
- (void)testEmptyStreamRPC { - (void)testEmptyStreamRPC {
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"]; __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"];
[_service fullDuplexCallWithRequestsWriter:[GRXWriter emptyWriter] [_service fullDuplexCallWithRequestsWriter:[GRXWriter emptyWriter]
handler:^(BOOL done, eventHandler:^(BOOL done,
RMTStreamingOutputCallResponse *response, RMTStreamingOutputCallResponse *response,
NSError *error) { NSError *error) {
XCTAssertNil(error, @"Finished with unexpected error: %@", error); XCTAssertNil(error, @"Finished with unexpected error: %@", error);
@ -283,7 +283,7 @@
[requestsBuffer writeValue:request]; [requestsBuffer writeValue:request];
__block ProtoRPC *call = [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer __block ProtoRPC *call = [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer
handler:^(BOOL done, eventHandler:^(BOOL done,
RMTStreamingOutputCallResponse *response, RMTStreamingOutputCallResponse *response,
NSError *error) { NSError *error) {
if (receivedResponse) { if (receivedResponse) {

@ -5,14 +5,27 @@ This directory contains source code for PHP implementation of gRPC layered on sh
#Status #Status
Pre-Alpha : This gRPC PHP implementation is work-in-progress and is not expected to work yet. Alpha : Ready for early adopters
## ENVIRONMENT ## ENVIRONMENT
Prerequisite: PHP 5.5 or later, PHPUnit, pecl Prerequisite: PHP 5.5 or later, `phpunit`, `pecl`
Linux:
```sh
$ sudo apt-get install php5 php5-dev phpunit php-pear
```
OS X:
```sh ```sh
sudo apt-get install php5 php5-dev phpunit php-pear $ curl https://phar.phpunit.de/phpunit.phar -o phpunit.phar
$ chmod +x phpunit.phar
$ sudo mv phpunit.phar /usr/local/bin/phpunit
$ curl -O http://pear.php.net/go-pear.phar
$ sudo php -d detect_unicode=0 go-pear.phar
``` ```
## Build from Homebrew ## Build from Homebrew

@ -0,0 +1,49 @@
#!/bin/bash
# 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.
set -e
default_extension_dir=$(php-config --extension-dir)
if command -v brew >/dev/null && [ -d $(brew --prefix)/opt/grpc-php ]; then
# homebrew and the grpc-php formula are installed
extension_dir="-d extension_dir="$(brew --prefix)/opt/grpc-php
elif [ ! -e $default_extension_dir/grpc.so ]; then
# the grpc extension is not found in the default PHP extension dir
# try the source modules directory
module_dir=../ext/grpc/modules
if [ ! -e $module_dir/grpc.so ]; then
echo "Please run 'phpize && ./configure && make' from ext/grpc first"
exit 1
fi
# sym-link in system supplied extensions
for f in $default_extension_dir/*.so; do
ln -s $f $module_dir/$(basename $f) &> /dev/null || true
done
extension_dir="-d extension_dir="$module_dir
fi

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# Copyright 2015, Google Inc. # Copyright 2015, Google Inc.
# All rights reserved. # All rights reserved.
# #
@ -28,11 +28,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -e
set +e
cd $(dirname $0) cd $(dirname $0)
source ./determine_extension_dir.sh
module_dir=../ext/grpc/modules php $extension_dir -d extension=grpc.so \
php -d extension_dir=$module_dir -d extension=grpc.so \
../tests/interop/interop_client.php $@ 1>&2 ../tests/interop/interop_client.php $@ 1>&2

@ -1,4 +1,4 @@
# Runs the generated code test against the ruby server #!/bin/bash
# Copyright 2015, Google Inc. # Copyright 2015, Google Inc.
# All rights reserved. # All rights reserved.
# #
@ -28,10 +28,11 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set -e
cd $(dirname $0) cd $(dirname $0)
GRPC_TEST_HOST=localhost:50051 php -d extension_dir=../ext/grpc/modules/ \ source ./determine_extension_dir.sh
-d extension=grpc.so `which phpunit` -v --debug --strict \ export GRPC_TEST_HOST=localhost:7071
php $extension_dir -d extension=grpc.so $(which phpunit) -v --debug --strict \
../tests/generated_code/GeneratedCodeTest.php ../tests/generated_code/GeneratedCodeTest.php
GRPC_TEST_HOST=localhost:50051 php -d extension_dir=../ext/grpc/modules/ \ php $extension_dir -d extension=grpc.so $(which phpunit) -v --debug --strict \
-d extension=grpc.so `which phpunit` -v --debug --strict \
../tests/generated_code/GeneratedCodeWithCallbackTest.php ../tests/generated_code/GeneratedCodeWithCallbackTest.php

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# Copyright 2015, Google Inc. # Copyright 2015, Google Inc.
# All rights reserved. # All rights reserved.
# #
@ -32,33 +32,6 @@
# against it # against it
set -e set -e
cd $(dirname $0) cd $(dirname $0)
default_extension_dir=`php -i | grep extension_dir | sed 's/.*=> //g'` source ./determine_extension_dir.sh
php $extension_dir -d extension=grpc.so $(which phpunit) -v --debug --strict \
if command -v brew >/dev/null && [ -d `brew --prefix`/opt/grpc-php ] ../tests/unit_tests
then
# homebrew and the grpc-php formula are installed
extension_dir="-d extension_dir="`brew --prefix`/opt/grpc-php
elif [ ! -e $default_extension_dir/grpc.so ]
then
# the grpc extension is not found in the default PHP extension dir
# try the source modules directory
module_dir=../ext/grpc/modules
if [ ! -d $module_dir ]
then
echo "Please run 'phpize && ./configure && make' from ext/grpc first"
exit 1
fi
# sym-link in system supplied extensions
for f in $default_extension_dir/*.so
do
ln -s $f $module_dir/$(basename $f) &> /dev/null || true
done
extension_dir='-d extension_dir='$module_dir
fi
php \
$extension_dir \
-d extension=grpc.so \
`which phpunit` -v --debug --strict ../tests/unit_tests

@ -35,8 +35,13 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(dl,,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(dl) PHP_ADD_LIBRARY(dl)
case $host in
*darwin*) ;;
*)
PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD) PHP_ADD_LIBRARY(rt,,GRPC_SHARED_LIBADD)
PHP_ADD_LIBRARY(rt) PHP_ADD_LIBRARY(rt)
;;
esac
GRPC_LIBDIR=$GRPC_DIR/${GRPC_LIB_SUBDIR-lib} GRPC_LIBDIR=$GRPC_DIR/${GRPC_LIB_SUBDIR-lib}

@ -63,6 +63,12 @@ ${cc_library(lib)}
% endif % endif
% endfor % endfor
% for lib in libs:
% if lib.name in ("grpc", "gpr"):
${objc_library(lib)}
% endif
% endfor
% for tgt in targets: % for tgt in targets:
% if tgt.build == 'protoc': % if tgt.build == 'protoc':
${cc_binary(tgt)} ${cc_binary(tgt)}
@ -97,6 +103,40 @@ cc_library(
) )
</%def> </%def>
<%def name="objc_library(lib)">
objc_library(
name = "${lib.name}_objc",
srcs = [
% for src in lib.src:
"${src}",
% endfor
],
hdrs = [
% for hdr in lib.get("public_headers", []):
"${hdr}",
% endfor
% for hdr in lib.get("headers", []):
"${hdr}",
% endfor
],
includes = [
"include",
".",
],
deps = [
% for dep in lib.get("deps", []):
":${dep}_objc",
% endfor
% if lib.get('secure', 'no') == 'yes':
"//external:libssl_objc",
% endif
],
% if lib.get("baselib", false):
sdk_dylibs = ["libz"],
% endif
)
</%def>
<%def name="cc_binary(tgt)"> <%def name="cc_binary(tgt)">
cc_binary( cc_binary(
name = "${tgt.name}", name = "${tgt.name}",
@ -139,3 +179,29 @@ objc_library(
srcs = glob([rx_library_path + "/private/*.m"]), srcs = glob([rx_library_path + "/private/*.m"]),
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
) )
objc_client_path = objc_path + "/GRPCClient"
objc_library(
name = "grpc_client",
hdrs = glob([
objc_client_path + "/*.h",
objc_client_path + "/private/*.h",
]),
srcs = glob([
objc_client_path + "/*.m",
objc_client_path + "/private/*.m",
]),
includes = [objc_path],
bundles = [":gRPCCertificates"],
deps = [
":grpc_objc",
":rx_library",
],
)
objc_bundle_library(
# The choice of name is signicant here, since it determines the bundle name.
name = "gRPCCertificates",
resources = ["etc/roots.pem"],
)

@ -42,6 +42,22 @@ def fix_header_name(name):
if split_name[0] == 'include': if split_name[0] == 'include':
split_name = split_name[1:] split_name = split_name[1:]
return '/'.join(split_name) return '/'.join(split_name)
def grpc_files(libs):
out = []
for lib in libs:
if lib.name in ("grpc", "gpr"):
out.extend(fix_header_name(h) for h in lib.get('headers', []))
out.extend(fix_header_name(h) for h in lib.get('public_headers', []))
out.extend(lib.get('src', []))
return out;
def grpc_private_headers(libs):
out = []
for lib in libs:
if lib.name in ("grpc", "gpr"):
out.extend(lib.get('headers', []))
return out
%> %>
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC' s.name = 'gRPC'
@ -70,29 +86,9 @@ Pod::Spec.new do |s|
# Core cross-platform gRPC library, written in C. # Core cross-platform gRPC library, written in C.
s.subspec 'C-Core' do |ss| s.subspec 'C-Core' do |ss|
ss.source_files = \ ss.source_files = ${(',\n' + 22*' ').join('\'%s\'' % f for f in grpc_files(libs))}
% for lib in libs:
% if lib.name in ("grpc", "gpr"): ss.private_header_files = ${(',\n' + 30*' ').join('\'%s\'' % f for f in grpc_private_headers(libs))}
% for hdr in lib.get("headers", []):
'${fix_header_name(hdr)}', \
% endfor
% for hdr in lib.get("public_headers", []):
'${fix_header_name(hdr)}', \
% endfor
% for src in lib.src:
'${src}', \
% endfor
% endif
% endfor
ss.private_header_files = \
% for lib in libs:
% if lib.name in ("grpc", "gpr"):
% for hdr in lib.get("headers", []):
'${hdr}', \
% endfor
% endif
% endfor
ss.header_mappings_dir = '.' ss.header_mappings_dir = '.'
@ -141,7 +137,7 @@ Pod::Spec.new do |s|
ss.dependency 'gRPC/RxLibrary' ss.dependency 'gRPC/RxLibrary'
# Certificates, to be able to establish TLS connections: # Certificates, to be able to establish TLS connections:
ss.resource_bundles = { 'gRPC' => ['etc/roots.pem'] } ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] }
end end
# RPC library for ProtocolBuffers, based on gRPC # RPC library for ProtocolBuffers, based on gRPC

@ -778,7 +778,7 @@ WARN_LOGFILE =
# spaces. # spaces.
# Note: If this tag is empty the current directory is searched. # Note: If this tag is empty the current directory is searched.
INPUT = ${' '.join( INPUT = ${' \\\n'.join(
itertools.chain.from_iterable( itertools.chain.from_iterable(
target.public_headers + target.public_headers +
([] ([]

@ -0,0 +1,33 @@
<%!
import json
import os
def proto_headers(src):
out = []
for f in src:
name, ext = os.path.splitext(f)
if ext == '.proto':
out.extend(fmt % name for fmt in ['%s.grpc.pb.h', '%s.pb.h'])
return out
def no_protos(src):
out = []
for f in src:
if os.path.splitext(f)[1] != '.proto':
out.append(f)
return out
%>
${json.dumps([{"name": tgt.name,
"language": tgt.language,
"src": sorted(
no_protos(tgt.src) +
tgt.get('public_headers', []) +
tgt.get('headers', [])),
"headers": sorted(
tgt.get('public_headers', []) +
tgt.get('headers', []) +
proto_headers(tgt.src)),
"deps": sorted(tgt.get('deps', []))}
for tgt in (targets + libs)],
sort_keys=True, indent=2)}

@ -54,6 +54,15 @@ def main():
'language': 'c', 'language': 'c',
'src': [ 'src': [
'test/core/bad_client/bad_client.c' 'test/core/bad_client/bad_client.c'
],
'headers': [
'test/core/bad_client/bad_client.h'
],
'deps': [
'grpc_test_util_unsecure',
'grpc_unsecure',
'gpr_test_util',
'gpr'
] ]
}], }],
'targets': [ 'targets': [

@ -93,6 +93,19 @@ END2END_TESTS = {
def main(): def main():
sec_deps = [
'end2end_certs',
'grpc_test_util',
'grpc',
'gpr_test_util',
'gpr'
]
unsec_deps = [
'grpc_test_util_unsecure',
'grpc_unsecure',
'gpr_test_util',
'gpr'
]
json = { json = {
'#': 'generated with test/end2end/gen_build_json.py', '#': 'generated with test/end2end/gen_build_json.py',
'libs': [ 'libs': [
@ -103,6 +116,8 @@ def main():
'secure': 'check' if END2END_FIXTURES[f].secure else 'no', 'secure': 'check' if END2END_FIXTURES[f].secure else 'no',
'src': ['test/core/end2end/fixtures/%s.c' % f], 'src': ['test/core/end2end/fixtures/%s.c' % f],
'platforms': [ 'posix' ] if f.endswith('_posix') else END2END_FIXTURES[f].platforms, 'platforms': [ 'posix' ] if f.endswith('_posix') else END2END_FIXTURES[f].platforms,
'deps': sec_deps if END2END_FIXTURES[f].secure else unsec_deps,
'headers': ['test/core/end2end/end2end_tests.h'],
} }
for f in sorted(END2END_FIXTURES.keys())] + [ for f in sorted(END2END_FIXTURES.keys())] + [
{ {
@ -111,7 +126,9 @@ def main():
'language': 'c', 'language': 'c',
'secure': 'check' if END2END_TESTS[t].secure else 'no', 'secure': 'check' if END2END_TESTS[t].secure else 'no',
'src': ['test/core/end2end/tests/%s.c' % t], 'src': ['test/core/end2end/tests/%s.c' % t],
'headers': ['test/core/end2end/tests/cancel_test_helpers.h'] 'headers': ['test/core/end2end/tests/cancel_test_helpers.h',
'test/core/end2end/end2end_tests.h'],
'deps': sec_deps if END2END_TESTS[t].secure else unsec_deps
} }
for t in sorted(END2END_TESTS.keys())] + [ for t in sorted(END2END_TESTS.keys())] + [
{ {
@ -135,13 +152,7 @@ def main():
'platforms': END2END_FIXTURES[f].platforms, 'platforms': END2END_FIXTURES[f].platforms,
'deps': [ 'deps': [
'end2end_fixture_%s' % f, 'end2end_fixture_%s' % f,
'end2end_test_%s' % t, 'end2end_test_%s' % t] + sec_deps
'end2end_certs',
'grpc_test_util',
'grpc',
'gpr_test_util',
'gpr'
]
} }
for f in sorted(END2END_FIXTURES.keys()) for f in sorted(END2END_FIXTURES.keys())
for t in sorted(END2END_TESTS.keys())] + [ for t in sorted(END2END_TESTS.keys())] + [
@ -155,12 +166,7 @@ def main():
'platforms': END2END_FIXTURES[f].platforms, 'platforms': END2END_FIXTURES[f].platforms,
'deps': [ 'deps': [
'end2end_fixture_%s' % f, 'end2end_fixture_%s' % f,
'end2end_test_%s' % t, 'end2end_test_%s' % t] + unsec_deps
'grpc_test_util_unsecure',
'grpc_unsecure',
'gpr_test_util',
'gpr'
]
} }
for f in sorted(END2END_FIXTURES.keys()) if not END2END_FIXTURES[f].secure for f in sorted(END2END_FIXTURES.keys()) if not END2END_FIXTURES[f].secure
for t in sorted(END2END_TESTS.keys()) if not END2END_TESTS[t].secure]} for t in sorted(END2END_TESTS.keys()) if not END2END_TESTS[t].secure]}

@ -97,7 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) {
static gpr_slice large_slice(void) { static gpr_slice large_slice(void) {
gpr_slice slice = gpr_slice_malloc(1000000); gpr_slice slice = gpr_slice_malloc(1000000);
memset(GPR_SLICE_START_PTR(slice), 0xab, GPR_SLICE_LENGTH(slice)); memset(GPR_SLICE_START_PTR(slice), 'x', GPR_SLICE_LENGTH(slice));
return slice; return slice;
} }

@ -68,6 +68,8 @@ namespace testing {
namespace { namespace {
const char* kServerCancelAfterReads = "cancel_after_reads";
// When echo_deadline is requested, deadline seen in the ServerContext is set in // When echo_deadline is requested, deadline seen in the ServerContext is set in
// the response in seconds. // the response in seconds.
void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request, void MaybeEchoDeadline(ServerContext* context, const EchoRequest* request,
@ -131,7 +133,23 @@ class TestServiceImpl : public ::grpc::cpp::test::util::TestService::Service {
EchoResponse* response) GRPC_OVERRIDE { EchoResponse* response) GRPC_OVERRIDE {
EchoRequest request; EchoRequest request;
response->set_message(""); response->set_message("");
int cancel_after_reads = 0;
const std::multimap<grpc::string, grpc::string> client_initial_metadata =
context->client_metadata();
if (client_initial_metadata.find(kServerCancelAfterReads) !=
client_initial_metadata.end()) {
std::istringstream iss(
client_initial_metadata.find(kServerCancelAfterReads)->second);
iss >> cancel_after_reads;
gpr_log(GPR_INFO, "cancel_after_reads %d", cancel_after_reads);
}
while (reader->Read(&request)) { while (reader->Read(&request)) {
if (cancel_after_reads == 1) {
gpr_log(GPR_INFO, "return cancel status");
return Status::CANCELLED;
} else if (cancel_after_reads > 0) {
cancel_after_reads--;
}
response->mutable_message()->append(request.message()); response->mutable_message()->append(request.message());
} }
return Status::OK; return Status::OK;
@ -687,6 +705,27 @@ TEST_F(End2endTest, OverridePerCallCredentials) {
EXPECT_TRUE(s.ok()); EXPECT_TRUE(s.ok());
} }
// Client sends 20 requests and the server returns CANCELLED status after
// reading 10 requests.
TEST_F(End2endTest, RequestStreamServerEarlyCancelTest) {
ResetStub();
EchoRequest request;
EchoResponse response;
ClientContext context;
context.AddMetadata(kServerCancelAfterReads, "10");
auto stream = stub_->RequestStream(&context, &response);
request.set_message("hello");
int send_messages = 20;
while (send_messages > 0) {
EXPECT_TRUE(stream->Write(request));
send_messages--;
}
stream->WritesDone();
Status s = stream->Finish();
EXPECT_EQ(s.error_code(), StatusCode::CANCELLED);
}
} // namespace testing } // namespace testing
} // namespace grpc } // namespace grpc

@ -234,12 +234,6 @@ class AsyncClient : public Client {
GPR_ASSERT(false); GPR_ASSERT(false);
break; break;
} }
if ((closed_loop_ || !rpc_deadlines_[thread_idx].empty()) &&
grpc_time_source::now() > deadline) {
// we have missed some 1-second deadline, which is worth noting
gpr_log(GPR_INFO, "Missed an RPC deadline");
// Don't give up, as there might be some truly heavy tails
}
if (got_event) { if (got_event) {
ClientRpcContext* ctx = ClientRpcContext::detag(got_tag); ClientRpcContext* ctx = ClientRpcContext::detag(got_tag);
if (ctx->RunNextState(ok, histogram) == false) { if (ctx->RunNextState(ok, histogram) == false) {

@ -31,7 +31,7 @@
* *
*/ */
#include "qps_worker.h" #include "test/cpp/qps/qps_worker.h"
#include <cassert> #include <cassert>
#include <memory> #include <memory>

@ -40,7 +40,7 @@
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include "qps_worker.h" #include "test/cpp/qps/qps_worker.h"
#include "test/cpp/util/test_config.h" #include "test/cpp/util/test_config.h"
DEFINE_int32(driver_port, 0, "Driver server port."); DEFINE_int32(driver_port, 0, "Driver server port.");

@ -46,6 +46,14 @@ enum PayloadType {
RANDOM = 2; RANDOM = 2;
} }
// Compression algorithms
enum CompressionType {
// No compression
NONE = 0;
GZIP = 1;
DEFLATE = 2;
}
// A block of data, to simply increase gRPC message size. // A block of data, to simply increase gRPC message size.
message Payload { message Payload {
// The type of data in body. // The type of data in body.
@ -54,6 +62,13 @@ message Payload {
optional bytes body = 2; optional bytes body = 2;
} }
// A protobuf representation for grpc status. This is used by test
// clients to specify a status that the server should attempt to return.
message EchoStatus {
optional int32 code = 1;
optional string message = 2;
}
// Unary request. // Unary request.
message SimpleRequest { message SimpleRequest {
// Desired payload type in the response from the server. // Desired payload type in the response from the server.
@ -72,6 +87,12 @@ message SimpleRequest {
// Whether SimpleResponse should include OAuth scope. // Whether SimpleResponse should include OAuth scope.
optional bool fill_oauth_scope = 5; optional bool fill_oauth_scope = 5;
// Compression algorithm to be used by the server for the response (stream)
optional CompressionType response_compression = 6;
// Whether server should return a given status
optional EchoStatus response_status = 7;
} }
// Unary response, as configured by the request. // Unary response, as configured by the request.
@ -123,6 +144,12 @@ message StreamingOutputCallRequest {
// Optional input payload sent along with the request. // Optional input payload sent along with the request.
optional Payload payload = 3; optional Payload payload = 3;
// Compression algorithm to be used by the server for the response (stream)
optional CompressionType response_compression = 6;
// Whether server should return a given status
optional EchoStatus response_status = 7;
} }
// Server-streaming response, as configured by the request and parameters. // Server-streaming response, as configured by the request and parameters.

@ -71,3 +71,11 @@ service TestService {
rpc HalfDuplexCall(stream StreamingOutputCallRequest) rpc HalfDuplexCall(stream StreamingOutputCallRequest)
returns (stream StreamingOutputCallResponse); returns (stream StreamingOutputCallResponse);
} }
// A simple service NOT implemented at servers so clients can test for
// that case.
service UnimplementedService {
// A call that no server should implement
rpc UnimplementedCall(grpc.testing.Empty) returns(grpc.testing.Empty);
}

@ -55,19 +55,15 @@ typedef struct {
unsigned char index; unsigned char index;
} spec; } spec;
static const spec fields[] = {{"INDEXED_FIELD", 0X80, 1, 1}, static const spec fields[] = {
{"INDEXED_FIELD_X", 0X80, 1, 2}, {"INDEXED_FIELD", 0X80, 1, 1}, {"INDEXED_FIELD_X", 0X80, 1, 2},
{"LITHDR_INCIDX", 0X40, 2, 1}, {"LITHDR_INCIDX", 0X40, 2, 1}, {"LITHDR_INCIDX_X", 0X40, 2, 2},
{"LITHDR_INCIDX_X", 0X40, 2, 2}, {"LITHDR_INCIDX_V", 0X40, 2, 0}, {"LITHDR_NOTIDX", 0X00, 4, 1},
{"LITHDR_INCIDX_V", 0X40, 2, 0}, {"LITHDR_NOTIDX_X", 0X00, 4, 2}, {"LITHDR_NOTIDX_V", 0X00, 4, 0},
{"LITHDR_NOTIDX", 0X00, 4, 1}, {"LITHDR_NVRIDX", 0X10, 4, 1}, {"LITHDR_NVRIDX_X", 0X10, 4, 2},
{"LITHDR_NOTIDX_X", 0X00, 4, 2}, {"LITHDR_NVRIDX_V", 0X10, 4, 0}, {"MAX_TBL_SIZE", 0X20, 3, 1},
{"LITHDR_NOTIDX_V", 0X00, 4, 0}, {"MAX_TBL_SIZE_X", 0X20, 3, 2},
{"LITHDR_NVRIDX", 0X10, 4, 1}, };
{"LITHDR_NVRIDX_X", 0X10, 4, 2},
{"LITHDR_NVRIDX_V", 0X10, 4, 0},
{"MAX_TBL_SIZE", 0X20, 3, 1},
{"MAX_TBL_SIZE_X", 0X20, 3, 2}, };
static const int num_fields = sizeof(fields) / sizeof(*fields); static const int num_fields = sizeof(fields) / sizeof(*fields);
@ -129,13 +125,9 @@ static void generate_first_byte_lut(void) {
#define MAXHUFFSTATES 1024 #define MAXHUFFSTATES 1024
/* represents a set of symbols as an array of booleans indicating inclusion */ /* represents a set of symbols as an array of booleans indicating inclusion */
typedef struct { typedef struct { char included[GRPC_CHTTP2_NUM_HUFFSYMS]; } symset;
char included[GRPC_CHTTP2_NUM_HUFFSYMS];
} symset;
/* represents a lookup table indexed by a nibble */ /* represents a lookup table indexed by a nibble */
typedef struct { typedef struct { int values[16]; } nibblelut;
int values[16];
} nibblelut;
/* returns a symset that includes all possible symbols */ /* returns a symset that includes all possible symbols */
static symset symset_all(void) { static symset symset_all(void) {
@ -268,8 +260,7 @@ static void build_dec_tbl(int state, int nibble, int nibbits, unsigned bitofs,
/* recurse down for this bit */ /* recurse down for this bit */
build_dec_tbl(state, (nibble << 1) | bit, nibbits + 1, bitofs + 1, emit, build_dec_tbl(state, (nibble << 1) | bit, nibbits + 1, bitofs + 1, emit,
nextsyms); nextsyms);
next: next:;
;
} }
} }

@ -760,7 +760,43 @@ WARN_LOGFILE =
# spaces. # spaces.
# Note: If this tag is empty the current directory is searched. # Note: If this tag is empty the current directory is searched.
INPUT = include/grpc++/async_generic_service.h include/grpc++/async_unary_call.h include/grpc++/byte_buffer.h include/grpc++/channel_arguments.h include/grpc++/channel_interface.h include/grpc++/client_context.h include/grpc++/completion_queue.h include/grpc++/config.h include/grpc++/config_protobuf.h include/grpc++/create_channel.h include/grpc++/credentials.h include/grpc++/generic_stub.h include/grpc++/impl/call.h include/grpc++/impl/client_unary_call.h include/grpc++/impl/grpc_library.h include/grpc++/impl/internal_stub.h include/grpc++/impl/proto_utils.h include/grpc++/impl/rpc_method.h include/grpc++/impl/rpc_service_method.h include/grpc++/impl/serialization_traits.h include/grpc++/impl/service_type.h include/grpc++/impl/sync.h include/grpc++/impl/sync_cxx11.h include/grpc++/impl/sync_no_cxx11.h include/grpc++/impl/thd.h include/grpc++/impl/thd_cxx11.h include/grpc++/impl/thd_no_cxx11.h include/grpc++/server.h include/grpc++/server_builder.h include/grpc++/server_context.h include/grpc++/server_credentials.h include/grpc++/slice.h include/grpc++/status.h include/grpc++/status_code_enum.h include/grpc++/stream.h include/grpc++/thread_pool_interface.h include/grpc++/time.h INPUT = include/grpc++/async_generic_service.h \
include/grpc++/async_unary_call.h \
include/grpc++/byte_buffer.h \
include/grpc++/channel_arguments.h \
include/grpc++/channel_interface.h \
include/grpc++/client_context.h \
include/grpc++/completion_queue.h \
include/grpc++/config.h \
include/grpc++/config_protobuf.h \
include/grpc++/create_channel.h \
include/grpc++/credentials.h \
include/grpc++/generic_stub.h \
include/grpc++/impl/call.h \
include/grpc++/impl/client_unary_call.h \
include/grpc++/impl/grpc_library.h \
include/grpc++/impl/internal_stub.h \
include/grpc++/impl/proto_utils.h \
include/grpc++/impl/rpc_method.h \
include/grpc++/impl/rpc_service_method.h \
include/grpc++/impl/serialization_traits.h \
include/grpc++/impl/service_type.h \
include/grpc++/impl/sync.h \
include/grpc++/impl/sync_cxx11.h \
include/grpc++/impl/sync_no_cxx11.h \
include/grpc++/impl/thd.h \
include/grpc++/impl/thd_cxx11.h \
include/grpc++/impl/thd_no_cxx11.h \
include/grpc++/server.h \
include/grpc++/server_builder.h \
include/grpc++/server_context.h \
include/grpc++/server_credentials.h \
include/grpc++/slice.h \
include/grpc++/status.h \
include/grpc++/status_code_enum.h \
include/grpc++/stream.h \
include/grpc++/thread_pool_interface.h \
include/grpc++/time.h
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

@ -760,7 +760,74 @@ WARN_LOGFILE =
# spaces. # spaces.
# Note: If this tag is empty the current directory is searched. # Note: If this tag is empty the current directory is searched.
INPUT = include/grpc++/async_generic_service.h include/grpc++/async_unary_call.h include/grpc++/byte_buffer.h include/grpc++/channel_arguments.h include/grpc++/channel_interface.h include/grpc++/client_context.h include/grpc++/completion_queue.h include/grpc++/config.h include/grpc++/config_protobuf.h include/grpc++/create_channel.h include/grpc++/credentials.h include/grpc++/generic_stub.h include/grpc++/impl/call.h include/grpc++/impl/client_unary_call.h include/grpc++/impl/grpc_library.h include/grpc++/impl/internal_stub.h include/grpc++/impl/proto_utils.h include/grpc++/impl/rpc_method.h include/grpc++/impl/rpc_service_method.h include/grpc++/impl/serialization_traits.h include/grpc++/impl/service_type.h include/grpc++/impl/sync.h include/grpc++/impl/sync_cxx11.h include/grpc++/impl/sync_no_cxx11.h include/grpc++/impl/thd.h include/grpc++/impl/thd_cxx11.h include/grpc++/impl/thd_no_cxx11.h include/grpc++/server.h include/grpc++/server_builder.h include/grpc++/server_context.h include/grpc++/server_credentials.h include/grpc++/slice.h include/grpc++/status.h include/grpc++/status_code_enum.h include/grpc++/stream.h include/grpc++/thread_pool_interface.h include/grpc++/time.h src/cpp/client/secure_credentials.h src/cpp/server/secure_server_credentials.h src/cpp/client/channel.h src/cpp/server/thread_pool.h src/cpp/client/secure_credentials.cc src/cpp/server/secure_server_credentials.cc src/cpp/client/channel.cc src/cpp/client/channel_arguments.cc src/cpp/client/client_context.cc src/cpp/client/create_channel.cc src/cpp/client/credentials.cc src/cpp/client/generic_stub.cc src/cpp/client/insecure_credentials.cc src/cpp/client/internal_stub.cc src/cpp/common/call.cc src/cpp/common/completion_queue.cc src/cpp/common/rpc_method.cc src/cpp/proto/proto_utils.cc src/cpp/server/async_generic_service.cc src/cpp/server/create_default_thread_pool.cc src/cpp/server/insecure_server_credentials.cc src/cpp/server/server.cc src/cpp/server/server_builder.cc src/cpp/server/server_context.cc src/cpp/server/server_credentials.cc src/cpp/server/thread_pool.cc src/cpp/util/byte_buffer.cc src/cpp/util/slice.cc src/cpp/util/status.cc src/cpp/util/time.cc INPUT = include/grpc++/async_generic_service.h \
include/grpc++/async_unary_call.h \
include/grpc++/byte_buffer.h \
include/grpc++/channel_arguments.h \
include/grpc++/channel_interface.h \
include/grpc++/client_context.h \
include/grpc++/completion_queue.h \
include/grpc++/config.h \
include/grpc++/config_protobuf.h \
include/grpc++/create_channel.h \
include/grpc++/credentials.h \
include/grpc++/generic_stub.h \
include/grpc++/impl/call.h \
include/grpc++/impl/client_unary_call.h \
include/grpc++/impl/grpc_library.h \
include/grpc++/impl/internal_stub.h \
include/grpc++/impl/proto_utils.h \
include/grpc++/impl/rpc_method.h \
include/grpc++/impl/rpc_service_method.h \
include/grpc++/impl/serialization_traits.h \
include/grpc++/impl/service_type.h \
include/grpc++/impl/sync.h \
include/grpc++/impl/sync_cxx11.h \
include/grpc++/impl/sync_no_cxx11.h \
include/grpc++/impl/thd.h \
include/grpc++/impl/thd_cxx11.h \
include/grpc++/impl/thd_no_cxx11.h \
include/grpc++/server.h \
include/grpc++/server_builder.h \
include/grpc++/server_context.h \
include/grpc++/server_credentials.h \
include/grpc++/slice.h \
include/grpc++/status.h \
include/grpc++/status_code_enum.h \
include/grpc++/stream.h \
include/grpc++/thread_pool_interface.h \
include/grpc++/time.h \
src/cpp/client/secure_credentials.h \
src/cpp/server/secure_server_credentials.h \
src/cpp/client/channel.h \
src/cpp/server/thread_pool.h \
src/cpp/client/secure_channel_arguments.cc \
src/cpp/client/secure_credentials.cc \
src/cpp/server/secure_server_credentials.cc \
src/cpp/client/channel.cc \
src/cpp/client/channel_arguments.cc \
src/cpp/client/client_context.cc \
src/cpp/client/create_channel.cc \
src/cpp/client/credentials.cc \
src/cpp/client/generic_stub.cc \
src/cpp/client/insecure_credentials.cc \
src/cpp/client/internal_stub.cc \
src/cpp/common/call.cc \
src/cpp/common/completion_queue.cc \
src/cpp/common/rpc_method.cc \
src/cpp/proto/proto_utils.cc \
src/cpp/server/async_generic_service.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/insecure_server_credentials.cc \
src/cpp/server/server.cc \
src/cpp/server/server_builder.cc \
src/cpp/server/server_context.cc \
src/cpp/server/server_credentials.cc \
src/cpp/server/thread_pool.cc \
src/cpp/util/byte_buffer.cc \
src/cpp/util/slice.cc \
src/cpp/util/status.cc \
src/cpp/util/time.cc
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

@ -760,7 +760,41 @@ WARN_LOGFILE =
# spaces. # spaces.
# Note: If this tag is empty the current directory is searched. # Note: If this tag is empty the current directory is searched.
INPUT = include/grpc/grpc_security.h include/grpc/byte_buffer.h include/grpc/byte_buffer_reader.h include/grpc/compression.h include/grpc/grpc.h include/grpc/status.h include/grpc/census.h include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_win32.h include/grpc/support/cancellable_platform.h include/grpc/support/cmdline.h include/grpc/support/cpu.h include/grpc/support/histogram.h include/grpc/support/host_port.h include/grpc/support/log.h include/grpc/support/log_win32.h include/grpc/support/port_platform.h include/grpc/support/slice.h include/grpc/support/slice_buffer.h include/grpc/support/string_util.h include/grpc/support/subprocess.h include/grpc/support/sync.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h include/grpc/support/sync_win32.h include/grpc/support/thd.h include/grpc/support/time.h include/grpc/support/tls.h include/grpc/support/tls_gcc.h include/grpc/support/tls_msvc.h include/grpc/support/tls_pthread.h include/grpc/support/useful.h INPUT = include/grpc/grpc_security.h \
include/grpc/byte_buffer.h \
include/grpc/byte_buffer_reader.h \
include/grpc/compression.h \
include/grpc/grpc.h \
include/grpc/status.h \
include/grpc/census.h \
include/grpc/support/alloc.h \
include/grpc/support/atm.h \
include/grpc/support/atm_gcc_atomic.h \
include/grpc/support/atm_gcc_sync.h \
include/grpc/support/atm_win32.h \
include/grpc/support/cancellable_platform.h \
include/grpc/support/cmdline.h \
include/grpc/support/cpu.h \
include/grpc/support/histogram.h \
include/grpc/support/host_port.h \
include/grpc/support/log.h \
include/grpc/support/log_win32.h \
include/grpc/support/port_platform.h \
include/grpc/support/slice.h \
include/grpc/support/slice_buffer.h \
include/grpc/support/string_util.h \
include/grpc/support/subprocess.h \
include/grpc/support/sync.h \
include/grpc/support/sync_generic.h \
include/grpc/support/sync_posix.h \
include/grpc/support/sync_win32.h \
include/grpc/support/thd.h \
include/grpc/support/time.h \
include/grpc/support/tls.h \
include/grpc/support/tls_gcc.h \
include/grpc/support/tls_msvc.h \
include/grpc/support/tls_pthread.h \
include/grpc/support/useful.h
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

File diff suppressed because one or more lines are too long

@ -0,0 +1,45 @@
#!/bin/bash
# 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.
#
# This script is invoked by run_jekins.sh when piggy-backing into docker.
set -e
export CONFIG=$config
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.5
export CPPFLAGS=-I/tmp/prebuilt/include
mkdir -p /var/local/git
git clone --recursive /var/local/jenkins/grpc /var/local/git/grpc
cd /var/local/git/grpc
nvm use 0.12
rvm use ruby-2.1
tools/run_tests/prepare_travis.sh
tools/run_tests/run_tests.py -t -c $config -l $language -x report.xml

@ -136,5 +136,7 @@ RUN wget http://www.dotdeb.org/dotdeb.gpg -O- | apt-key add -
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
git php5 php5-dev phpunit unzip git php5 php5-dev phpunit unzip
RUN mkdir /var/local/jenkins
# Define the default command. # Define the default command.
CMD ["bash"] CMD ["bash"]

@ -41,6 +41,10 @@ if [ "$platform" == "linux" ]
then then
echo "building $language on Linux" echo "building $language on Linux"
cd `dirname $0`/../..
git_root=`pwd`
cd -
# Use image name based on Dockerfile checksum # Use image name based on Dockerfile checksum
DOCKER_IMAGE_NAME=grpc_jenkins_slave_`sha1sum tools/jenkins/grpc_jenkins_slave/Dockerfile | cut -f1 -d\ ` DOCKER_IMAGE_NAME=grpc_jenkins_slave_`sha1sum tools/jenkins/grpc_jenkins_slave/Dockerfile | cut -f1 -d\ `
@ -57,26 +61,19 @@ then
rm -f docker.cid rm -f docker.cid
# Run tests inside docker # Run tests inside docker
docker run --cidfile=docker.cid $DOCKER_IMAGE_NAME bash -c -l "git clone --recursive $GIT_URL /var/local/git/grpc \ docker run \
&& cd /var/local/git/grpc \ -e "config=$config" \
$FETCH_PULL_REQUEST_CMD \ -e "language=$language" \
&& git checkout -f $GIT_COMMIT \ -i \
&& git submodule update \ -v "$git_root:/var/local/jenkins/grpc" \
&& nvm use 0.12 \ --cidfile=docker.cid \
&& rvm use ruby-2.1 \ $DOCKER_IMAGE_NAME \
&& CONFIG=$config tools/run_tests/prepare_travis.sh \ bash -l /var/local/jenkins/grpc/tools/jenkins/docker_run_jenkins.sh || DOCKER_FAILED="true"
&& CPPFLAGS=-I/tmp/prebuilt/include tools/run_tests/run_tests.py -t -c $config -l $language" || DOCKER_FAILED="true"
DOCKER_CID=`cat docker.cid` DOCKER_CID=`cat docker.cid`
if [ "$DOCKER_FAILED" == "" ] docker kill $DOCKER_CID
then docker cp $DOCKER_CID:/var/local/git/grpc/report.xml $git_root
echo "Docker finished successfully, deleting the container $DOCKER_CID"
docker rm $DOCKER_CID docker rm $DOCKER_CID
else
echo "Docker exited with failure, keeping container $DOCKER_CID."
echo "You can SSH to the worker and use 'docker commit CID YOUR_IMAGE_NAME' and 'docker run -i -t YOUR_IMAGE_NAME bash' to debug the problem."
exit 1
fi
elif [ "$platform" == "windows" ] elif [ "$platform" == "windows" ]
then then
@ -89,7 +86,7 @@ then
/cygdrive/c/nuget/nuget.exe restore vsprojects/grpc.sln /cygdrive/c/nuget/nuget.exe restore vsprojects/grpc.sln
/cygdrive/c/nuget/nuget.exe restore src/csharp/Grpc.sln /cygdrive/c/nuget/nuget.exe restore src/csharp/Grpc.sln
python tools/run_tests/run_tests.py -t -l $language python tools/run_tests/run_tests.py -t -l $language -x report.xml
else else
echo "Unknown platform $platform" echo "Unknown platform $platform"
exit 1 exit 1

@ -0,0 +1,55 @@
#!/usr/bin/env python2.7
import json
import os
import re
import sys
root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
with open(os.path.join(root, 'tools', 'run_tests', 'sources_and_headers.json')) as f:
js = json.loads(f.read())
re_inc1 = re.compile(r'^#\s*include\s*"([^"]*)"')
assert re_inc1.match('#include "foo"').group(1) == 'foo'
re_inc2 = re.compile(r'^#\s*include\s*<((grpc|grpc\+\+)/[^"]*)>')
assert re_inc2.match('#include <grpc++/foo>').group(1) == 'grpc++/foo'
def get_target(name):
for target in js:
if target['name'] == name:
return target
assert False, 'no target %s' % name
def target_has_header(target, name):
# print target['name'], name
if name in target['headers']:
return True
for dep in target['deps']:
if target_has_header(get_target(dep), name):
return True
if name == 'src/core/profiling/stap_probes.h':
return True
return False
errors = 0
for target in js:
for fn in target['src']:
with open(os.path.join(root, fn)) as f:
src = f.read().splitlines()
for line in src:
m = re_inc1.match(line)
if m:
if not target_has_header(target, m.group(1)):
print (
'target %s (%s) does not name header %s as a dependency' % (
target['name'], fn, m.group(1)))
errors += 1
m = re_inc2.match(line)
if m:
if not target_has_header(target, 'include/' + m.group(1)):
print (
'target %s (%s) does not name header %s as a dependency' % (
target['name'], fn, m.group(1)))
errors += 1
assert errors == 0

@ -34,10 +34,12 @@ import multiprocessing
import os import os
import platform import platform
import signal import signal
import string
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
import time import time
import xml.etree.cElementTree as ET
_DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count() _DEFAULT_MAX_JOBS = 16 * multiprocessing.cpu_count()
@ -159,7 +161,7 @@ class JobSpec(object):
class Job(object): class Job(object):
"""Manages one job.""" """Manages one job."""
def __init__(self, spec, bin_hash, newline_on_success, travis): def __init__(self, spec, bin_hash, newline_on_success, travis, xml_report):
self._spec = spec self._spec = spec
self._bin_hash = bin_hash self._bin_hash = bin_hash
self._tempfile = tempfile.TemporaryFile() self._tempfile = tempfile.TemporaryFile()
@ -176,19 +178,27 @@ class Job(object):
self._state = _RUNNING self._state = _RUNNING
self._newline_on_success = newline_on_success self._newline_on_success = newline_on_success
self._travis = travis self._travis = travis
self._xml_test = ET.SubElement(xml_report, 'testcase',
name=self._spec.shortname) if xml_report is not None else None
message('START', spec.shortname, do_newline=self._travis) message('START', spec.shortname, do_newline=self._travis)
def state(self, update_cache): def state(self, update_cache):
"""Poll current state of the job. Prints messages at completion.""" """Poll current state of the job. Prints messages at completion."""
if self._state == _RUNNING and self._process.poll() is not None: if self._state == _RUNNING and self._process.poll() is not None:
elapsed = time.time() - self._start elapsed = time.time() - self._start
if self._process.returncode != 0:
self._state = _FAILURE
self._tempfile.seek(0) self._tempfile.seek(0)
stdout = self._tempfile.read() stdout = self._tempfile.read()
filtered_stdout = filter(lambda x: x in string.printable, stdout.decode(errors='ignore'))
if self._xml_test is not None:
self._xml_test.set('time', str(elapsed))
ET.SubElement(self._xml_test, 'system-out').text = filtered_stdout
if self._process.returncode != 0:
self._state = _FAILURE
message('FAILED', '%s [ret=%d, pid=%d]' % ( message('FAILED', '%s [ret=%d, pid=%d]' % (
self._spec.shortname, self._process.returncode, self._process.pid), self._spec.shortname, self._process.returncode, self._process.pid),
stdout, do_newline=True) stdout, do_newline=True)
if self._xml_test is not None:
ET.SubElement(self._xml_test, 'failure', message='Failure').text
else: else:
self._state = _SUCCESS self._state = _SUCCESS
message('PASSED', '%s [time=%.1fsec]' % (self._spec.shortname, elapsed), message('PASSED', '%s [time=%.1fsec]' % (self._spec.shortname, elapsed),
@ -200,6 +210,9 @@ class Job(object):
stdout = self._tempfile.read() stdout = self._tempfile.read()
message('TIMEOUT', self._spec.shortname, stdout, do_newline=True) message('TIMEOUT', self._spec.shortname, stdout, do_newline=True)
self.kill() self.kill()
if self._xml_test is not None:
ET.SubElement(self._xml_test, 'system-out').text = stdout
ET.SubElement(self._xml_test, 'error', message='Timeout')
return self._state return self._state
def kill(self): def kill(self):
@ -212,7 +225,7 @@ class Jobset(object):
"""Manages one run of jobs.""" """Manages one run of jobs."""
def __init__(self, check_cancelled, maxjobs, newline_on_success, travis, def __init__(self, check_cancelled, maxjobs, newline_on_success, travis,
stop_on_failure, cache): stop_on_failure, cache, xml_report):
self._running = set() self._running = set()
self._check_cancelled = check_cancelled self._check_cancelled = check_cancelled
self._cancelled = False self._cancelled = False
@ -224,6 +237,7 @@ class Jobset(object):
self._cache = cache self._cache = cache
self._stop_on_failure = stop_on_failure self._stop_on_failure = stop_on_failure
self._hashes = {} self._hashes = {}
self._xml_report = xml_report
def start(self, spec): def start(self, spec):
"""Start a job. Return True on success, False on failure.""" """Start a job. Return True on success, False on failure."""
@ -250,7 +264,8 @@ class Jobset(object):
self._running.add(Job(spec, self._running.add(Job(spec,
bin_hash, bin_hash,
self._newline_on_success, self._newline_on_success,
self._travis)) self._travis,
self._xml_report))
except: except:
message('FAILED', spec.shortname) message('FAILED', spec.shortname)
self._cancelled = True self._cancelled = True
@ -324,11 +339,13 @@ def run(cmdlines,
travis=False, travis=False,
infinite_runs=False, infinite_runs=False,
stop_on_failure=False, stop_on_failure=False,
cache=None): cache=None,
xml_report=None):
js = Jobset(check_cancelled, js = Jobset(check_cancelled,
maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS, maxjobs if maxjobs is not None else _DEFAULT_MAX_JOBS,
newline_on_success, travis, stop_on_failure, newline_on_success, travis, stop_on_failure,
cache if cache is not None else NoCache()) cache if cache is not None else NoCache(),
xml_report)
for cmdline in cmdlines: for cmdline in cmdlines:
if not js.start(cmdline): if not js.start(cmdline):
break break

@ -42,6 +42,7 @@ import re
import subprocess import subprocess
import sys import sys
import time import time
import xml.etree.cElementTree as ET
import jobset import jobset
import watch_dirs import watch_dirs
@ -278,7 +279,8 @@ class CSharpLanguage(object):
class Sanity(object): class Sanity(object):
def test_specs(self, config, travis): def test_specs(self, config, travis):
return [config.job_spec('tools/run_tests/run_sanity.sh', None)] return [config.job_spec('tools/run_tests/run_sanity.sh', None),
config.job_spec('tools/run_tests/check_sources_and_headers.py', None)]
def make_targets(self): def make_targets(self):
return ['run_dep_checks'] return ['run_dep_checks']
@ -396,6 +398,8 @@ argp.add_argument('-S', '--stop_on_failure',
action='store_const', action='store_const',
const=True) const=True)
argp.add_argument('-a', '--antagonists', default=0, type=int) argp.add_argument('-a', '--antagonists', default=0, type=int)
argp.add_argument('-x', '--xml_report', default=None, type=str,
help='Generates a JUnit-compatible XML report')
args = argp.parse_args() args = argp.parse_args()
# grab config # grab config
@ -492,7 +496,7 @@ class TestCache(object):
self.parse(json.loads(f.read())) self.parse(json.loads(f.read()))
def _build_and_run(check_cancelled, newline_on_success, travis, cache): def _build_and_run(check_cancelled, newline_on_success, travis, cache, xml_report=None):
"""Do one pass of building & running tests.""" """Do one pass of building & running tests."""
# build latest sequentially # build latest sequentially
if not jobset.run(build_steps, maxjobs=1, if not jobset.run(build_steps, maxjobs=1,
@ -518,16 +522,24 @@ def _build_and_run(check_cancelled, newline_on_success, travis, cache):
runs_sequence = (itertools.repeat(massaged_one_run) if infinite_runs runs_sequence = (itertools.repeat(massaged_one_run) if infinite_runs
else itertools.repeat(massaged_one_run, runs_per_test)) else itertools.repeat(massaged_one_run, runs_per_test))
all_runs = itertools.chain.from_iterable(runs_sequence) all_runs = itertools.chain.from_iterable(runs_sequence)
root = ET.Element('testsuites') if xml_report else None
testsuite = ET.SubElement(root, 'testsuite', id='1', package='grpc', name='tests') if xml_report else None
if not jobset.run(all_runs, check_cancelled, if not jobset.run(all_runs, check_cancelled,
newline_on_success=newline_on_success, travis=travis, newline_on_success=newline_on_success, travis=travis,
infinite_runs=infinite_runs, infinite_runs=infinite_runs,
maxjobs=args.jobs, maxjobs=args.jobs,
stop_on_failure=args.stop_on_failure, stop_on_failure=args.stop_on_failure,
cache=cache): cache=cache if not xml_report else None,
xml_report=testsuite):
return 2 return 2
finally: finally:
for antagonist in antagonists: for antagonist in antagonists:
antagonist.kill() antagonist.kill()
if xml_report:
tree = ET.ElementTree(root)
tree.write(xml_report, encoding='UTF-8')
if cache: cache.save() if cache: cache.save()
@ -559,7 +571,8 @@ else:
result = _build_and_run(check_cancelled=lambda: False, result = _build_and_run(check_cancelled=lambda: False,
newline_on_success=args.newline_on_success, newline_on_success=args.newline_on_success,
travis=args.travis, travis=args.travis,
cache=test_cache) cache=test_cache,
xml_report=args.xml_report)
if result == 0: if result == 0:
jobset.message('SUCCESS', 'All tests passed', do_newline=True) jobset.message('SUCCESS', 'All tests passed', do_newline=True)
else: else:

File diff suppressed because it is too large Load Diff

@ -135,8 +135,8 @@ fling_server: fling_server.exe
$(OUT_DIR)\fling_server.exe $(OUT_DIR)\fling_server.exe
gen_hpack_tables.exe: build_libs $(OUT_DIR) gen_hpack_tables.exe: build_libs $(OUT_DIR)
echo Building gen_hpack_tables echo Building gen_hpack_tables
$(CC) $(CFLAGS) /Fo:$(OUT_DIR)\ $(REPO_ROOT)\src\core\transport\chttp2\gen_hpack_tables.c $(CC) $(CFLAGS) /Fo:$(OUT_DIR)\ $(REPO_ROOT)\tools\codegen\core\gen_hpack_tables.c
$(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\gen_hpack_tables.exe" Debug\grpc_test_util.lib Debug\gpr.lib Debug\grpc.lib $(LIBS) $(OUT_DIR)\gen_hpack_tables.obj $(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\gen_hpack_tables.exe" Debug\gpr.lib Debug\grpc.lib $(LIBS) $(OUT_DIR)\gen_hpack_tables.obj
gen_hpack_tables: gen_hpack_tables.exe gen_hpack_tables: gen_hpack_tables.exe
echo Running gen_hpack_tables echo Running gen_hpack_tables
$(OUT_DIR)\gen_hpack_tables.exe $(OUT_DIR)\gen_hpack_tables.exe

@ -191,6 +191,8 @@
<ClInclude Include="..\..\src\cpp\server\thread_pool.h" /> <ClInclude Include="..\..\src\cpp\server\thread_pool.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\cpp\client\secure_channel_arguments.cc">
</ClCompile>
<ClCompile Include="..\..\src\cpp\client\secure_credentials.cc"> <ClCompile Include="..\..\src\cpp\client\secure_credentials.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\secure_server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\secure_server_credentials.cc">

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\cpp\client\secure_channel_arguments.cc">
<Filter>src\cpp\client</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cpp\client\secure_credentials.cc"> <ClCompile Include="..\..\src\cpp\client\secure_credentials.cc">
<Filter>src\cpp\client</Filter> <Filter>src\cpp\client</Filter>
</ClCompile> </ClCompile>

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

Loading…
Cancel
Save