Merge github.com:grpc/grpc into status_codes

pull/5935/head
Craig Tiller 9 years ago
commit 78abce7447
  1. 50
      BUILD
  2. 110
      Makefile
  3. 10
      binding.gyp
  4. 31
      build.yaml
  5. 12
      config.m4
  6. 5
      examples/node/README.md
  7. 24
      gRPC.podspec
  8. 17
      grpc.gemspec
  9. 2
      include/grpc++/generic/async_generic_service.h
  10. 6
      include/grpc++/impl/codegen/async_stream.h
  11. 9
      include/grpc++/impl/codegen/async_unary_call.h
  12. 3
      include/grpc++/impl/codegen/call.h
  13. 3
      include/grpc++/impl/codegen/client_unary_call.h
  14. 6
      include/grpc++/impl/codegen/impl/async_stream.h
  15. 18
      include/grpc++/impl/codegen/method_handler_impl.h
  16. 2
      include/grpc++/impl/codegen/rpc_service_method.h
  17. 6
      include/grpc++/impl/codegen/server_context.h
  18. 7
      include/grpc++/impl/codegen/server_interface.h
  19. 6
      include/grpc++/impl/codegen/sync_stream.h
  20. 10
      include/grpc++/support/byte_buffer.h
  21. 4
      include/grpc++/support/channel_arguments.h
  22. 2
      include/grpc++/support/slice.h
  23. 4
      include/grpc/byte_buffer_reader.h
  24. 7
      include/grpc/compression.h
  25. 32
      include/grpc/grpc.h
  26. 9
      include/grpc/grpc_security.h
  27. 2
      include/grpc/impl/codegen/log.h
  28. 4
      include/grpc/impl/codegen/port_platform.h
  29. 4
      include/grpc/impl/codegen/slice.h
  30. 4
      include/grpc/impl/codegen/slice_buffer.h
  31. 4
      include/grpc/impl/codegen/time.h
  32. 17
      package.json
  33. 17
      package.xml
  34. 4
      setup.py
  35. 7
      src/compiler/python_generator.cc
  36. 30
      src/core/census/grpc_filter.c
  37. 2
      src/core/census/grpc_plugin.c
  38. 2
      src/core/channel/channel_args.c
  39. 14
      src/core/channel/client_channel.c
  40. 15
      src/core/channel/compress_filter.c
  41. 20
      src/core/channel/connected_channel.c
  42. 15
      src/core/channel/http_client_filter.c
  43. 15
      src/core/channel/http_server_filter.c
  44. 10
      src/core/client_config/lb_policies/pick_first.c
  45. 10
      src/core/client_config/lb_policies/round_robin.c
  46. 35
      src/core/client_config/resolvers/sockaddr_resolver.c
  47. 2
      src/core/client_config/resolvers/zookeeper_resolver.c
  48. 16
      src/core/client_config/subchannel.c
  49. 16
      src/core/client_config/subchannel.h
  50. 18
      src/core/http/format_request.c
  51. 8
      src/core/http/format_request.h
  52. 27
      src/core/http/httpcli.c
  53. 39
      src/core/http/httpcli.h
  54. 6
      src/core/http/httpcli_security_connector.c
  55. 313
      src/core/http/parser.c
  56. 116
      src/core/http/parser.h
  57. 211
      src/core/httpcli/parser.c
  58. 4
      src/core/iomgr/endpoint.h
  59. 11
      src/core/iomgr/endpoint_pair_posix.c
  60. 8
      src/core/iomgr/endpoint_pair_windows.c
  61. 4
      src/core/iomgr/fd_posix.h
  62. 4
      src/core/iomgr/iocp_windows.c
  63. 2
      src/core/iomgr/iomgr_internal.h
  64. 4
      src/core/iomgr/iomgr_posix.c
  65. 4
      src/core/iomgr/iomgr_windows.c
  66. 2
      src/core/iomgr/pollset_windows.c
  67. 12
      src/core/iomgr/resolve_address_posix.c
  68. 4
      src/core/iomgr/sockaddr_posix.h
  69. 21
      src/core/iomgr/sockaddr_utils.c
  70. 2
      src/core/iomgr/sockaddr_win32.h
  71. 14
      src/core/iomgr/socket_utils_common_posix.c
  72. 4
      src/core/iomgr/socket_utils_linux.c
  73. 2
      src/core/iomgr/socket_utils_posix.h
  74. 4
      src/core/iomgr/socket_windows.c
  75. 4
      src/core/iomgr/socket_windows.h
  76. 2
      src/core/iomgr/tcp_client.h
  77. 4
      src/core/iomgr/tcp_client_posix.c
  78. 6
      src/core/iomgr/tcp_client_windows.c
  79. 4
      src/core/iomgr/tcp_posix.c
  80. 54
      src/core/iomgr/tcp_server_posix.c
  81. 14
      src/core/iomgr/tcp_windows.c
  82. 4
      src/core/iomgr/timer.h
  83. 30
      src/core/iomgr/udp_server.c
  84. 103
      src/core/iomgr/unix_sockets_posix.c
  85. 61
      src/core/iomgr/unix_sockets_posix.h
  86. 45
      src/core/iomgr/unix_sockets_posix_noop.c
  87. 4
      src/core/iomgr/wakeup_fd_nospecial.c
  88. 6
      src/core/iomgr/wakeup_fd_posix.c
  89. 4
      src/core/iomgr/workqueue.h
  90. 4
      src/core/json/json_string.c
  91. 4
      src/core/profiling/basic_timers.c
  92. 6
      src/core/security/client_auth_filter.c
  93. 25
      src/core/security/credentials.c
  94. 9
      src/core/security/credentials.h
  95. 9
      src/core/security/google_default_credentials.c
  96. 4
      src/core/security/handshake.c
  97. 20
      src/core/security/jwt_verifier.c
  98. 11
      src/core/security/secure_endpoint.c
  99. 2
      src/core/security/secure_endpoint.h
  100. 2
      src/core/security/security_context.c
  101. Some files were not shown because too many files have changed in this diff Show More

50
BUILD

@ -190,9 +190,9 @@ cc_library(
"src/core/compression/algorithm_metadata.h", "src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h", "src/core/compression/message_compress.h",
"src/core/debug/trace.h", "src/core/debug/trace.h",
"src/core/httpcli/format_request.h", "src/core/http/format_request.h",
"src/core/httpcli/httpcli.h", "src/core/http/httpcli.h",
"src/core/httpcli/parser.h", "src/core/http/parser.h",
"src/core/iomgr/closure.h", "src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h", "src/core/iomgr/endpoint_pair.h",
@ -224,6 +224,7 @@ cc_library(
"src/core/iomgr/timer.h", "src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h", "src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h", "src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h", "src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h", "src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h", "src/core/iomgr/workqueue.h",
@ -331,9 +332,9 @@ cc_library(
"src/core/compression/compression_algorithm.c", "src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c", "src/core/compression/message_compress.c",
"src/core/debug/trace.c", "src/core/debug/trace.c",
"src/core/httpcli/format_request.c", "src/core/http/format_request.c",
"src/core/httpcli/httpcli.c", "src/core/http/httpcli.c",
"src/core/httpcli/parser.c", "src/core/http/parser.c",
"src/core/iomgr/closure.c", "src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c", "src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c", "src/core/iomgr/endpoint_pair_posix.c",
@ -368,6 +369,8 @@ cc_library(
"src/core/iomgr/timer.c", "src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c", "src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c", "src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c", "src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c", "src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c", "src/core/iomgr/wakeup_fd_pipe.c",
@ -429,7 +432,7 @@ cc_library(
"src/core/transport/static_metadata.c", "src/core/transport/static_metadata.c",
"src/core/transport/transport.c", "src/core/transport/transport.c",
"src/core/transport/transport_op_string.c", "src/core/transport/transport_op_string.c",
"src/core/httpcli/httpcli_security_connector.c", "src/core/http/httpcli_security_connector.c",
"src/core/security/b64.c", "src/core/security/b64.c",
"src/core/security/client_auth_filter.c", "src/core/security/client_auth_filter.c",
"src/core/security/credentials.c", "src/core/security/credentials.c",
@ -562,9 +565,9 @@ cc_library(
"src/core/compression/algorithm_metadata.h", "src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h", "src/core/compression/message_compress.h",
"src/core/debug/trace.h", "src/core/debug/trace.h",
"src/core/httpcli/format_request.h", "src/core/http/format_request.h",
"src/core/httpcli/httpcli.h", "src/core/http/httpcli.h",
"src/core/httpcli/parser.h", "src/core/http/parser.h",
"src/core/iomgr/closure.h", "src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h", "src/core/iomgr/endpoint_pair.h",
@ -596,6 +599,7 @@ cc_library(
"src/core/iomgr/timer.h", "src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h", "src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h", "src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h", "src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h", "src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h", "src/core/iomgr/workqueue.h",
@ -690,9 +694,9 @@ cc_library(
"src/core/compression/compression_algorithm.c", "src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c", "src/core/compression/message_compress.c",
"src/core/debug/trace.c", "src/core/debug/trace.c",
"src/core/httpcli/format_request.c", "src/core/http/format_request.c",
"src/core/httpcli/httpcli.c", "src/core/http/httpcli.c",
"src/core/httpcli/parser.c", "src/core/http/parser.c",
"src/core/iomgr/closure.c", "src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c", "src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c", "src/core/iomgr/endpoint_pair_posix.c",
@ -727,6 +731,8 @@ cc_library(
"src/core/iomgr/timer.c", "src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c", "src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c", "src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c", "src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c", "src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c", "src/core/iomgr/wakeup_fd_pipe.c",
@ -1041,7 +1047,6 @@ cc_library(
".", ".",
], ],
deps = [ deps = [
"//external:protobuf_compiler",
], ],
) )
@ -1390,9 +1395,9 @@ objc_library(
"src/core/compression/compression_algorithm.c", "src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c", "src/core/compression/message_compress.c",
"src/core/debug/trace.c", "src/core/debug/trace.c",
"src/core/httpcli/format_request.c", "src/core/http/format_request.c",
"src/core/httpcli/httpcli.c", "src/core/http/httpcli.c",
"src/core/httpcli/parser.c", "src/core/http/parser.c",
"src/core/iomgr/closure.c", "src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c", "src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c", "src/core/iomgr/endpoint_pair_posix.c",
@ -1427,6 +1432,8 @@ objc_library(
"src/core/iomgr/timer.c", "src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c", "src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c", "src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c", "src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c", "src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c", "src/core/iomgr/wakeup_fd_pipe.c",
@ -1488,7 +1495,7 @@ objc_library(
"src/core/transport/static_metadata.c", "src/core/transport/static_metadata.c",
"src/core/transport/transport.c", "src/core/transport/transport.c",
"src/core/transport/transport_op_string.c", "src/core/transport/transport_op_string.c",
"src/core/httpcli/httpcli_security_connector.c", "src/core/http/httpcli_security_connector.c",
"src/core/security/b64.c", "src/core/security/b64.c",
"src/core/security/client_auth_filter.c", "src/core/security/client_auth_filter.c",
"src/core/security/credentials.c", "src/core/security/credentials.c",
@ -1566,9 +1573,9 @@ objc_library(
"src/core/compression/algorithm_metadata.h", "src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h", "src/core/compression/message_compress.h",
"src/core/debug/trace.h", "src/core/debug/trace.h",
"src/core/httpcli/format_request.h", "src/core/http/format_request.h",
"src/core/httpcli/httpcli.h", "src/core/http/httpcli.h",
"src/core/httpcli/parser.h", "src/core/http/parser.h",
"src/core/iomgr/closure.h", "src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h", "src/core/iomgr/endpoint_pair.h",
@ -1600,6 +1607,7 @@ objc_library(
"src/core/iomgr/timer.h", "src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h", "src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h", "src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h", "src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h", "src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h", "src/core/iomgr/workqueue.h",

@ -927,8 +927,8 @@ grpc_security_connector_test: $(BINDIR)/$(CONFIG)/grpc_security_connector_test
grpc_verify_jwt: $(BINDIR)/$(CONFIG)/grpc_verify_jwt grpc_verify_jwt: $(BINDIR)/$(CONFIG)/grpc_verify_jwt
hpack_parser_test: $(BINDIR)/$(CONFIG)/hpack_parser_test hpack_parser_test: $(BINDIR)/$(CONFIG)/hpack_parser_test
hpack_table_test: $(BINDIR)/$(CONFIG)/hpack_table_test hpack_table_test: $(BINDIR)/$(CONFIG)/hpack_table_test
http_parser_test: $(BINDIR)/$(CONFIG)/http_parser_test
httpcli_format_request_test: $(BINDIR)/$(CONFIG)/httpcli_format_request_test httpcli_format_request_test: $(BINDIR)/$(CONFIG)/httpcli_format_request_test
httpcli_parser_test: $(BINDIR)/$(CONFIG)/httpcli_parser_test
httpcli_test: $(BINDIR)/$(CONFIG)/httpcli_test httpcli_test: $(BINDIR)/$(CONFIG)/httpcli_test
httpscli_test: $(BINDIR)/$(CONFIG)/httpscli_test httpscli_test: $(BINDIR)/$(CONFIG)/httpscli_test
init_test: $(BINDIR)/$(CONFIG)/init_test init_test: $(BINDIR)/$(CONFIG)/init_test
@ -1129,13 +1129,13 @@ static: static_c static_cxx
static_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a static_zookeeper_libs static_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a static_zookeeper_libs
static_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a static_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib.a $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a
shared: shared_c shared_cxx shared: shared_c shared_cxx
shared_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)gpr$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT) shared_zookeeper_libs shared_c: pc_c pc_c_unsecure cache.mk pc_c_zookeeper $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)gpr$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION).$(SHARED_EXT) shared_zookeeper_libs
shared_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT) shared_cxx: pc_cxx pc_cxx_unsecure cache.mk $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT)
shared_csharp: shared_c $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION).$(SHARED_EXT) shared_csharp: shared_c $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION).$(SHARED_EXT)
ifeq ($(HAS_ZOOKEEPER),true) ifeq ($(HAS_ZOOKEEPER),true)
@ -1236,8 +1236,8 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/grpc_security_connector_test \ $(BINDIR)/$(CONFIG)/grpc_security_connector_test \
$(BINDIR)/$(CONFIG)/hpack_parser_test \ $(BINDIR)/$(CONFIG)/hpack_parser_test \
$(BINDIR)/$(CONFIG)/hpack_table_test \ $(BINDIR)/$(CONFIG)/hpack_table_test \
$(BINDIR)/$(CONFIG)/http_parser_test \
$(BINDIR)/$(CONFIG)/httpcli_format_request_test \ $(BINDIR)/$(CONFIG)/httpcli_format_request_test \
$(BINDIR)/$(CONFIG)/httpcli_parser_test \
$(BINDIR)/$(CONFIG)/httpcli_test \ $(BINDIR)/$(CONFIG)/httpcli_test \
$(BINDIR)/$(CONFIG)/httpscli_test \ $(BINDIR)/$(CONFIG)/httpscli_test \
$(BINDIR)/$(CONFIG)/init_test \ $(BINDIR)/$(CONFIG)/init_test \
@ -1522,10 +1522,10 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/hpack_parser_test || ( echo test hpack_parser_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/hpack_parser_test || ( echo test hpack_parser_test failed ; exit 1 )
$(E) "[RUN] Testing hpack_table_test" $(E) "[RUN] Testing hpack_table_test"
$(Q) $(BINDIR)/$(CONFIG)/hpack_table_test || ( echo test hpack_table_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/hpack_table_test || ( echo test hpack_table_test failed ; exit 1 )
$(E) "[RUN] Testing http_parser_test"
$(Q) $(BINDIR)/$(CONFIG)/http_parser_test || ( echo test http_parser_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_format_request_test" $(E) "[RUN] Testing httpcli_format_request_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_format_request_test || ( echo test httpcli_format_request_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/httpcli_format_request_test || ( echo test httpcli_format_request_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_parser_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_parser_test || ( echo test httpcli_parser_test failed ; exit 1 )
$(E) "[RUN] Testing httpcli_test" $(E) "[RUN] Testing httpcli_test"
$(Q) $(BINDIR)/$(CONFIG)/httpcli_test || ( echo test httpcli_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/httpcli_test || ( echo test httpcli_test failed ; exit 1 )
$(E) "[RUN] Testing httpscli_test" $(E) "[RUN] Testing httpscli_test"
@ -1754,6 +1754,8 @@ strip-static_cxx: static_cxx
ifeq ($(CONFIG),opt) ifeq ($(CONFIG),opt)
$(E) "[STRIP] Stripping libgrpc++.a" $(E) "[STRIP] Stripping libgrpc++.a"
$(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++.a
$(E) "[STRIP] Stripping libgrpc++_codegen_lib.a"
$(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib.a
$(E) "[STRIP] Stripping libgrpc++_unsecure.a" $(E) "[STRIP] Stripping libgrpc++_unsecure.a"
$(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a
endif endif
@ -1776,6 +1778,8 @@ strip-shared_cxx: shared_cxx
ifeq ($(CONFIG),opt) ifeq ($(CONFIG),opt)
$(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT)" $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT)"
$(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT)
$(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT)"
$(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT)
$(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT)" $(E) "[STRIP] Stripping $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT)"
$(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT) $(Q) $(STRIP) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT)
endif endif
@ -2087,6 +2091,9 @@ install-static_cxx: static_cxx strip-static_cxx install-pkg-config_cxx
$(E) "[INSTALL] Installing libgrpc++.a" $(E) "[INSTALL] Installing libgrpc++.a"
$(Q) $(INSTALL) -d $(prefix)/lib $(Q) $(INSTALL) -d $(prefix)/lib
$(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(prefix)/lib/libgrpc++.a $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++.a $(prefix)/lib/libgrpc++.a
$(E) "[INSTALL] Installing libgrpc++_codegen_lib.a"
$(Q) $(INSTALL) -d $(prefix)/lib
$(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib.a $(prefix)/lib/libgrpc++_codegen_lib.a
$(E) "[INSTALL] Installing libgrpc++_unsecure.a" $(E) "[INSTALL] Installing libgrpc++_unsecure.a"
$(Q) $(INSTALL) -d $(prefix)/lib $(Q) $(INSTALL) -d $(prefix)/lib
$(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(prefix)/lib/libgrpc++_unsecure.a $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure.a $(prefix)/lib/libgrpc++_unsecure.a
@ -2148,6 +2155,15 @@ ifeq ($(SYSTEM),MINGW32)
else ifneq ($(SYSTEM),Darwin) else ifneq ($(SYSTEM),Darwin)
$(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++.so.0 $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++.so.0
$(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++.so $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++.so
endif
$(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT)"
$(Q) $(INSTALL) -d $(prefix)/lib
$(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/$(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT)
ifeq ($(SYSTEM),MINGW32)
$(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib-imp.a $(prefix)/lib/libgrpc++_codegen_lib-imp.a
else ifneq ($(SYSTEM),Darwin)
$(Q) ln -sf $(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++_codegen_lib.so.0
$(Q) ln -sf $(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(prefix)/lib/libgrpc++_codegen_lib.so
endif endif
$(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT)" $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION).$(SHARED_EXT)"
$(Q) $(INSTALL) -d $(prefix)/lib $(Q) $(INSTALL) -d $(prefix)/lib
@ -2437,9 +2453,9 @@ LIBGRPC_SRC = \
src/core/compression/compression_algorithm.c \ src/core/compression/compression_algorithm.c \
src/core/compression/message_compress.c \ src/core/compression/message_compress.c \
src/core/debug/trace.c \ src/core/debug/trace.c \
src/core/httpcli/format_request.c \ src/core/http/format_request.c \
src/core/httpcli/httpcli.c \ src/core/http/httpcli.c \
src/core/httpcli/parser.c \ src/core/http/parser.c \
src/core/iomgr/closure.c \ src/core/iomgr/closure.c \
src/core/iomgr/endpoint.c \ src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \ src/core/iomgr/endpoint_pair_posix.c \
@ -2474,6 +2490,8 @@ LIBGRPC_SRC = \
src/core/iomgr/timer.c \ src/core/iomgr/timer.c \
src/core/iomgr/timer_heap.c \ src/core/iomgr/timer_heap.c \
src/core/iomgr/udp_server.c \ src/core/iomgr/udp_server.c \
src/core/iomgr/unix_sockets_posix.c \
src/core/iomgr/unix_sockets_posix_noop.c \
src/core/iomgr/wakeup_fd_eventfd.c \ src/core/iomgr/wakeup_fd_eventfd.c \
src/core/iomgr/wakeup_fd_nospecial.c \ src/core/iomgr/wakeup_fd_nospecial.c \
src/core/iomgr/wakeup_fd_pipe.c \ src/core/iomgr/wakeup_fd_pipe.c \
@ -2535,7 +2553,7 @@ LIBGRPC_SRC = \
src/core/transport/static_metadata.c \ src/core/transport/static_metadata.c \
src/core/transport/transport.c \ src/core/transport/transport.c \
src/core/transport/transport_op_string.c \ src/core/transport/transport_op_string.c \
src/core/httpcli/httpcli_security_connector.c \ src/core/http/httpcli_security_connector.c \
src/core/security/b64.c \ src/core/security/b64.c \
src/core/security/client_auth_filter.c \ src/core/security/client_auth_filter.c \
src/core/security/credentials.c \ src/core/security/credentials.c \
@ -2797,9 +2815,9 @@ LIBGRPC_UNSECURE_SRC = \
src/core/compression/compression_algorithm.c \ src/core/compression/compression_algorithm.c \
src/core/compression/message_compress.c \ src/core/compression/message_compress.c \
src/core/debug/trace.c \ src/core/debug/trace.c \
src/core/httpcli/format_request.c \ src/core/http/format_request.c \
src/core/httpcli/httpcli.c \ src/core/http/httpcli.c \
src/core/httpcli/parser.c \ src/core/http/parser.c \
src/core/iomgr/closure.c \ src/core/iomgr/closure.c \
src/core/iomgr/endpoint.c \ src/core/iomgr/endpoint.c \
src/core/iomgr/endpoint_pair_posix.c \ src/core/iomgr/endpoint_pair_posix.c \
@ -2834,6 +2852,8 @@ LIBGRPC_UNSECURE_SRC = \
src/core/iomgr/timer.c \ src/core/iomgr/timer.c \
src/core/iomgr/timer_heap.c \ src/core/iomgr/timer_heap.c \
src/core/iomgr/udp_server.c \ src/core/iomgr/udp_server.c \
src/core/iomgr/unix_sockets_posix.c \
src/core/iomgr/unix_sockets_posix_noop.c \
src/core/iomgr/wakeup_fd_eventfd.c \ src/core/iomgr/wakeup_fd_eventfd.c \
src/core/iomgr/wakeup_fd_nospecial.c \ src/core/iomgr/wakeup_fd_nospecial.c \
src/core/iomgr/wakeup_fd_pipe.c \ src/core/iomgr/wakeup_fd_pipe.c \
@ -3313,6 +3333,7 @@ ifeq ($(NO_PROTOBUF),true)
$(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib.a: protobuf_dep_error $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib.a: protobuf_dep_error
$(LIBDIR)/$(CONFIG)/$(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT): protobuf_dep_error
else else
@ -3327,6 +3348,23 @@ endif
ifeq ($(SYSTEM),MINGW32)
$(LIBDIR)/$(CONFIG)/grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT): $(LIBGRPC++_CODEGEN_LIB_OBJS) $(ZLIB_DEP) $(PROTOBUF_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared grpc++_codegen_lib.def -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc++_codegen_lib$(SHARED_VERSION).def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib$(SHARED_VERSION)-dll.a -o $(LIBDIR)/$(CONFIG)/grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_CODEGEN_LIB_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF)
else
$(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT): $(LIBGRPC++_CODEGEN_LIB_OBJS) $(ZLIB_DEP) $(PROTOBUF_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
ifeq ($(SYSTEM),Darwin)
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_CODEGEN_LIB_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF)
else
$(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_codegen_lib.so.0 -o $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(LIBGRPC++_CODEGEN_LIB_OBJS) $(LDLIBS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF)
$(Q) ln -sf $(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib$(SHARED_VERSION).so.0
$(Q) ln -sf $(SHARED_PREFIX)grpc++_codegen_lib$(SHARED_VERSION).$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc++_codegen_lib$(SHARED_VERSION).so
endif
endif
endif endif
@ -7757,72 +7795,72 @@ endif
endif endif
HTTPCLI_FORMAT_REQUEST_TEST_SRC = \ HTTP_PARSER_TEST_SRC = \
test/core/httpcli/format_request_test.c \ test/core/http/parser_test.c \
HTTPCLI_FORMAT_REQUEST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_FORMAT_REQUEST_TEST_SRC)))) HTTP_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTP_PARSER_TEST_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL. # You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/httpcli_format_request_test: openssl_dep_error $(BINDIR)/$(CONFIG)/http_parser_test: openssl_dep_error
else else
$(BINDIR)/$(CONFIG)/httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(BINDIR)/$(CONFIG)/http_parser_test: $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test $(Q) $(LD) $(LDFLAGS) $(HTTP_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/http_parser_test
endif endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/format_request_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/core/http/parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep) deps_http_parser_test: $(HTTP_PARSER_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true) ifneq ($(NO_DEPS),true)
-include $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep) -include $(HTTP_PARSER_TEST_OBJS:.o=.dep)
endif endif
endif endif
HTTPCLI_PARSER_TEST_SRC = \ HTTPCLI_FORMAT_REQUEST_TEST_SRC = \
test/core/httpcli/parser_test.c \ test/core/http/format_request_test.c \
HTTPCLI_PARSER_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_PARSER_TEST_SRC)))) HTTPCLI_FORMAT_REQUEST_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_FORMAT_REQUEST_TEST_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL. # You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/httpcli_parser_test: openssl_dep_error $(BINDIR)/$(CONFIG)/httpcli_format_request_test: openssl_dep_error
else else
$(BINDIR)/$(CONFIG)/httpcli_parser_test: $(HTTPCLI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(BINDIR)/$(CONFIG)/httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@" $(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(HTTPCLI_PARSER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_parser_test $(Q) $(LD) $(LDFLAGS) $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/httpcli_format_request_test
endif endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/parser_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/core/http/format_request_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpcli_parser_test: $(HTTPCLI_PARSER_TEST_OBJS:.o=.dep) deps_httpcli_format_request_test: $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true) ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true) ifneq ($(NO_DEPS),true)
-include $(HTTPCLI_PARSER_TEST_OBJS:.o=.dep) -include $(HTTPCLI_FORMAT_REQUEST_TEST_OBJS:.o=.dep)
endif endif
endif endif
HTTPCLI_TEST_SRC = \ HTTPCLI_TEST_SRC = \
test/core/httpcli/httpcli_test.c \ test/core/http/httpcli_test.c \
HTTPCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_TEST_SRC)))) HTTPCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPCLI_TEST_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
@ -7842,7 +7880,7 @@ $(BINDIR)/$(CONFIG)/httpcli_test: $(HTTPCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgr
endif endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/httpcli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/core/http/httpcli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpcli_test: $(HTTPCLI_TEST_OBJS:.o=.dep) deps_httpcli_test: $(HTTPCLI_TEST_OBJS:.o=.dep)
@ -7854,7 +7892,7 @@ endif
HTTPSCLI_TEST_SRC = \ HTTPSCLI_TEST_SRC = \
test/core/httpcli/httpscli_test.c \ test/core/http/httpscli_test.c \
HTTPSCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPSCLI_TEST_SRC)))) HTTPSCLI_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(HTTPSCLI_TEST_SRC))))
ifeq ($(NO_SECURE),true) ifeq ($(NO_SECURE),true)
@ -7874,7 +7912,7 @@ $(BINDIR)/$(CONFIG)/httpscli_test: $(HTTPSCLI_TEST_OBJS) $(LIBDIR)/$(CONFIG)/lib
endif endif
$(OBJDIR)/$(CONFIG)/test/core/httpcli/httpscli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OBJDIR)/$(CONFIG)/test/core/http/httpscli_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_httpscli_test: $(HTTPSCLI_TEST_OBJS:.o=.dep) deps_httpscli_test: $(HTTPSCLI_TEST_OBJS:.o=.dep)
@ -13378,7 +13416,7 @@ ifneq ($(OPENSSL_DEP),)
# This is to ensure the embedded OpenSSL is built beforehand, properly # This is to ensure the embedded OpenSSL is built beforehand, properly
# installing headers to their final destination on the drive. We need this # installing headers to their final destination on the drive. We need this
# otherwise parallel compilation will fail if a source is compiled first. # otherwise parallel compilation will fail if a source is compiled first.
src/core/httpcli/httpcli_security_connector.c: $(OPENSSL_DEP) src/core/http/httpcli_security_connector.c: $(OPENSSL_DEP)
src/core/security/b64.c: $(OPENSSL_DEP) src/core/security/b64.c: $(OPENSSL_DEP)
src/core/security/client_auth_filter.c: $(OPENSSL_DEP) src/core/security/client_auth_filter.c: $(OPENSSL_DEP)
src/core/security/credentials.c: $(OPENSSL_DEP) src/core/security/credentials.c: $(OPENSSL_DEP)

@ -592,9 +592,9 @@
'src/core/compression/compression_algorithm.c', 'src/core/compression/compression_algorithm.c',
'src/core/compression/message_compress.c', 'src/core/compression/message_compress.c',
'src/core/debug/trace.c', 'src/core/debug/trace.c',
'src/core/httpcli/format_request.c', 'src/core/http/format_request.c',
'src/core/httpcli/httpcli.c', 'src/core/http/httpcli.c',
'src/core/httpcli/parser.c', 'src/core/http/parser.c',
'src/core/iomgr/closure.c', 'src/core/iomgr/closure.c',
'src/core/iomgr/endpoint.c', 'src/core/iomgr/endpoint.c',
'src/core/iomgr/endpoint_pair_posix.c', 'src/core/iomgr/endpoint_pair_posix.c',
@ -629,6 +629,8 @@
'src/core/iomgr/timer.c', 'src/core/iomgr/timer.c',
'src/core/iomgr/timer_heap.c', 'src/core/iomgr/timer_heap.c',
'src/core/iomgr/udp_server.c', 'src/core/iomgr/udp_server.c',
'src/core/iomgr/unix_sockets_posix.c',
'src/core/iomgr/unix_sockets_posix_noop.c',
'src/core/iomgr/wakeup_fd_eventfd.c', 'src/core/iomgr/wakeup_fd_eventfd.c',
'src/core/iomgr/wakeup_fd_nospecial.c', 'src/core/iomgr/wakeup_fd_nospecial.c',
'src/core/iomgr/wakeup_fd_pipe.c', 'src/core/iomgr/wakeup_fd_pipe.c',
@ -690,7 +692,7 @@
'src/core/transport/static_metadata.c', 'src/core/transport/static_metadata.c',
'src/core/transport/transport.c', 'src/core/transport/transport.c',
'src/core/transport/transport_op_string.c', 'src/core/transport/transport_op_string.c',
'src/core/httpcli/httpcli_security_connector.c', 'src/core/http/httpcli_security_connector.c',
'src/core/security/b64.c', 'src/core/security/b64.c',
'src/core/security/client_auth_filter.c', 'src/core/security/client_auth_filter.c',
'src/core/security/credentials.c', 'src/core/security/credentials.c',

@ -280,9 +280,9 @@ filegroups:
- src/core/compression/algorithm_metadata.h - src/core/compression/algorithm_metadata.h
- src/core/compression/message_compress.h - src/core/compression/message_compress.h
- src/core/debug/trace.h - src/core/debug/trace.h
- src/core/httpcli/format_request.h - src/core/http/format_request.h
- src/core/httpcli/httpcli.h - src/core/http/httpcli.h
- src/core/httpcli/parser.h - src/core/http/parser.h
- src/core/iomgr/closure.h - src/core/iomgr/closure.h
- src/core/iomgr/endpoint.h - src/core/iomgr/endpoint.h
- src/core/iomgr/endpoint_pair.h - src/core/iomgr/endpoint_pair.h
@ -314,6 +314,7 @@ filegroups:
- src/core/iomgr/timer.h - src/core/iomgr/timer.h
- src/core/iomgr/timer_heap.h - src/core/iomgr/timer_heap.h
- src/core/iomgr/udp_server.h - src/core/iomgr/udp_server.h
- src/core/iomgr/unix_sockets_posix.h
- src/core/iomgr/wakeup_fd_pipe.h - src/core/iomgr/wakeup_fd_pipe.h
- src/core/iomgr/wakeup_fd_posix.h - src/core/iomgr/wakeup_fd_posix.h
- src/core/iomgr/workqueue.h - src/core/iomgr/workqueue.h
@ -401,9 +402,9 @@ filegroups:
- src/core/compression/compression_algorithm.c - src/core/compression/compression_algorithm.c
- src/core/compression/message_compress.c - src/core/compression/message_compress.c
- src/core/debug/trace.c - src/core/debug/trace.c
- src/core/httpcli/format_request.c - src/core/http/format_request.c
- src/core/httpcli/httpcli.c - src/core/http/httpcli.c
- src/core/httpcli/parser.c - src/core/http/parser.c
- src/core/iomgr/closure.c - src/core/iomgr/closure.c
- src/core/iomgr/endpoint.c - src/core/iomgr/endpoint.c
- src/core/iomgr/endpoint_pair_posix.c - src/core/iomgr/endpoint_pair_posix.c
@ -438,6 +439,8 @@ filegroups:
- src/core/iomgr/timer.c - src/core/iomgr/timer.c
- src/core/iomgr/timer_heap.c - src/core/iomgr/timer_heap.c
- src/core/iomgr/udp_server.c - src/core/iomgr/udp_server.c
- src/core/iomgr/unix_sockets_posix.c
- src/core/iomgr/unix_sockets_posix_noop.c
- src/core/iomgr/wakeup_fd_eventfd.c - src/core/iomgr/wakeup_fd_eventfd.c
- src/core/iomgr/wakeup_fd_nospecial.c - src/core/iomgr/wakeup_fd_nospecial.c
- src/core/iomgr/wakeup_fd_pipe.c - src/core/iomgr/wakeup_fd_pipe.c
@ -524,7 +527,7 @@ filegroups:
- src/core/tsi/transport_security.h - src/core/tsi/transport_security.h
- src/core/tsi/transport_security_interface.h - src/core/tsi/transport_security_interface.h
src: src:
- src/core/httpcli/httpcli_security_connector.c - src/core/http/httpcli_security_connector.c
- src/core/security/b64.c - src/core/security/b64.c
- src/core/security/client_auth_filter.c - src/core/security/client_auth_filter.c
- src/core/security/credentials.c - src/core/security/credentials.c
@ -760,7 +763,7 @@ libs:
secure: check secure: check
vs_project_guid: '{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}' vs_project_guid: '{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}'
- name: grpc++_codegen_lib - name: grpc++_codegen_lib
build: protoc build: all
language: c++ language: c++
headers: [] headers: []
src: [] src: []
@ -1560,21 +1563,21 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: httpcli_format_request_test - name: http_parser_test
build: test build: test
language: c language: c
src: src:
- test/core/httpcli/format_request_test.c - test/core/http/parser_test.c
deps: deps:
- grpc_test_util - grpc_test_util
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: httpcli_parser_test - name: httpcli_format_request_test
build: test build: test
language: c language: c
src: src:
- test/core/httpcli/parser_test.c - test/core/http/format_request_test.c
deps: deps:
- grpc_test_util - grpc_test_util
- grpc - grpc
@ -1585,7 +1588,7 @@ targets:
build: test build: test
language: c language: c
src: src:
- test/core/httpcli/httpcli_test.c - test/core/http/httpcli_test.c
deps: deps:
- grpc_test_util - grpc_test_util
- grpc - grpc
@ -1600,7 +1603,7 @@ targets:
build: test build: test
language: c language: c
src: src:
- test/core/httpcli/httpscli_test.c - test/core/http/httpscli_test.c
deps: deps:
- grpc_test_util - grpc_test_util
- grpc - grpc

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

@ -10,6 +10,11 @@ INSTALL
------- -------
```sh ```sh
$ # Get the gRPC repository
$ export REPO_ROOT=grpc # REPO root can be any directory of your choice
$ git clone https://github.com/grpc/grpc.git $REPO_ROOT
$ cd $REPO_ROOT
$ cd examples/node $ cd examples/node
$ npm install $ npm install
``` ```

@ -194,9 +194,9 @@ Pod::Spec.new do |s|
'src/core/compression/algorithm_metadata.h', 'src/core/compression/algorithm_metadata.h',
'src/core/compression/message_compress.h', 'src/core/compression/message_compress.h',
'src/core/debug/trace.h', 'src/core/debug/trace.h',
'src/core/httpcli/format_request.h', 'src/core/http/format_request.h',
'src/core/httpcli/httpcli.h', 'src/core/http/httpcli.h',
'src/core/httpcli/parser.h', 'src/core/http/parser.h',
'src/core/iomgr/closure.h', 'src/core/iomgr/closure.h',
'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint.h',
'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/endpoint_pair.h',
@ -228,6 +228,7 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.h', 'src/core/iomgr/timer.h',
'src/core/iomgr/timer_heap.h', 'src/core/iomgr/timer_heap.h',
'src/core/iomgr/udp_server.h', 'src/core/iomgr/udp_server.h',
'src/core/iomgr/unix_sockets_posix.h',
'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_pipe.h',
'src/core/iomgr/wakeup_fd_posix.h', 'src/core/iomgr/wakeup_fd_posix.h',
'src/core/iomgr/workqueue.h', 'src/core/iomgr/workqueue.h',
@ -348,9 +349,9 @@ Pod::Spec.new do |s|
'src/core/compression/compression_algorithm.c', 'src/core/compression/compression_algorithm.c',
'src/core/compression/message_compress.c', 'src/core/compression/message_compress.c',
'src/core/debug/trace.c', 'src/core/debug/trace.c',
'src/core/httpcli/format_request.c', 'src/core/http/format_request.c',
'src/core/httpcli/httpcli.c', 'src/core/http/httpcli.c',
'src/core/httpcli/parser.c', 'src/core/http/parser.c',
'src/core/iomgr/closure.c', 'src/core/iomgr/closure.c',
'src/core/iomgr/endpoint.c', 'src/core/iomgr/endpoint.c',
'src/core/iomgr/endpoint_pair_posix.c', 'src/core/iomgr/endpoint_pair_posix.c',
@ -385,6 +386,8 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.c', 'src/core/iomgr/timer.c',
'src/core/iomgr/timer_heap.c', 'src/core/iomgr/timer_heap.c',
'src/core/iomgr/udp_server.c', 'src/core/iomgr/udp_server.c',
'src/core/iomgr/unix_sockets_posix.c',
'src/core/iomgr/unix_sockets_posix_noop.c',
'src/core/iomgr/wakeup_fd_eventfd.c', 'src/core/iomgr/wakeup_fd_eventfd.c',
'src/core/iomgr/wakeup_fd_nospecial.c', 'src/core/iomgr/wakeup_fd_nospecial.c',
'src/core/iomgr/wakeup_fd_pipe.c', 'src/core/iomgr/wakeup_fd_pipe.c',
@ -446,7 +449,7 @@ Pod::Spec.new do |s|
'src/core/transport/static_metadata.c', 'src/core/transport/static_metadata.c',
'src/core/transport/transport.c', 'src/core/transport/transport.c',
'src/core/transport/transport_op_string.c', 'src/core/transport/transport_op_string.c',
'src/core/httpcli/httpcli_security_connector.c', 'src/core/http/httpcli_security_connector.c',
'src/core/security/b64.c', 'src/core/security/b64.c',
'src/core/security/client_auth_filter.c', 'src/core/security/client_auth_filter.c',
'src/core/security/credentials.c', 'src/core/security/credentials.c',
@ -522,9 +525,9 @@ Pod::Spec.new do |s|
'src/core/compression/algorithm_metadata.h', 'src/core/compression/algorithm_metadata.h',
'src/core/compression/message_compress.h', 'src/core/compression/message_compress.h',
'src/core/debug/trace.h', 'src/core/debug/trace.h',
'src/core/httpcli/format_request.h', 'src/core/http/format_request.h',
'src/core/httpcli/httpcli.h', 'src/core/http/httpcli.h',
'src/core/httpcli/parser.h', 'src/core/http/parser.h',
'src/core/iomgr/closure.h', 'src/core/iomgr/closure.h',
'src/core/iomgr/endpoint.h', 'src/core/iomgr/endpoint.h',
'src/core/iomgr/endpoint_pair.h', 'src/core/iomgr/endpoint_pair.h',
@ -556,6 +559,7 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.h', 'src/core/iomgr/timer.h',
'src/core/iomgr/timer_heap.h', 'src/core/iomgr/timer_heap.h',
'src/core/iomgr/udp_server.h', 'src/core/iomgr/udp_server.h',
'src/core/iomgr/unix_sockets_posix.h',
'src/core/iomgr/wakeup_fd_pipe.h', 'src/core/iomgr/wakeup_fd_pipe.h',
'src/core/iomgr/wakeup_fd_posix.h', 'src/core/iomgr/wakeup_fd_posix.h',
'src/core/iomgr/workqueue.h', 'src/core/iomgr/workqueue.h',

@ -190,9 +190,9 @@ Gem::Specification.new do |s|
s.files += %w( src/core/compression/algorithm_metadata.h ) s.files += %w( src/core/compression/algorithm_metadata.h )
s.files += %w( src/core/compression/message_compress.h ) s.files += %w( src/core/compression/message_compress.h )
s.files += %w( src/core/debug/trace.h ) s.files += %w( src/core/debug/trace.h )
s.files += %w( src/core/httpcli/format_request.h ) s.files += %w( src/core/http/format_request.h )
s.files += %w( src/core/httpcli/httpcli.h ) s.files += %w( src/core/http/httpcli.h )
s.files += %w( src/core/httpcli/parser.h ) s.files += %w( src/core/http/parser.h )
s.files += %w( src/core/iomgr/closure.h ) s.files += %w( src/core/iomgr/closure.h )
s.files += %w( src/core/iomgr/endpoint.h ) s.files += %w( src/core/iomgr/endpoint.h )
s.files += %w( src/core/iomgr/endpoint_pair.h ) s.files += %w( src/core/iomgr/endpoint_pair.h )
@ -224,6 +224,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/iomgr/timer.h ) s.files += %w( src/core/iomgr/timer.h )
s.files += %w( src/core/iomgr/timer_heap.h ) s.files += %w( src/core/iomgr/timer_heap.h )
s.files += %w( src/core/iomgr/udp_server.h ) s.files += %w( src/core/iomgr/udp_server.h )
s.files += %w( src/core/iomgr/unix_sockets_posix.h )
s.files += %w( src/core/iomgr/wakeup_fd_pipe.h ) s.files += %w( src/core/iomgr/wakeup_fd_pipe.h )
s.files += %w( src/core/iomgr/wakeup_fd_posix.h ) s.files += %w( src/core/iomgr/wakeup_fd_posix.h )
s.files += %w( src/core/iomgr/workqueue.h ) s.files += %w( src/core/iomgr/workqueue.h )
@ -331,9 +332,9 @@ Gem::Specification.new do |s|
s.files += %w( src/core/compression/compression_algorithm.c ) s.files += %w( src/core/compression/compression_algorithm.c )
s.files += %w( src/core/compression/message_compress.c ) s.files += %w( src/core/compression/message_compress.c )
s.files += %w( src/core/debug/trace.c ) s.files += %w( src/core/debug/trace.c )
s.files += %w( src/core/httpcli/format_request.c ) s.files += %w( src/core/http/format_request.c )
s.files += %w( src/core/httpcli/httpcli.c ) s.files += %w( src/core/http/httpcli.c )
s.files += %w( src/core/httpcli/parser.c ) s.files += %w( src/core/http/parser.c )
s.files += %w( src/core/iomgr/closure.c ) s.files += %w( src/core/iomgr/closure.c )
s.files += %w( src/core/iomgr/endpoint.c ) s.files += %w( src/core/iomgr/endpoint.c )
s.files += %w( src/core/iomgr/endpoint_pair_posix.c ) s.files += %w( src/core/iomgr/endpoint_pair_posix.c )
@ -368,6 +369,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/iomgr/timer.c ) s.files += %w( src/core/iomgr/timer.c )
s.files += %w( src/core/iomgr/timer_heap.c ) s.files += %w( src/core/iomgr/timer_heap.c )
s.files += %w( src/core/iomgr/udp_server.c ) s.files += %w( src/core/iomgr/udp_server.c )
s.files += %w( src/core/iomgr/unix_sockets_posix.c )
s.files += %w( src/core/iomgr/unix_sockets_posix_noop.c )
s.files += %w( src/core/iomgr/wakeup_fd_eventfd.c ) s.files += %w( src/core/iomgr/wakeup_fd_eventfd.c )
s.files += %w( src/core/iomgr/wakeup_fd_nospecial.c ) s.files += %w( src/core/iomgr/wakeup_fd_nospecial.c )
s.files += %w( src/core/iomgr/wakeup_fd_pipe.c ) s.files += %w( src/core/iomgr/wakeup_fd_pipe.c )
@ -429,7 +432,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/transport/static_metadata.c ) s.files += %w( src/core/transport/static_metadata.c )
s.files += %w( src/core/transport/transport.c ) s.files += %w( src/core/transport/transport.c )
s.files += %w( src/core/transport/transport_op_string.c ) s.files += %w( src/core/transport/transport_op_string.c )
s.files += %w( src/core/httpcli/httpcli_security_connector.c ) s.files += %w( src/core/http/httpcli_security_connector.c )
s.files += %w( src/core/security/b64.c ) s.files += %w( src/core/security/b64.c )
s.files += %w( src/core/security/client_auth_filter.c ) s.files += %w( src/core/security/client_auth_filter.c )
s.files += %w( src/core/security/credentials.c ) s.files += %w( src/core/security/credentials.c )

@ -34,8 +34,8 @@
#ifndef GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H #ifndef GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H
#define GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H #define GRPCXX_GENERIC_ASYNC_GENERIC_SERVICE_H
#include <grpc++/support/byte_buffer.h>
#include <grpc++/support/async_stream.h> #include <grpc++/support/async_stream.h>
#include <grpc++/support/byte_buffer.h>
struct grpc_server; struct grpc_server;

@ -215,7 +215,8 @@ class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface<W> {
CallOpSet<CallOpSendMessage> write_ops_; CallOpSet<CallOpSendMessage> write_ops_;
CallOpSet<CallOpClientSendClose> writes_done_ops_; CallOpSet<CallOpClientSendClose> writes_done_ops_;
CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage, CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage,
CallOpClientRecvStatus> finish_ops_; CallOpClientRecvStatus>
finish_ops_;
}; };
/// Client-side interface for asynchronous bi-directional streaming. /// Client-side interface for asynchronous bi-directional streaming.
@ -350,7 +351,8 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface,
CallOpSet<CallOpSendInitialMetadata> meta_ops_; CallOpSet<CallOpSendInitialMetadata> meta_ops_;
CallOpSet<CallOpRecvMessage<R>> read_ops_; CallOpSet<CallOpRecvMessage<R>> read_ops_;
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpServerSendStatus> finish_ops_; CallOpServerSendStatus>
finish_ops_;
}; };
template <class W> template <class W>

@ -101,10 +101,12 @@ class ClientAsyncResponseReader GRPC_FINAL
class CallOpSetCollection : public CallOpSetCollectionInterface { class CallOpSetCollection : public CallOpSetCollectionInterface {
public: public:
SneakyCallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, SneakyCallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpClientSendClose> init_buf_; CallOpClientSendClose>
init_buf_;
CallOpSet<CallOpRecvInitialMetadata> meta_buf_; CallOpSet<CallOpRecvInitialMetadata> meta_buf_;
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>, CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>,
CallOpClientRecvStatus> finish_buf_; CallOpClientRecvStatus>
finish_buf_;
}; };
std::shared_ptr<CallOpSetCollection> collection_; std::shared_ptr<CallOpSetCollection> collection_;
}; };
@ -159,7 +161,8 @@ class ServerAsyncResponseWriter GRPC_FINAL
ServerContext* ctx_; ServerContext* ctx_;
CallOpSet<CallOpSendInitialMetadata> meta_buf_; CallOpSet<CallOpSendInitialMetadata> meta_buf_;
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpServerSendStatus> finish_buf_; CallOpServerSendStatus>
finish_buf_;
}; };
} // namespace grpc } // namespace grpc

@ -280,7 +280,8 @@ class CallOpRecvMessage {
if (*status) { if (*status) {
got_message = true; got_message = true;
*status = SerializationTraits<R>::Deserialize(recv_buf_, message_, *status = SerializationTraits<R>::Deserialize(recv_buf_, message_,
max_message_size).ok(); max_message_size)
.ok();
} else { } else {
got_message = false; got_message = false;
g_core_codegen_interface->grpc_byte_buffer_destroy(recv_buf_); g_core_codegen_interface->grpc_byte_buffer_destroy(recv_buf_);

@ -56,7 +56,8 @@ Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method,
Call call(channel->CreateCall(method, context, &cq)); Call call(channel->CreateCall(method, context, &cq));
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>, CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>,
CallOpClientSendClose, CallOpClientRecvStatus> ops; CallOpClientSendClose, CallOpClientRecvStatus>
ops;
Status status = ops.SendMessage(request); Status status = ops.SendMessage(request);
if (!status.ok()) { if (!status.ok()) {
return status; return status;

@ -215,7 +215,8 @@ class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface<W> {
CallOpSet<CallOpSendMessage> write_ops_; CallOpSet<CallOpSendMessage> write_ops_;
CallOpSet<CallOpClientSendClose> writes_done_ops_; CallOpSet<CallOpClientSendClose> writes_done_ops_;
CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage, CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage,
CallOpClientRecvStatus> finish_ops_; CallOpClientRecvStatus>
finish_ops_;
}; };
/// Client-side interface for asynchronous bi-directional streaming. /// Client-side interface for asynchronous bi-directional streaming.
@ -350,7 +351,8 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncStreamingInterface,
CallOpSet<CallOpSendInitialMetadata> meta_ops_; CallOpSet<CallOpSendInitialMetadata> meta_ops_;
CallOpSet<CallOpRecvMessage<R>> read_ops_; CallOpSet<CallOpRecvMessage<R>> read_ops_;
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpServerSendStatus> finish_ops_; CallOpServerSendStatus>
finish_ops_;
}; };
template <class W> template <class W>

@ -61,7 +61,8 @@ class RpcMethodHandler : public MethodHandler {
GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_);
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpServerSendStatus> ops; CallOpServerSendStatus>
ops;
ops.SendInitialMetadata(param.server_context->initial_metadata_); ops.SendInitialMetadata(param.server_context->initial_metadata_);
if (status.ok()) { if (status.ok()) {
status = ops.SendMessage(rsp); status = ops.SendMessage(rsp);
@ -74,7 +75,8 @@ class RpcMethodHandler : public MethodHandler {
private: private:
// Application provided rpc handler function. // Application provided rpc handler function.
std::function<Status(ServiceType*, ServerContext*, const RequestType*, std::function<Status(ServiceType*, ServerContext*, const RequestType*,
ResponseType*)> func_; ResponseType*)>
func_;
// The class the above handler function lives in. // The class the above handler function lives in.
ServiceType* service_; ServiceType* service_;
}; };
@ -96,7 +98,8 @@ class ClientStreamingHandler : public MethodHandler {
GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_); GPR_CODEGEN_ASSERT(!param.server_context->sent_initial_metadata_);
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpServerSendStatus> ops; CallOpServerSendStatus>
ops;
ops.SendInitialMetadata(param.server_context->initial_metadata_); ops.SendInitialMetadata(param.server_context->initial_metadata_);
if (status.ok()) { if (status.ok()) {
status = ops.SendMessage(rsp); status = ops.SendMessage(rsp);
@ -108,7 +111,8 @@ class ClientStreamingHandler : public MethodHandler {
private: private:
std::function<Status(ServiceType*, ServerContext*, ServerReader<RequestType>*, std::function<Status(ServiceType*, ServerContext*, ServerReader<RequestType>*,
ResponseType*)> func_; ResponseType*)>
func_;
ServiceType* service_; ServiceType* service_;
}; };
@ -143,7 +147,8 @@ class ServerStreamingHandler : public MethodHandler {
private: private:
std::function<Status(ServiceType*, ServerContext*, const RequestType*, std::function<Status(ServiceType*, ServerContext*, const RequestType*,
ServerWriter<ResponseType>*)> func_; ServerWriter<ResponseType>*)>
func_;
ServiceType* service_; ServiceType* service_;
}; };
@ -174,7 +179,8 @@ class BidiStreamingHandler : public MethodHandler {
private: private:
std::function<Status(ServiceType*, ServerContext*, std::function<Status(ServiceType*, ServerContext*,
ServerReaderWriter<ResponseType, RequestType>*)> func_; ServerReaderWriter<ResponseType, RequestType>*)>
func_;
ServiceType* service_; ServiceType* service_;
}; };

@ -40,10 +40,10 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <grpc/impl/codegen/byte_buffer.h>
#include <grpc++/impl/codegen/config.h> #include <grpc++/impl/codegen/config.h>
#include <grpc++/impl/codegen/rpc_method.h> #include <grpc++/impl/codegen/rpc_method.h>
#include <grpc++/impl/codegen/status.h> #include <grpc++/impl/codegen/status.h>
#include <grpc/impl/codegen/byte_buffer.h>
namespace grpc { namespace grpc {
class ServerContext; class ServerContext;

@ -37,12 +37,12 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/time.h>
#include <grpc++/impl/codegen/security/auth_context.h>
#include <grpc++/impl/codegen/config.h> #include <grpc++/impl/codegen/config.h>
#include <grpc++/impl/codegen/security/auth_context.h>
#include <grpc++/impl/codegen/string_ref.h> #include <grpc++/impl/codegen/string_ref.h>
#include <grpc++/impl/codegen/time.h> #include <grpc++/impl/codegen/time.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/time.h>
struct gpr_timespec; struct gpr_timespec;
struct grpc_metadata; struct grpc_metadata;

@ -192,10 +192,11 @@ class ServerInterface : public CallHook {
bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE { bool FinalizeResult(void** tag, bool* status) GRPC_OVERRIDE {
bool serialization_status = bool serialization_status =
*status && payload_ && *status && payload_ &&
SerializationTraits<Message>::Deserialize( SerializationTraits<Message>::Deserialize(payload_, request_,
payload_, request_, server_->max_message_size()).ok(); server_->max_message_size())
.ok();
bool ret = RegisteredAsyncRequest::FinalizeResult(tag, status); bool ret = RegisteredAsyncRequest::FinalizeResult(tag, status);
*status = serialization_status&&* status; *status = serialization_status && *status;
return ret; return ret;
} }

@ -123,7 +123,8 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface<R> {
ClientContext* context, const W& request) ClientContext* context, const W& request)
: context_(context), call_(channel->CreateCall(method, context, &cq_)) { : context_(context), call_(channel->CreateCall(method, context, &cq_)) {
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpClientSendClose> ops; CallOpClientSendClose>
ops;
ops.SendInitialMetadata(context->send_initial_metadata_); ops.SendInitialMetadata(context->send_initial_metadata_);
// TODO(ctiller): don't assert // TODO(ctiller): don't assert
GPR_CODEGEN_ASSERT(ops.SendMessage(request).ok()); GPR_CODEGEN_ASSERT(ops.SendMessage(request).ok());
@ -235,7 +236,8 @@ class ClientWriter : public ClientWriterInterface<W> {
private: private:
ClientContext* context_; ClientContext* context_;
CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage, CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage,
CallOpClientRecvStatus> finish_ops_; CallOpClientRecvStatus>
finish_ops_;
CompletionQueue cq_; CompletionQueue cq_;
Call call_; Call call_;
}; };

@ -34,13 +34,13 @@
#ifndef GRPCXX_SUPPORT_BYTE_BUFFER_H #ifndef GRPCXX_SUPPORT_BYTE_BUFFER_H
#define GRPCXX_SUPPORT_BYTE_BUFFER_H #define GRPCXX_SUPPORT_BYTE_BUFFER_H
#include <grpc/grpc.h>
#include <grpc/byte_buffer.h>
#include <grpc/support/log.h>
#include <grpc++/impl/serialization_traits.h> #include <grpc++/impl/serialization_traits.h>
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
#include <grpc++/support/slice.h> #include <grpc++/support/slice.h>
#include <grpc++/support/status.h> #include <grpc++/support/status.h>
#include <grpc/byte_buffer.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include <vector> #include <vector>
@ -99,8 +99,8 @@ class SerializationTraits<ByteBuffer, void> {
} }
static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer, static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer,
bool* own_buffer) { bool* own_buffer) {
*buffer = source.buffer(); *buffer = grpc_byte_buffer_copy(source.buffer());
*own_buffer = false; *own_buffer = true;
return Status::OK; return Status::OK;
} }
}; };

@ -34,12 +34,12 @@
#ifndef GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H #ifndef GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H
#define GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H #define GRPCXX_SUPPORT_CHANNEL_ARGUMENTS_H
#include <vector>
#include <list> #include <list>
#include <vector>
#include <grpc++/support/config.h>
#include <grpc/compression.h> #include <grpc/compression.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc++/support/config.h>
namespace grpc { namespace grpc {
namespace testing { namespace testing {

@ -34,8 +34,8 @@
#ifndef GRPCXX_SUPPORT_SLICE_H #ifndef GRPCXX_SUPPORT_SLICE_H
#define GRPCXX_SUPPORT_SLICE_H #define GRPCXX_SUPPORT_SLICE_H
#include <grpc/support/slice.h>
#include <grpc++/support/config.h> #include <grpc++/support/config.h>
#include <grpc/support/slice.h>
namespace grpc { namespace grpc {

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,8 +34,8 @@
#ifndef GRPC_BYTE_BUFFER_READER_H #ifndef GRPC_BYTE_BUFFER_READER_H
#define GRPC_BYTE_BUFFER_READER_H #define GRPC_BYTE_BUFFER_READER_H
#include <grpc/grpc.h>
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
#include <grpc/grpc.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

@ -36,8 +36,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <grpc/impl/codegen/port_platform.h>
#include <grpc/impl/codegen/compression_types.h> #include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/port_platform.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -59,9 +59,8 @@ GRPCAPI int grpc_compression_algorithm_name(
* compression algorithms encoded in the \a accepted_encodings bitset. * compression algorithms encoded in the \a accepted_encodings bitset.
* *
* It abort()s for unknown levels . */ * It abort()s for unknown levels . */
GRPCAPI grpc_compression_algorithm GRPCAPI grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_algorithm_for_level(grpc_compression_level level, grpc_compression_level level, uint32_t accepted_encodings);
uint32_t accepted_encodings);
GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts); GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts);

@ -36,13 +36,13 @@
#include <grpc/status.h> #include <grpc/status.h>
#include <stddef.h>
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
#include <grpc/support/slice.h>
#include <grpc/support/time.h>
#include <grpc/impl/codegen/connectivity_state.h> #include <grpc/impl/codegen/connectivity_state.h>
#include <grpc/impl/codegen/propagation_bits.h>
#include <grpc/impl/codegen/grpc_types.h> #include <grpc/impl/codegen/grpc_types.h>
#include <grpc/impl/codegen/propagation_bits.h>
#include <grpc/support/slice.h>
#include <grpc/support/time.h>
#include <stddef.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -154,9 +154,8 @@ GRPCAPI void grpc_alarm_cancel(grpc_alarm *alarm);
GRPCAPI void grpc_alarm_destroy(grpc_alarm *alarm); GRPCAPI void grpc_alarm_destroy(grpc_alarm *alarm);
/** Check the connectivity state of a channel. */ /** Check the connectivity state of a channel. */
GRPCAPI grpc_connectivity_state GRPCAPI grpc_connectivity_state grpc_channel_check_connectivity_state(
grpc_channel_check_connectivity_state(grpc_channel *channel, grpc_channel *channel, int try_to_connect);
int try_to_connect);
/** Watch for a change in connectivity state. /** Watch for a change in connectivity state.
Once the channel connectivity state is different from last_observed_state, Once the channel connectivity state is different from last_observed_state,
@ -267,9 +266,10 @@ GRPCAPI grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved);
and description passed in. and description passed in.
Importantly, this function does not send status nor description to the Importantly, this function does not send status nor description to the
remote endpoint. */ remote endpoint. */
GRPCAPI grpc_call_error GRPCAPI grpc_call_error grpc_call_cancel_with_status(grpc_call *call,
grpc_call_cancel_with_status(grpc_call *call, grpc_status_code status, grpc_status_code status,
const char *description, void *reserved); const char *description,
void *reserved);
/** Destroy a call. /** Destroy a call.
THREAD SAFETY: grpc_call_destroy is thread-compatible */ THREAD SAFETY: grpc_call_destroy is thread-compatible */
@ -283,13 +283,11 @@ GRPCAPI void grpc_call_destroy(grpc_call *call);
to \a cq_bound_to_call. to \a cq_bound_to_call.
Note that \a cq_for_notification must have been registered to the server via Note that \a cq_for_notification must have been registered to the server via
\a grpc_server_register_completion_queue. */ \a grpc_server_register_completion_queue. */
GRPCAPI grpc_call_error GRPCAPI grpc_call_error grpc_server_request_call(
grpc_server_request_call(grpc_server *server, grpc_call **call, grpc_server *server, grpc_call **call, grpc_call_details *details,
grpc_call_details *details, grpc_metadata_array *request_metadata,
grpc_metadata_array *request_metadata, grpc_completion_queue *cq_bound_to_call,
grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new);
grpc_completion_queue *cq_for_notification,
void *tag_new);
/** Registers a method in the server. /** Registers a method in the server.
Methods to this (host, method) pair will not be reported by Methods to this (host, method) pair will not be reported by

@ -80,9 +80,8 @@ grpc_auth_context_peer_identity(const grpc_auth_context *ctx);
/* Finds a property in the context. May return an empty iterator (first _next /* Finds a property in the context. May return an empty iterator (first _next
will return NULL) if no property with this name was found in the context. */ will return NULL) if no property with this name was found in the context. */
GRPCAPI grpc_auth_property_iterator GRPCAPI grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(
grpc_auth_context_find_properties_by_name(const grpc_auth_context *ctx, const grpc_auth_context *ctx, const char *name);
const char *name);
/* Gets the name of the property that indicates the peer identity. Will return /* Gets the name of the property that indicates the peer identity. Will return
NULL if the peer is not authenticated. */ NULL if the peer is not authenticated. */
@ -363,8 +362,8 @@ GRPCAPI int grpc_server_add_secure_http2_port(grpc_server *server,
/* Sets a credentials to a call. Can only be called on the client side before /* Sets a credentials to a call. Can only be called on the client side before
grpc_call_start_batch. */ grpc_call_start_batch. */
GRPCAPI grpc_call_error GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call *call,
grpc_call_set_credentials(grpc_call *call, grpc_call_credentials *creds); grpc_call_credentials *creds);
/* --- Auth Metadata Processing --- */ /* --- Auth Metadata Processing --- */

@ -34,8 +34,8 @@
#ifndef GRPC_IMPL_CODEGEN_LOG_H #ifndef GRPC_IMPL_CODEGEN_LOG_H
#define GRPC_IMPL_CODEGEN_LOG_H #define GRPC_IMPL_CODEGEN_LOG_H
#include <stdlib.h> /* for abort() */
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> /* for abort() */
#include <grpc/impl/codegen/port_platform.h> #include <grpc/impl/codegen/port_platform.h>

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

@ -122,8 +122,8 @@ GPRAPI gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *));
/* Equivalent to gpr_slice_new, but with a two argument destroy function that /* Equivalent to gpr_slice_new, but with a two argument destroy function that
also takes the slice length. */ also takes the slice length. */
GPRAPI gpr_slice GPRAPI gpr_slice gpr_slice_new_with_len(void *p, size_t len,
gpr_slice_new_with_len(void *p, size_t len, void (*destroy)(void *, size_t)); void (*destroy)(void *, size_t));
/* Equivalent to gpr_slice_new(malloc(len), len, free), but saves one malloc() /* Equivalent to gpr_slice_new(malloc(len), len, free), but saves one malloc()
call. call.

@ -73,8 +73,8 @@ GPRAPI void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice slice);
slice at the returned index in sb->slices) slice at the returned index in sb->slices)
The implementation MAY decide to concatenate data at the end of a small The implementation MAY decide to concatenate data at the end of a small
slice added in this fashion. */ slice added in this fashion. */
GPRAPI size_t GPRAPI size_t gpr_slice_buffer_add_indexed(gpr_slice_buffer *sb,
gpr_slice_buffer_add_indexed(gpr_slice_buffer *sb, gpr_slice slice); gpr_slice slice);
GPRAPI void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_slice *slices, GPRAPI void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_slice *slices,
size_t n); size_t n);
/* add a very small (less than 8 bytes) amount of data to the end of a slice /* add a very small (less than 8 bytes) amount of data to the end of a slice

@ -88,8 +88,8 @@ GPRAPI void gpr_time_init(void);
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock); GPRAPI gpr_timespec gpr_now(gpr_clock_type clock);
/* Convert a timespec from one clock to another */ /* Convert a timespec from one clock to another */
GPRAPI gpr_timespec GPRAPI gpr_timespec gpr_convert_clock_type(gpr_timespec t,
gpr_convert_clock_type(gpr_timespec t, gpr_clock_type target_clock); gpr_clock_type target_clock);
/* Return -ve, 0, or +ve according to whether a < b, a == b, or a > b /* Return -ve, 0, or +ve according to whether a < b, a == b, or a > b
respectively. */ respectively. */

@ -132,9 +132,9 @@
"src/core/compression/algorithm_metadata.h", "src/core/compression/algorithm_metadata.h",
"src/core/compression/message_compress.h", "src/core/compression/message_compress.h",
"src/core/debug/trace.h", "src/core/debug/trace.h",
"src/core/httpcli/format_request.h", "src/core/http/format_request.h",
"src/core/httpcli/httpcli.h", "src/core/http/httpcli.h",
"src/core/httpcli/parser.h", "src/core/http/parser.h",
"src/core/iomgr/closure.h", "src/core/iomgr/closure.h",
"src/core/iomgr/endpoint.h", "src/core/iomgr/endpoint.h",
"src/core/iomgr/endpoint_pair.h", "src/core/iomgr/endpoint_pair.h",
@ -166,6 +166,7 @@
"src/core/iomgr/timer.h", "src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h", "src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h", "src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h", "src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h", "src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h", "src/core/iomgr/workqueue.h",
@ -273,9 +274,9 @@
"src/core/compression/compression_algorithm.c", "src/core/compression/compression_algorithm.c",
"src/core/compression/message_compress.c", "src/core/compression/message_compress.c",
"src/core/debug/trace.c", "src/core/debug/trace.c",
"src/core/httpcli/format_request.c", "src/core/http/format_request.c",
"src/core/httpcli/httpcli.c", "src/core/http/httpcli.c",
"src/core/httpcli/parser.c", "src/core/http/parser.c",
"src/core/iomgr/closure.c", "src/core/iomgr/closure.c",
"src/core/iomgr/endpoint.c", "src/core/iomgr/endpoint.c",
"src/core/iomgr/endpoint_pair_posix.c", "src/core/iomgr/endpoint_pair_posix.c",
@ -310,6 +311,8 @@
"src/core/iomgr/timer.c", "src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c", "src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c", "src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c", "src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c", "src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c", "src/core/iomgr/wakeup_fd_pipe.c",
@ -371,7 +374,7 @@
"src/core/transport/static_metadata.c", "src/core/transport/static_metadata.c",
"src/core/transport/transport.c", "src/core/transport/transport.c",
"src/core/transport/transport_op_string.c", "src/core/transport/transport_op_string.c",
"src/core/httpcli/httpcli_security_connector.c", "src/core/http/httpcli_security_connector.c",
"src/core/security/b64.c", "src/core/security/b64.c",
"src/core/security/client_auth_filter.c", "src/core/security/client_auth_filter.c",
"src/core/security/credentials.c", "src/core/security/credentials.c",

@ -194,9 +194,9 @@
<file baseinstalldir="/" name="src/core/compression/algorithm_metadata.h" role="src" /> <file baseinstalldir="/" name="src/core/compression/algorithm_metadata.h" role="src" />
<file baseinstalldir="/" name="src/core/compression/message_compress.h" role="src" /> <file baseinstalldir="/" name="src/core/compression/message_compress.h" role="src" />
<file baseinstalldir="/" name="src/core/debug/trace.h" role="src" /> <file baseinstalldir="/" name="src/core/debug/trace.h" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/format_request.h" role="src" /> <file baseinstalldir="/" name="src/core/http/format_request.h" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/httpcli.h" role="src" /> <file baseinstalldir="/" name="src/core/http/httpcli.h" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/parser.h" role="src" /> <file baseinstalldir="/" name="src/core/http/parser.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/closure.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/closure.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/endpoint.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/endpoint.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/endpoint_pair.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/endpoint_pair.h" role="src" />
@ -228,6 +228,7 @@
<file baseinstalldir="/" name="src/core/iomgr/timer.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/timer.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/timer_heap.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/timer_heap.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/udp_server.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/udp_server.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_pipe.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_pipe.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_posix.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/workqueue.h" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/workqueue.h" role="src" />
@ -335,9 +336,9 @@
<file baseinstalldir="/" name="src/core/compression/compression_algorithm.c" role="src" /> <file baseinstalldir="/" name="src/core/compression/compression_algorithm.c" role="src" />
<file baseinstalldir="/" name="src/core/compression/message_compress.c" role="src" /> <file baseinstalldir="/" name="src/core/compression/message_compress.c" role="src" />
<file baseinstalldir="/" name="src/core/debug/trace.c" role="src" /> <file baseinstalldir="/" name="src/core/debug/trace.c" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/format_request.c" role="src" /> <file baseinstalldir="/" name="src/core/http/format_request.c" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/httpcli.c" role="src" /> <file baseinstalldir="/" name="src/core/http/httpcli.c" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/parser.c" role="src" /> <file baseinstalldir="/" name="src/core/http/parser.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/closure.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/closure.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/endpoint.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/endpoint.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/endpoint_pair_posix.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/endpoint_pair_posix.c" role="src" />
@ -372,6 +373,8 @@
<file baseinstalldir="/" name="src/core/iomgr/timer.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/timer.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/timer_heap.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/timer_heap.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/udp_server.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/udp_server.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix_noop.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_eventfd.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_eventfd.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_nospecial.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_nospecial.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_pipe.c" role="src" /> <file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_pipe.c" role="src" />
@ -433,7 +436,7 @@
<file baseinstalldir="/" name="src/core/transport/static_metadata.c" role="src" /> <file baseinstalldir="/" name="src/core/transport/static_metadata.c" role="src" />
<file baseinstalldir="/" name="src/core/transport/transport.c" role="src" /> <file baseinstalldir="/" name="src/core/transport/transport.c" role="src" />
<file baseinstalldir="/" name="src/core/transport/transport_op_string.c" role="src" /> <file baseinstalldir="/" name="src/core/transport/transport_op_string.c" role="src" />
<file baseinstalldir="/" name="src/core/httpcli/httpcli_security_connector.c" role="src" /> <file baseinstalldir="/" name="src/core/http/httpcli_security_connector.c" role="src" />
<file baseinstalldir="/" name="src/core/security/b64.c" role="src" /> <file baseinstalldir="/" name="src/core/security/b64.c" role="src" />
<file baseinstalldir="/" name="src/core/security/client_auth_filter.c" role="src" /> <file baseinstalldir="/" name="src/core/security/client_auth_filter.c" role="src" />
<file baseinstalldir="/" name="src/core/security/credentials.c" role="src" /> <file baseinstalldir="/" name="src/core/security/credentials.c" role="src" />

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

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

@ -172,13 +172,27 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
} }
const grpc_channel_filter grpc_client_census_filter = { const grpc_channel_filter grpc_client_census_filter = {
client_start_transport_op, grpc_channel_next_op, sizeof(call_data), client_start_transport_op,
client_init_call_elem, grpc_call_stack_ignore_set_pollset, grpc_channel_next_op,
client_destroy_call_elem, sizeof(channel_data), init_channel_elem, sizeof(call_data),
destroy_channel_elem, grpc_call_next_get_peer, "census-client"}; client_init_call_elem,
grpc_call_stack_ignore_set_pollset,
client_destroy_call_elem,
sizeof(channel_data),
init_channel_elem,
destroy_channel_elem,
grpc_call_next_get_peer,
"census-client"};
const grpc_channel_filter grpc_server_census_filter = { const grpc_channel_filter grpc_server_census_filter = {
server_start_transport_op, grpc_channel_next_op, sizeof(call_data), server_start_transport_op,
server_init_call_elem, grpc_call_stack_ignore_set_pollset, grpc_channel_next_op,
server_destroy_call_elem, sizeof(channel_data), init_channel_elem, sizeof(call_data),
destroy_channel_elem, grpc_call_next_get_peer, "census-server"}; server_init_call_elem,
grpc_call_stack_ignore_set_pollset,
server_destroy_call_elem,
sizeof(channel_data),
init_channel_elem,
destroy_channel_elem,
grpc_call_next_get_peer,
"census-server"};

@ -38,8 +38,8 @@
#include <grpc/census.h> #include <grpc/census.h>
#include "src/core/census/grpc_filter.h" #include "src/core/census/grpc_filter.h"
#include "src/core/surface/channel_init.h"
#include "src/core/channel/channel_stack_builder.h" #include "src/core/channel/channel_stack_builder.h"
#include "src/core/surface/channel_init.h"
static bool maybe_add_census_filter(grpc_channel_stack_builder *builder, static bool maybe_add_census_filter(grpc_channel_stack_builder *builder,
void *arg_must_be_null) { void *arg_must_be_null) {

@ -31,8 +31,8 @@
* *
*/ */
#include <grpc/grpc.h>
#include "src/core/channel/channel_args.h" #include "src/core/channel/channel_args.h"
#include <grpc/grpc.h>
#include "src/core/support/string.h" #include "src/core/support/string.h"
#include <grpc/census.h> #include <grpc/census.h>

@ -431,9 +431,17 @@ static void cc_set_pollset(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
} }
const grpc_channel_filter grpc_client_channel_filter = { const grpc_channel_filter grpc_client_channel_filter = {
cc_start_transport_stream_op, cc_start_transport_op, sizeof(call_data), cc_start_transport_stream_op,
init_call_elem, cc_set_pollset, destroy_call_elem, sizeof(channel_data), cc_start_transport_op,
init_channel_elem, destroy_channel_elem, cc_get_peer, "client-channel", sizeof(call_data),
init_call_elem,
cc_set_pollset,
destroy_call_elem,
sizeof(channel_data),
init_channel_elem,
destroy_channel_elem,
cc_get_peer,
"client-channel",
}; };
void grpc_client_channel_set_resolver(grpc_exec_ctx *exec_ctx, void grpc_client_channel_set_resolver(grpc_exec_ctx *exec_ctx,

@ -291,7 +291,14 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {} grpc_channel_element *elem) {}
const grpc_channel_filter grpc_compress_filter = { const grpc_channel_filter grpc_compress_filter = {
compress_start_transport_stream_op, grpc_channel_next_op, sizeof(call_data), compress_start_transport_stream_op,
init_call_elem, grpc_call_stack_ignore_set_pollset, destroy_call_elem, grpc_channel_next_op,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(call_data),
grpc_call_next_get_peer, "compress"}; init_call_elem,
grpc_call_stack_ignore_set_pollset,
destroy_call_elem,
sizeof(channel_data),
init_channel_elem,
destroy_channel_elem,
grpc_call_next_get_peer,
"compress"};

@ -37,13 +37,13 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "src/core/support/string.h"
#include "src/core/transport/transport.h"
#include "src/core/profiling/timers.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h> #include <grpc/support/slice_buffer.h>
#include "src/core/profiling/timers.h"
#include "src/core/support/string.h"
#include "src/core/transport/transport.h"
#define MAX_BUFFER_LENGTH 8192 #define MAX_BUFFER_LENGTH 8192
@ -132,9 +132,17 @@ static char *con_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
} }
static const grpc_channel_filter connected_channel_filter = { static const grpc_channel_filter connected_channel_filter = {
con_start_transport_stream_op, con_start_transport_op, sizeof(call_data), con_start_transport_stream_op,
init_call_elem, set_pollset, destroy_call_elem, sizeof(channel_data), con_start_transport_op,
init_channel_elem, destroy_channel_elem, con_get_peer, "connected", sizeof(call_data),
init_call_elem,
set_pollset,
destroy_call_elem,
sizeof(channel_data),
init_channel_elem,
destroy_channel_elem,
con_get_peer,
"connected",
}; };
static void bind_transport(grpc_channel_stack *channel_stack, static void bind_transport(grpc_channel_stack *channel_stack,

@ -242,7 +242,14 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
} }
const grpc_channel_filter grpc_http_client_filter = { const grpc_channel_filter grpc_http_client_filter = {
hc_start_transport_op, grpc_channel_next_op, sizeof(call_data), hc_start_transport_op,
init_call_elem, grpc_call_stack_ignore_set_pollset, destroy_call_elem, grpc_channel_next_op,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(call_data),
grpc_call_next_get_peer, "http-client"}; init_call_elem,
grpc_call_stack_ignore_set_pollset,
destroy_call_elem,
sizeof(channel_data),
init_channel_elem,
destroy_channel_elem,
grpc_call_next_get_peer,
"http-client"};

@ -227,7 +227,14 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {} grpc_channel_element *elem) {}
const grpc_channel_filter grpc_http_server_filter = { const grpc_channel_filter grpc_http_server_filter = {
hs_start_transport_op, grpc_channel_next_op, sizeof(call_data), hs_start_transport_op,
init_call_elem, grpc_call_stack_ignore_set_pollset, destroy_call_elem, grpc_channel_next_op,
sizeof(channel_data), init_channel_elem, destroy_channel_elem, sizeof(call_data),
grpc_call_next_get_peer, "http-server"}; init_call_elem,
grpc_call_stack_ignore_set_pollset,
destroy_call_elem,
sizeof(channel_data),
init_channel_elem,
destroy_channel_elem,
grpc_call_next_get_peer,
"http-server"};

@ -378,8 +378,14 @@ void pf_ping_one(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
} }
static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = { static const grpc_lb_policy_vtable pick_first_lb_policy_vtable = {
pf_destroy, pf_shutdown, pf_pick, pf_cancel_pick, pf_ping_one, pf_exit_idle, pf_destroy,
pf_check_connectivity, pf_notify_on_state_change}; pf_shutdown,
pf_pick,
pf_cancel_pick,
pf_ping_one,
pf_exit_idle,
pf_check_connectivity,
pf_notify_on_state_change};
static void pick_first_factory_ref(grpc_lb_policy_factory *factory) {} static void pick_first_factory_ref(grpc_lb_policy_factory *factory) {}

@ -483,8 +483,14 @@ static void rr_ping_one(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
} }
static const grpc_lb_policy_vtable round_robin_lb_policy_vtable = { static const grpc_lb_policy_vtable round_robin_lb_policy_vtable = {
rr_destroy, rr_shutdown, rr_pick, rr_cancel_pick, rr_ping_one, rr_exit_idle, rr_destroy,
rr_check_connectivity, rr_notify_on_state_change}; rr_shutdown,
rr_pick,
rr_cancel_pick,
rr_ping_one,
rr_exit_idle,
rr_check_connectivity,
rr_notify_on_state_change};
static void round_robin_factory_ref(grpc_lb_policy_factory *factory) {} static void round_robin_factory_ref(grpc_lb_policy_factory *factory) {}

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

@ -44,9 +44,9 @@
#include "src/core/client_config/lb_policy_registry.h" #include "src/core/client_config/lb_policy_registry.h"
#include "src/core/client_config/resolver_registry.h" #include "src/core/client_config/resolver_registry.h"
#include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/resolve_address.h"
#include "src/core/json/json.h"
#include "src/core/support/string.h" #include "src/core/support/string.h"
#include "src/core/surface/api_trace.h" #include "src/core/surface/api_trace.h"
#include "src/core/json/json.h"
/** Zookeeper session expiration time in milliseconds */ /** Zookeeper session expiration time in milliseconds */
#define GRPC_ZOOKEEPER_SESSION_TIMEOUT 15000 #define GRPC_ZOOKEEPER_SESSION_TIMEOUT 15000

@ -185,8 +185,8 @@ static void connection_destroy(grpc_exec_ctx *exec_ctx, void *arg,
gpr_free(c); gpr_free(c);
} }
void grpc_connected_subchannel_ref(grpc_connected_subchannel *c void grpc_connected_subchannel_ref(
GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { grpc_connected_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CONNECTION(c), REF_REASON); GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CONNECTION(c), REF_REASON);
} }
@ -227,8 +227,8 @@ static gpr_atm ref_mutate(grpc_subchannel *c, gpr_atm delta,
return old_val; return old_val;
} }
grpc_subchannel *grpc_subchannel_ref(grpc_subchannel *c grpc_subchannel *grpc_subchannel_ref(
GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
gpr_atm old_refs; gpr_atm old_refs;
old_refs = ref_mutate(c, (1 << INTERNAL_REF_BITS), old_refs = ref_mutate(c, (1 << INTERNAL_REF_BITS),
0 REF_MUTATE_PURPOSE("STRONG_REF")); 0 REF_MUTATE_PURPOSE("STRONG_REF"));
@ -236,8 +236,8 @@ grpc_subchannel *grpc_subchannel_ref(grpc_subchannel *c
return c; return c;
} }
grpc_subchannel *grpc_subchannel_weak_ref(grpc_subchannel *c grpc_subchannel *grpc_subchannel_weak_ref(
GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { grpc_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
gpr_atm old_refs; gpr_atm old_refs;
old_refs = ref_mutate(c, 1, 0 REF_MUTATE_PURPOSE("WEAK_REF")); old_refs = ref_mutate(c, 1, 0 REF_MUTATE_PURPOSE("WEAK_REF"));
GPR_ASSERT(old_refs != 0); GPR_ASSERT(old_refs != 0);
@ -626,8 +626,8 @@ static void subchannel_call_destroy(grpc_exec_ctx *exec_ctx, void *call,
GPR_TIMER_END("grpc_subchannel_call_unref.destroy", 0); GPR_TIMER_END("grpc_subchannel_call_unref.destroy", 0);
} }
void grpc_subchannel_call_ref(grpc_subchannel_call *c void grpc_subchannel_call_ref(
GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { grpc_subchannel_call *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
GRPC_CALL_STACK_REF(SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON); GRPC_CALL_STACK_REF(SUBCHANNEL_CALL_TO_CALL_STACK(c), REF_REASON);
} }

@ -83,25 +83,25 @@ typedef struct grpc_subchannel_args grpc_subchannel_args;
#define GRPC_SUBCHANNEL_REF_EXTRA_ARGS #define GRPC_SUBCHANNEL_REF_EXTRA_ARGS
#endif #endif
grpc_subchannel *grpc_subchannel_ref(grpc_subchannel *channel grpc_subchannel *grpc_subchannel_ref(
GRPC_SUBCHANNEL_REF_EXTRA_ARGS); grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
grpc_subchannel *grpc_subchannel_ref_from_weak_ref( grpc_subchannel *grpc_subchannel_ref_from_weak_ref(
grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_unref(grpc_exec_ctx *exec_ctx, void grpc_subchannel_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel *channel grpc_subchannel *channel
GRPC_SUBCHANNEL_REF_EXTRA_ARGS); GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
grpc_subchannel *grpc_subchannel_weak_ref(grpc_subchannel *channel grpc_subchannel *grpc_subchannel_weak_ref(
GRPC_SUBCHANNEL_REF_EXTRA_ARGS); grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_weak_unref(grpc_exec_ctx *exec_ctx, void grpc_subchannel_weak_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel *channel grpc_subchannel *channel
GRPC_SUBCHANNEL_REF_EXTRA_ARGS); GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_connected_subchannel_ref(grpc_connected_subchannel *channel void grpc_connected_subchannel_ref(
GRPC_SUBCHANNEL_REF_EXTRA_ARGS); grpc_connected_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_connected_subchannel_unref(grpc_exec_ctx *exec_ctx, void grpc_connected_subchannel_unref(grpc_exec_ctx *exec_ctx,
grpc_connected_subchannel *channel grpc_connected_subchannel *channel
GRPC_SUBCHANNEL_REF_EXTRA_ARGS); GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_call_ref(grpc_subchannel_call *call void grpc_subchannel_call_ref(
GRPC_SUBCHANNEL_REF_EXTRA_ARGS); grpc_subchannel_call *call GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
void grpc_subchannel_call_unref(grpc_exec_ctx *exec_ctx, void grpc_subchannel_call_unref(grpc_exec_ctx *exec_ctx,
grpc_subchannel_call *call grpc_subchannel_call *call
GRPC_SUBCHANNEL_REF_EXTRA_ARGS); GRPC_SUBCHANNEL_REF_EXTRA_ARGS);

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -31,22 +31,22 @@
* *
*/ */
#include "src/core/httpcli/format_request.h" #include "src/core/http/format_request.h"
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "src/core/support/string.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/slice.h> #include <grpc/support/slice.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
#include "src/core/support/string.h"
static void fill_common_header(const grpc_httpcli_request *request, static void fill_common_header(const grpc_httpcli_request *request,
gpr_strvec *buf) { gpr_strvec *buf) {
size_t i; size_t i;
gpr_strvec_add(buf, gpr_strdup(request->path)); gpr_strvec_add(buf, gpr_strdup(request->http.path));
gpr_strvec_add(buf, gpr_strdup(" HTTP/1.0\r\n")); gpr_strvec_add(buf, gpr_strdup(" HTTP/1.0\r\n"));
/* just in case some crazy server really expects HTTP/1.1 */ /* just in case some crazy server really expects HTTP/1.1 */
gpr_strvec_add(buf, gpr_strdup("Host: ")); gpr_strvec_add(buf, gpr_strdup("Host: "));
@ -56,10 +56,10 @@ static void fill_common_header(const grpc_httpcli_request *request,
gpr_strvec_add(buf, gpr_strvec_add(buf,
gpr_strdup("User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n")); gpr_strdup("User-Agent: " GRPC_HTTPCLI_USER_AGENT "\r\n"));
/* user supplied headers */ /* user supplied headers */
for (i = 0; i < request->hdr_count; i++) { for (i = 0; i < request->http.hdr_count; i++) {
gpr_strvec_add(buf, gpr_strdup(request->hdrs[i].key)); gpr_strvec_add(buf, gpr_strdup(request->http.hdrs[i].key));
gpr_strvec_add(buf, gpr_strdup(": ")); gpr_strvec_add(buf, gpr_strdup(": "));
gpr_strvec_add(buf, gpr_strdup(request->hdrs[i].value)); gpr_strvec_add(buf, gpr_strdup(request->http.hdrs[i].value));
gpr_strvec_add(buf, gpr_strdup("\r\n")); gpr_strvec_add(buf, gpr_strdup("\r\n"));
} }
} }
@ -94,8 +94,8 @@ gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
fill_common_header(request, &out); fill_common_header(request, &out);
if (body_bytes) { if (body_bytes) {
uint8_t has_content_type = 0; uint8_t has_content_type = 0;
for (i = 0; i < request->hdr_count; i++) { for (i = 0; i < request->http.hdr_count; i++) {
if (strcmp(request->hdrs[i].key, "Content-Type") == 0) { if (strcmp(request->http.hdrs[i].key, "Content-Type") == 0) {
has_content_type = 1; has_content_type = 1;
break; break;
} }

@ -31,15 +31,15 @@
* *
*/ */
#ifndef GRPC_CORE_HTTPCLI_FORMAT_REQUEST_H #ifndef GRPC_CORE_HTTP_FORMAT_REQUEST_H
#define GRPC_CORE_HTTPCLI_FORMAT_REQUEST_H #define GRPC_CORE_HTTP_FORMAT_REQUEST_H
#include "src/core/httpcli/httpcli.h"
#include <grpc/support/slice.h> #include <grpc/support/slice.h>
#include "src/core/http/httpcli.h"
gpr_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request); gpr_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request);
gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
const char *body_bytes, const char *body_bytes,
size_t body_size); size_t body_size);
#endif /* GRPC_CORE_HTTPCLI_FORMAT_REQUEST_H */ #endif /* GRPC_CORE_HTTP_FORMAT_REQUEST_H */

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

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

@ -31,15 +31,15 @@
* *
*/ */
#include "src/core/httpcli/httpcli.h" #include "src/core/http/httpcli.h"
#include <string.h> #include <string.h>
#include "src/core/security/handshake.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>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include "src/core/security/handshake.h"
#include "src/core/support/string.h"
#include "src/core/tsi/ssl_transport_security.h" #include "src/core/tsi/ssl_transport_security.h"
typedef struct { typedef struct {

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

@ -0,0 +1,116 @@
/*
*
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_HTTP_PARSER_H
#define GRPC_CORE_HTTP_PARSER_H
#include <grpc/support/port_platform.h>
#include <grpc/support/slice.h>
/* Maximum length of a header string of the form 'Key: Value\r\n' */
#define GRPC_HTTP_PARSER_MAX_HEADER_LENGTH 4096
/* A single header to be passed in a request */
typedef struct grpc_http_header {
char *key;
char *value;
} grpc_http_header;
typedef enum {
GRPC_HTTP_FIRST_LINE,
GRPC_HTTP_HEADERS,
GRPC_HTTP_BODY
} grpc_http_parser_state;
typedef enum {
GRPC_HTTP_HTTP10,
GRPC_HTTP_HTTP11,
GRPC_HTTP_HTTP20,
} grpc_http_version;
typedef enum {
GRPC_HTTP_RESPONSE,
GRPC_HTTP_REQUEST,
GRPC_HTTP_UNKNOWN
} grpc_http_type;
/* A request */
typedef struct grpc_http_request {
/* Method of the request (e.g. GET, POST) */
char *method;
/* The path of the resource to fetch */
char *path;
/* HTTP version to use */
grpc_http_version version;
/* Headers attached to the request */
size_t hdr_count;
grpc_http_header *hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
char *body;
} grpc_http_request;
/* A response */
typedef struct grpc_http_response {
/* HTTP status code */
int status;
/* Headers: count and key/values */
size_t hdr_count;
grpc_http_header *hdrs;
/* Body: length and contents; contents are NOT null-terminated */
size_t body_length;
char *body;
} grpc_http_response;
typedef struct {
grpc_http_parser_state state;
grpc_http_type type;
union {
grpc_http_response response;
grpc_http_request request;
} http;
size_t body_capacity;
size_t hdr_capacity;
uint8_t cur_line[GRPC_HTTP_PARSER_MAX_HEADER_LENGTH];
size_t cur_line_length;
} grpc_http_parser;
void grpc_http_parser_init(grpc_http_parser *parser);
void grpc_http_parser_destroy(grpc_http_parser *parser);
int grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice);
int grpc_http_parser_eof(grpc_http_parser *parser);
#endif /* GRPC_CORE_HTTP_PARSER_H */

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

@ -34,11 +34,11 @@
#ifndef GRPC_CORE_IOMGR_ENDPOINT_H #ifndef GRPC_CORE_IOMGR_ENDPOINT_H
#define GRPC_CORE_IOMGR_ENDPOINT_H #define GRPC_CORE_IOMGR_ENDPOINT_H
#include "src/core/iomgr/pollset.h"
#include "src/core/iomgr/pollset_set.h"
#include <grpc/support/slice.h> #include <grpc/support/slice.h>
#include <grpc/support/slice_buffer.h> #include <grpc/support/slice_buffer.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/iomgr/pollset.h"
#include "src/core/iomgr/pollset_set.h"
/* An endpoint caps a streaming channel between two communicating processes. /* An endpoint caps a streaming channel between two communicating processes.
Examples may be: a tcp socket, <stdin+stdout>, or some shared memory. */ Examples may be: a tcp socket, <stdin+stdout>, or some shared memory. */

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

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,16 +34,16 @@
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifdef GPR_WINSOCK_SOCKET #ifdef GPR_WINSOCK_SOCKET
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/endpoint_pair.h" #include "src/core/iomgr/endpoint_pair.h"
#include "src/core/iomgr/sockaddr_utils.h"
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include "src/core/iomgr/tcp_windows.h"
#include "src/core/iomgr/socket_windows.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/iomgr/socket_windows.h"
#include "src/core/iomgr/tcp_windows.h"
static void create_sockets(SOCKET sv[2]) { static void create_sockets(SOCKET sv[2]) {
SOCKET svr_sock = INVALID_SOCKET; SOCKET svr_sock = INVALID_SOCKET;

@ -34,11 +34,11 @@
#ifndef GRPC_CORE_IOMGR_FD_POSIX_H #ifndef GRPC_CORE_IOMGR_FD_POSIX_H
#define GRPC_CORE_IOMGR_FD_POSIX_H #define GRPC_CORE_IOMGR_FD_POSIX_H
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/pollset.h"
#include <grpc/support/atm.h> #include <grpc/support/atm.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/pollset.h"
typedef struct grpc_fd grpc_fd; typedef struct grpc_fd grpc_fd;

@ -37,15 +37,15 @@
#include <winsock2.h> #include <winsock2.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/log_win32.h> #include <grpc/support/log_win32.h>
#include <grpc/support/alloc.h>
#include <grpc/support/thd.h> #include <grpc/support/thd.h>
#include "src/core/iomgr/timer.h"
#include "src/core/iomgr/iocp_windows.h" #include "src/core/iomgr/iocp_windows.h"
#include "src/core/iomgr/iomgr_internal.h" #include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/socket_windows.h" #include "src/core/iomgr/socket_windows.h"
#include "src/core/iomgr/timer.h"
static ULONG g_iocp_kick_token; static ULONG g_iocp_kick_token;
static OVERLAPPED g_iocp_custom_overlap; static OVERLAPPED g_iocp_custom_overlap;

@ -36,8 +36,8 @@
#include <stdbool.h> #include <stdbool.h>
#include "src/core/iomgr/iomgr.h"
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include "src/core/iomgr/iomgr.h"
typedef struct grpc_iomgr_object { typedef struct grpc_iomgr_object {
char *name; char *name;

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,9 +35,9 @@
#ifdef GPR_POSIX_SOCKET #ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/iomgr_posix.h"
#include "src/core/debug/trace.h" #include "src/core/debug/trace.h"
#include "src/core/iomgr/fd_posix.h" #include "src/core/iomgr/fd_posix.h"
#include "src/core/iomgr/iomgr_posix.h"
#include "src/core/iomgr/tcp_posix.h" #include "src/core/iomgr/tcp_posix.h"
void grpc_iomgr_platform_init(void) { void grpc_iomgr_platform_init(void) {

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -39,9 +39,9 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/iomgr/socket_windows.h"
#include "src/core/iomgr/iocp_windows.h" #include "src/core/iomgr/iocp_windows.h"
#include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/iomgr.h"
#include "src/core/iomgr/socket_windows.h"
/* Windows' io manager is going to be fully designed using IO completion /* Windows' io manager is going to be fully designed using IO completion
ports. All of what we're doing here is basically make sure that ports. All of what we're doing here is basically make sure that

@ -38,8 +38,8 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/thd.h> #include <grpc/support/thd.h>
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/iocp_windows.h" #include "src/core/iomgr/iocp_windows.h"
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/pollset.h" #include "src/core/iomgr/pollset.h"
#include "src/core/iomgr/pollset_windows.h" #include "src/core/iomgr/pollset_windows.h"

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

@ -35,10 +35,10 @@
#define GRPC_CORE_IOMGR_SOCKADDR_POSIX_H #define GRPC_CORE_IOMGR_SOCKADDR_POSIX_H
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h> #include <unistd.h>
#endif /* GRPC_CORE_IOMGR_SOCKADDR_POSIX_H */ #endif /* GRPC_CORE_IOMGR_SOCKADDR_POSIX_H */

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

@ -36,6 +36,8 @@
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
// must be included after the above
#include <mswsock.h> #include <mswsock.h>
#endif /* GRPC_CORE_IOMGR_SOCKADDR_WIN32_H */ #endif /* GRPC_CORE_IOMGR_SOCKADDR_WIN32_H */

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -38,23 +38,23 @@
#include "src/core/iomgr/socket_utils_posix.h" #include "src/core/iomgr/socket_utils_posix.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <limits.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <string.h>
#include <errno.h>
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/support/string.h"
#include <grpc/support/host_port.h> #include <grpc/support/host_port.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/support/string.h"
/* set a socket to non blocking mode */ /* set a socket to non blocking mode */
int grpc_set_socket_nonblocking(int fd, int non_blocking) { int grpc_set_socket_nonblocking(int fd, int non_blocking) {

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -37,8 +37,8 @@
#include "src/core/iomgr/socket_utils_posix.h" #include "src/core/iomgr/socket_utils_posix.h"
#include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h>
int grpc_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int grpc_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen,
int nonblock, int cloexec) { int nonblock, int cloexec) {

@ -34,8 +34,8 @@
#ifndef GRPC_CORE_IOMGR_SOCKET_UTILS_POSIX_H #ifndef GRPC_CORE_IOMGR_SOCKET_UTILS_POSIX_H
#define GRPC_CORE_IOMGR_SOCKET_UTILS_POSIX_H #define GRPC_CORE_IOMGR_SOCKET_UTILS_POSIX_H
#include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h>
/* a wrapper for accept or accept4 */ /* a wrapper for accept or accept4 */
int grpc_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int grpc_accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen,

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -36,6 +36,8 @@
#ifdef GPR_WINSOCK_SOCKET #ifdef GPR_WINSOCK_SOCKET
#include <winsock2.h> #include <winsock2.h>
// must be included after winsock2.h
#include <mswsock.h> #include <mswsock.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>

@ -37,11 +37,11 @@
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <winsock2.h> #include <winsock2.h>
#include <grpc/support/sync.h>
#include <grpc/support/atm.h> #include <grpc/support/atm.h>
#include <grpc/support/sync.h>
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/exec_ctx.h" #include "src/core/iomgr/exec_ctx.h"
#include "src/core/iomgr/iomgr_internal.h"
/* This holds the data for an outstanding read or write on a socket. /* This holds the data for an outstanding read or write on a socket.
The mutex to protect the concurrent access to that data is the one The mutex to protect the concurrent access to that data is the one

@ -34,10 +34,10 @@
#ifndef GRPC_CORE_IOMGR_TCP_CLIENT_H #ifndef GRPC_CORE_IOMGR_TCP_CLIENT_H
#define GRPC_CORE_IOMGR_TCP_CLIENT_H #define GRPC_CORE_IOMGR_TCP_CLIENT_H
#include <grpc/support/time.h>
#include "src/core/iomgr/endpoint.h" #include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/pollset_set.h" #include "src/core/iomgr/pollset_set.h"
#include "src/core/iomgr/sockaddr.h" #include "src/core/iomgr/sockaddr.h"
#include <grpc/support/time.h>
/* Asynchronously connect to an address (specified as (addr, len)), and call /* Asynchronously connect to an address (specified as (addr, len)), and call
cb with arg and the completed connection when done (or call cb with arg and cb with arg and the completed connection when done (or call cb with arg and

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

@ -43,13 +43,13 @@
#include <grpc/support/slice_buffer.h> #include <grpc/support/slice_buffer.h>
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
#include "src/core/iomgr/timer.h"
#include "src/core/iomgr/iocp_windows.h" #include "src/core/iomgr/iocp_windows.h"
#include "src/core/iomgr/tcp_client.h"
#include "src/core/iomgr/tcp_windows.h"
#include "src/core/iomgr/sockaddr.h" #include "src/core/iomgr/sockaddr.h"
#include "src/core/iomgr/sockaddr_utils.h" #include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/socket_windows.h" #include "src/core/iomgr/socket_windows.h"
#include "src/core/iomgr/tcp_client.h"
#include "src/core/iomgr/tcp_windows.h"
#include "src/core/iomgr/timer.h"
typedef struct { typedef struct {
grpc_closure *on_done; grpc_closure *on_done;

@ -297,7 +297,7 @@ static flush_result tcp_flush(grpc_tcp *tcp) {
unwind_slice_idx = tcp->outgoing_slice_idx; unwind_slice_idx = tcp->outgoing_slice_idx;
unwind_byte_idx = tcp->outgoing_byte_idx; unwind_byte_idx = tcp->outgoing_byte_idx;
for (iov_size = 0; tcp->outgoing_slice_idx != tcp->outgoing_buffer->count && for (iov_size = 0; tcp->outgoing_slice_idx != tcp->outgoing_buffer->count &&
iov_size != MAX_WRITE_IOVEC; iov_size != MAX_WRITE_IOVEC;
iov_size++) { iov_size++) {
iov[iov_size].iov_base = iov[iov_size].iov_base =
GPR_SLICE_START_PTR( GPR_SLICE_START_PTR(
@ -446,7 +446,7 @@ static char *tcp_get_peer(grpc_endpoint *ep) {
} }
static const grpc_endpoint_vtable vtable = { static const grpc_endpoint_vtable vtable = {
tcp_read, tcp_write, tcp_add_to_pollset, tcp_add_to_pollset_set, tcp_read, tcp_write, tcp_add_to_pollset, tcp_add_to_pollset_set,
tcp_shutdown, tcp_destroy, tcp_get_peer}; tcp_shutdown, tcp_destroy, tcp_get_peer};
grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd, size_t slice_size, grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd, size_t slice_size,

@ -52,20 +52,20 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/un.h>
#include <unistd.h> #include <unistd.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#include "src/core/iomgr/pollset_posix.h" #include "src/core/iomgr/pollset_posix.h"
#include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/sockaddr_utils.h" #include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/socket_utils_posix.h" #include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/tcp_posix.h" #include "src/core/iomgr/tcp_posix.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h" #include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
#define MIN_SAFE_ACCEPT_QUEUE_SIZE 100 #define MIN_SAFE_ACCEPT_QUEUE_SIZE 100
@ -81,7 +81,6 @@ struct grpc_tcp_listener {
union { union {
uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE]; uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr; struct sockaddr sockaddr;
struct sockaddr_un un;
} addr; } addr;
size_t addr_len; size_t addr_len;
int port; int port;
@ -98,14 +97,6 @@ struct grpc_tcp_listener {
int is_sibling; int is_sibling;
}; };
static void unlink_if_unix_domain_socket(const struct sockaddr_un *un) {
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
unlink(un->sun_path);
}
}
/* the overall server */ /* the overall server */
struct grpc_tcp_server { struct grpc_tcp_server {
gpr_refcount refs; gpr_refcount refs;
@ -203,9 +194,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
if (s->head) { if (s->head) {
grpc_tcp_listener *sp; grpc_tcp_listener *sp;
for (sp = s->head; sp; sp = sp->next) { for (sp = s->head; sp; sp = sp->next) {
if (sp->addr.sockaddr.sa_family == AF_UNIX) { grpc_unlink_if_unix_domain_socket(&sp->addr.sockaddr);
unlink_if_unix_domain_socket(&sp->addr.un);
}
sp->destroyed_closure.cb = destroyed_port; sp->destroyed_closure.cb = destroyed_port;
sp->destroyed_closure.cb_arg = s; sp->destroyed_closure.cb_arg = s;
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL, grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
@ -281,7 +270,7 @@ static int prepare_socket(int fd, const struct sockaddr *addr,
} }
if (!grpc_set_socket_nonblocking(fd, 1) || !grpc_set_socket_cloexec(fd, 1) || if (!grpc_set_socket_nonblocking(fd, 1) || !grpc_set_socket_cloexec(fd, 1) ||
(addr->sa_family != AF_UNIX && (!grpc_set_socket_low_latency(fd, 1) || (!grpc_is_unix_socket(addr) && (!grpc_set_socket_low_latency(fd, 1) ||
!grpc_set_socket_reuse_addr(fd, 1))) || !grpc_set_socket_reuse_addr(fd, 1))) ||
!grpc_set_socket_no_sigpipe_if_possible(fd)) { !grpc_set_socket_no_sigpipe_if_possible(fd)) {
gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd, gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd,
@ -451,9 +440,7 @@ int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
if (s->tail != NULL) { if (s->tail != NULL) {
port_index = s->tail->port_index + 1; port_index = s->tail->port_index + 1;
} }
if (((struct sockaddr *)addr)->sa_family == AF_UNIX) { grpc_unlink_if_unix_domain_socket((struct sockaddr *)addr);
unlink_if_unix_domain_socket(addr);
}
/* Check if this is a wildcard port, and if so, try to keep the port the same /* Check if this is a wildcard port, and if so, try to keep the port the same
as some previously created listener. */ as some previously created listener. */
@ -499,7 +486,6 @@ int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
/* If we didn't get a dualstack socket, also listen on 0.0.0.0. */ /* If we didn't get a dualstack socket, also listen on 0.0.0.0. */
if (port == 0 && sp != NULL) { if (port == 0 && sp != NULL) {
grpc_sockaddr_set_port((struct sockaddr *)&wild4, sp->port); grpc_sockaddr_set_port((struct sockaddr *)&wild4, sp->port);
sp2 = sp;
} }
addr = (struct sockaddr *)&wild4; addr = (struct sockaddr *)&wild4;
addr_len = sizeof(wild4); addr_len = sizeof(wild4);
@ -508,16 +494,18 @@ int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
fd = grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, &dsmode); fd = grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, &dsmode);
if (fd < 0) { if (fd < 0) {
gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno)); gpr_log(GPR_ERROR, "Unable to create socket: %s", strerror(errno));
} } else {
if (dsmode == GRPC_DSMODE_IPV4 && if (dsmode == GRPC_DSMODE_IPV4 &&
grpc_sockaddr_is_v4mapped(addr, &addr4_copy)) { grpc_sockaddr_is_v4mapped(addr, &addr4_copy)) {
addr = (struct sockaddr *)&addr4_copy; addr = (struct sockaddr *)&addr4_copy;
addr_len = sizeof(addr4_copy); addr_len = sizeof(addr4_copy);
} }
sp = add_socket_to_server(s, fd, addr, addr_len, port_index, fd_index); sp2 = sp;
if (sp2 != NULL && sp != NULL) { sp = add_socket_to_server(s, fd, addr, addr_len, port_index, fd_index);
sp2->sibling = sp; if (sp2 != NULL && sp != NULL) {
sp->is_sibling = 1; sp2->sibling = sp;
sp->is_sibling = 1;
}
} }
done: done:

@ -44,12 +44,12 @@
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
#include "src/core/iomgr/timer.h"
#include "src/core/iomgr/iocp_windows.h" #include "src/core/iomgr/iocp_windows.h"
#include "src/core/iomgr/sockaddr.h" #include "src/core/iomgr/sockaddr.h"
#include "src/core/iomgr/sockaddr_utils.h" #include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/socket_windows.h" #include "src/core/iomgr/socket_windows.h"
#include "src/core/iomgr/tcp_client.h" #include "src/core/iomgr/tcp_client.h"
#include "src/core/iomgr/timer.h"
static int set_non_block(SOCKET sock) { static int set_non_block(SOCKET sock) {
int status; int status;
@ -146,8 +146,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *tcpp, bool success) {
grpc_winsocket_callback_info *info = &socket->read_info; grpc_winsocket_callback_info *info = &socket->read_info;
if (success) { if (success) {
if (socket->read_info.wsa_error != 0 && !tcp->shutting_down) { if (info->wsa_error != 0 && !tcp->shutting_down) {
if (socket->read_info.wsa_error != WSAECONNRESET) { if (info->wsa_error != WSAECONNRESET) {
char *utf8_message = gpr_format_message(info->wsa_error); char *utf8_message = gpr_format_message(info->wsa_error);
gpr_log(GPR_ERROR, "ReadFile overlapped error: %s", utf8_message); gpr_log(GPR_ERROR, "ReadFile overlapped error: %s", utf8_message);
gpr_free(utf8_message); gpr_free(utf8_message);
@ -306,7 +306,7 @@ static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
ok = true; ok = true;
GPR_ASSERT(bytes_sent == tcp->write_slices->length); GPR_ASSERT(bytes_sent == tcp->write_slices->length);
} else { } else {
if (socket->read_info.wsa_error != WSAECONNRESET) { if (info->wsa_error != WSAECONNRESET) {
char *utf8_message = gpr_format_message(info->wsa_error); char *utf8_message = gpr_format_message(info->wsa_error);
gpr_log(GPR_ERROR, "WSASend error: %s", utf8_message); gpr_log(GPR_ERROR, "WSASend error: %s", utf8_message);
gpr_free(utf8_message); gpr_free(utf8_message);
@ -382,9 +382,9 @@ static char *win_get_peer(grpc_endpoint *ep) {
return gpr_strdup(tcp->peer_string); return gpr_strdup(tcp->peer_string);
} }
static grpc_endpoint_vtable vtable = {win_read, win_write, win_add_to_pollset, static grpc_endpoint_vtable vtable = {
win_add_to_pollset_set, win_shutdown, win_read, win_write, win_add_to_pollset, win_add_to_pollset_set,
win_destroy, win_get_peer}; win_shutdown, win_destroy, win_get_peer};
grpc_endpoint *grpc_tcp_create(grpc_winsocket *socket, char *peer_string) { grpc_endpoint *grpc_tcp_create(grpc_winsocket *socket, char *peer_string) {
grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp)); grpc_tcp *tcp = (grpc_tcp *)gpr_malloc(sizeof(grpc_tcp));

@ -34,10 +34,10 @@
#ifndef GRPC_CORE_IOMGR_TIMER_H #ifndef GRPC_CORE_IOMGR_TIMER_H
#define GRPC_CORE_IOMGR_TIMER_H #define GRPC_CORE_IOMGR_TIMER_H
#include "src/core/iomgr/iomgr.h"
#include "src/core/iomgr/exec_ctx.h"
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/iomgr/exec_ctx.h"
#include "src/core/iomgr/iomgr.h"
typedef struct grpc_timer { typedef struct grpc_timer {
gpr_timespec deadline; gpr_timespec deadline;

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

@ -0,0 +1,103 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/iomgr/unix_sockets_posix.h"
#ifdef GPR_HAVE_UNIX_SOCKET
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <grpc/support/alloc.h>
void grpc_create_socketpair_if_unix(int sv[2]) {
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
}
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name) {
struct sockaddr_un *un;
grpc_resolved_addresses *addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
addrs->naddrs = 1;
addrs->addrs = gpr_malloc(sizeof(grpc_resolved_address));
un = (struct sockaddr_un *)addrs->addrs->addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, name);
addrs->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return addrs;
}
int grpc_is_unix_socket(const struct sockaddr *addr) {
return addr->sa_family == AF_UNIX;
}
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return;
}
struct sockaddr_un *un = (struct sockaddr_un *)addr;
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
unlink(un->sun_path);
}
}
int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
struct sockaddr_un *un = (struct sockaddr_un *)addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, uri->path);
*len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return 1;
}
char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return gpr_strdup("localhost");
}
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return NULL;
}
char *result;
gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un *)addr)->sun_path);
return result;
}
#endif

@ -0,0 +1,61 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H
#define GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
#include "src/core/client_config/resolver_factory.h"
#include "src/core/client_config/uri_parser.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/sockaddr.h"
void grpc_create_socketpair_if_unix(int sv[2]);
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name);
int grpc_is_unix_socket(const struct sockaddr *addr);
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr);
int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len);
char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri);
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr);
#endif /* GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H */

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015-2016, Google Inc. * Copyright 2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -31,34 +31,31 @@
* *
*/ */
#ifndef GRPC_CORE_HTTPCLI_PARSER_H #include "src/core/iomgr/unix_sockets_posix.h"
#define GRPC_CORE_HTTPCLI_PARSER_H
#include "src/core/httpcli/httpcli.h" #ifndef GPR_HAVE_UNIX_SOCKET
#include <grpc/support/port_platform.h>
#include <grpc/support/slice.h>
typedef enum { void grpc_create_socketpair_if_unix(int sv[2]) {}
GRPC_HTTPCLI_INITIAL_RESPONSE,
GRPC_HTTPCLI_HEADERS,
GRPC_HTTPCLI_BODY
} grpc_httpcli_parser_state;
typedef struct { grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name) {
grpc_httpcli_parser_state state; return NULL;
}
grpc_httpcli_response r; int grpc_is_unix_socket(const struct sockaddr *addr) { return false; }
size_t body_capacity;
size_t hdr_capacity;
uint8_t cur_line[GRPC_HTTPCLI_MAX_HEADER_LENGTH]; void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr) {}
size_t cur_line_length;
} grpc_httpcli_parser;
void grpc_httpcli_parser_init(grpc_httpcli_parser* parser); int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
void grpc_httpcli_parser_destroy(grpc_httpcli_parser* parser); return 0;
}
int grpc_httpcli_parser_parse(grpc_httpcli_parser* parser, gpr_slice slice); char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
int grpc_httpcli_parser_eof(grpc_httpcli_parser* parser); grpc_uri *uri) {
return NULL;
}
#endif /* GRPC_CORE_HTTPCLI_PARSER_H */ char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
return NULL;
}
#endif

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -40,8 +40,8 @@
#ifdef GPR_POSIX_NO_SPECIAL_WAKEUP_FD #ifdef GPR_POSIX_NO_SPECIAL_WAKEUP_FD
#include "src/core/iomgr/wakeup_fd_posix.h"
#include <stddef.h> #include <stddef.h>
#include "src/core/iomgr/wakeup_fd_posix.h"
static int check_availability_invalid(void) { return 0; } static int check_availability_invalid(void) { return 0; }

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,9 +35,9 @@
#ifdef GPR_POSIX_WAKEUP_FD #ifdef GPR_POSIX_WAKEUP_FD
#include "src/core/iomgr/wakeup_fd_posix.h"
#include "src/core/iomgr/wakeup_fd_pipe.h"
#include <stddef.h> #include <stddef.h>
#include "src/core/iomgr/wakeup_fd_pipe.h"
#include "src/core/iomgr/wakeup_fd_posix.h"
static const grpc_wakeup_fd_vtable *wakeup_fd_vtable = NULL; static const grpc_wakeup_fd_vtable *wakeup_fd_vtable = NULL;
int grpc_allow_specialized_wakeup_fd = 1; int grpc_allow_specialized_wakeup_fd = 1;

@ -34,10 +34,10 @@
#ifndef GRPC_CORE_IOMGR_WORKQUEUE_H #ifndef GRPC_CORE_IOMGR_WORKQUEUE_H
#define GRPC_CORE_IOMGR_WORKQUEUE_H #define GRPC_CORE_IOMGR_WORKQUEUE_H
#include "src/core/iomgr/iomgr.h"
#include "src/core/iomgr/pollset.h"
#include "src/core/iomgr/closure.h" #include "src/core/iomgr/closure.h"
#include "src/core/iomgr/exec_ctx.h" #include "src/core/iomgr/exec_ctx.h"
#include "src/core/iomgr/iomgr.h"
#include "src/core/iomgr/pollset.h"
#ifdef GPR_POSIX_SOCKET #ifdef GPR_POSIX_SOCKET
#include "src/core/iomgr/workqueue_posix.h" #include "src/core/iomgr/workqueue_posix.h"

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -31,8 +31,8 @@
* *
*/ */
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -39,9 +39,9 @@
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/time.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/thd.h> #include <grpc/support/thd.h>
#include <grpc/support/time.h>
#include <stdio.h> #include <stdio.h>
typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type; typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type;

@ -331,6 +331,6 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
const grpc_channel_filter grpc_client_auth_filter = { const grpc_channel_filter grpc_client_auth_filter = {
auth_start_transport_op, grpc_channel_next_op, sizeof(call_data), auth_start_transport_op, grpc_channel_next_op, sizeof(call_data),
init_call_elem, set_pollset, destroy_call_elem, sizeof(channel_data), init_call_elem, set_pollset, destroy_call_elem,
init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, sizeof(channel_data), init_channel_elem, destroy_channel_elem,
"client-auth"}; grpc_call_next_get_peer, "client-auth"};

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

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

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

@ -36,11 +36,11 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include "src/core/security/security_context.h"
#include "src/core/security/secure_endpoint.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/slice_buffer.h> #include <grpc/support/slice_buffer.h>
#include "src/core/security/secure_endpoint.h"
#include "src/core/security/security_context.h"
#define GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE 256 #define GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE 256

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

@ -32,14 +32,14 @@
*/ */
#include "src/core/security/secure_endpoint.h" #include "src/core/security/secure_endpoint.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>
#include <grpc/support/slice_buffer.h>
#include <grpc/support/slice.h> #include <grpc/support/slice.h>
#include <grpc/support/slice_buffer.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include "src/core/tsi/transport_security_interface.h"
#include "src/core/debug/trace.h" #include "src/core/debug/trace.h"
#include "src/core/support/string.h"
#include "src/core/tsi/transport_security_interface.h"
#define STAGING_BUFFER_SIZE 8192 #define STAGING_BUFFER_SIZE 8192
@ -354,8 +354,9 @@ static char *endpoint_get_peer(grpc_endpoint *secure_ep) {
} }
static const grpc_endpoint_vtable vtable = { static const grpc_endpoint_vtable vtable = {
endpoint_read, endpoint_write, endpoint_add_to_pollset, endpoint_read, endpoint_write,
endpoint_add_to_pollset_set, endpoint_shutdown, endpoint_destroy, endpoint_add_to_pollset, endpoint_add_to_pollset_set,
endpoint_shutdown, endpoint_destroy,
endpoint_get_peer}; endpoint_get_peer};
grpc_endpoint *grpc_secure_endpoint_create( grpc_endpoint *grpc_secure_endpoint_create(

@ -34,8 +34,8 @@
#ifndef GRPC_CORE_SECURITY_SECURE_ENDPOINT_H #ifndef GRPC_CORE_SECURITY_SECURE_ENDPOINT_H
#define GRPC_CORE_SECURITY_SECURE_ENDPOINT_H #define GRPC_CORE_SECURITY_SECURE_ENDPOINT_H
#include "src/core/iomgr/endpoint.h"
#include <grpc/support/slice.h> #include <grpc/support/slice.h>
#include "src/core/iomgr/endpoint.h"
struct tsi_frame_protector; struct tsi_frame_protector;

@ -34,9 +34,9 @@
#include <string.h> #include <string.h>
#include "src/core/security/security_context.h" #include "src/core/security/security_context.h"
#include "src/core/support/string.h"
#include "src/core/surface/api_trace.h" #include "src/core/surface/api_trace.h"
#include "src/core/surface/call.h" #include "src/core/surface/call.h"
#include "src/core/support/string.h"
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>

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

Loading…
Cancel
Save