Merge branch 'cleaner-posix2' into cleaner-posix3

pull/5647/head
Craig Tiller 9 years ago
commit ac04b7f537
  1. 2
      BUILD
  2. 2
      Makefile
  3. 3
      PYTHON-MANIFEST.in
  4. 24
      build.yaml
  5. 84
      config.m4
  6. 4
      doc/health-checking.md
  7. 2
      examples/csharp/helloworld/.nuget/packages.config
  8. 25
      examples/csharp/helloworld/Greeter/Greeter.csproj
  9. 28
      examples/csharp/helloworld/Greeter/Helloworld.cs
  10. 2
      examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
  11. 12
      examples/csharp/helloworld/Greeter/packages.config
  12. 25
      examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
  13. 12
      examples/csharp/helloworld/GreeterClient/packages.config
  14. 25
      examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
  15. 12
      examples/csharp/helloworld/GreeterServer/packages.config
  16. 29
      examples/csharp/helloworld/README.md
  17. 2
      examples/csharp/helloworld/generate_protos.bat
  18. 2
      examples/csharp/route_guide/.nuget/packages.config
  19. 108
      examples/csharp/route_guide/RouteGuide/RouteGuide.cs
  20. 20
      examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
  21. 2
      examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
  22. 10
      examples/csharp/route_guide/RouteGuide/packages.config
  23. 20
      examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
  24. 10
      examples/csharp/route_guide/RouteGuideClient/packages.config
  25. 20
      examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
  26. 10
      examples/csharp/route_guide/RouteGuideServer/packages.config
  27. 2
      examples/csharp/route_guide/generate_protos.bat
  28. 26
      examples/python/README.md
  29. 36
      examples/python/helloworld/run_client.sh
  30. 37
      examples/python/helloworld/run_server.sh
  31. 36
      examples/python/route_guide/run_client.sh
  32. 36
      examples/python/route_guide/run_server.sh
  33. 17
      include/grpc++/alarm.h
  34. 30
      package.xml
  35. 1
      setup.py
  36. 2
      src/core/client_config/lb_policy.c
  37. 2
      src/core/client_config/lb_policy.h
  38. 1
      src/core/httpcli/httpcli.c
  39. 2
      src/core/httpcli/httpcli.h
  40. 14
      src/core/httpcli/httpcli_security_connector.c
  41. 91
      src/core/iomgr/ev_poll_and_epoll_posix.c
  42. 41
      src/core/iomgr/ev_poll_posix.c
  43. 2
      src/core/iomgr/ev_posix.c
  44. 2
      src/core/iomgr/ev_posix.h
  45. 2
      src/core/iomgr/iomgr_internal.h
  46. 2
      src/core/iomgr/iomgr_posix.c
  47. 2
      src/core/iomgr/pollset.h
  48. 2
      src/core/iomgr/pollset_set.h
  49. 2
      src/core/iomgr/pollset_set_windows.c
  50. 2
      src/core/iomgr/pollset_set_windows.h
  51. 5
      src/core/iomgr/pollset_windows.c
  52. 2
      src/core/iomgr/pollset_windows.h
  53. 1
      src/core/iomgr/udp_server.c
  54. 1
      src/core/security/client_auth_filter.c
  55. 6
      src/core/security/credentials.c
  56. 6
      src/core/security/credentials.h
  57. 26
      src/core/security/google_default_credentials.c
  58. 22
      src/core/security/handshake.c
  59. 3
      src/core/security/handshake.h
  60. 107
      src/core/security/security_connector.c
  61. 64
      src/core/security/security_connector.h
  62. 14
      src/core/security/server_secure_chttp2.c
  63. 5
      src/core/surface/alarm.c
  64. 48
      src/core/surface/completion_queue.c
  65. 7
      src/core/surface/secure_channel_create.c
  66. 51
      src/cpp/common/alarm.cc
  67. 6
      src/csharp/Grpc.Core/Internal/PlatformApis.cs
  68. 14
      src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs
  69. 48
      src/csharp/Grpc.HealthCheck.Tests/HealthServiceImplTest.cs
  70. 2
      src/csharp/Grpc.HealthCheck/Grpc.HealthCheck.nuspec
  71. 72
      src/csharp/Grpc.HealthCheck/Health.cs
  72. 30
      src/csharp/Grpc.HealthCheck/HealthGrpc.cs
  73. 46
      src/csharp/Grpc.HealthCheck/HealthServiceImpl.cs
  74. 116
      src/csharp/README.md
  75. 2
      src/csharp/generate_proto_csharp.sh
  76. 6
      src/node/health_check/health.js
  77. 7
      src/proto/grpc/health/v1/health.proto
  78. 2
      src/python/grpcio/precompiled.py
  79. 2
      src/python/grpcio_health_checking/grpc/health/v1/__init__.py
  80. 4
      src/python/grpcio_health_checking/grpc/health/v1/health.proto
  81. 6
      src/python/grpcio_health_checking/grpc/health/v1/health.py
  82. 2
      src/ruby/.rubocop.yml
  83. 37
      src/ruby/ext/grpc/rb_grpc.c
  84. 4
      src/ruby/lib/grpc/core/time_consts.rb
  85. 4
      src/ruby/lib/grpc/errors.rb
  86. 4
      src/ruby/pb/README.md
  87. 4
      src/ruby/pb/generate_proto_ruby.sh
  88. 22
      src/ruby/pb/grpc/health/checker.rb
  89. 28
      src/ruby/pb/grpc/health/v1/health.rb
  90. 8
      src/ruby/pb/grpc/health/v1/health_services.rb
  91. 29
      src/ruby/pb/grpc/health/v1alpha/health.rb
  92. 58
      src/ruby/spec/pb/health/checker_spec.rb
  93. 17
      templates/config.m4.template
  94. 4
      templates/package.xml.template
  95. 1
      templates/tools/run_tests/tests.json.template
  96. 12
      test/core/end2end/fixtures/h2_uchannel.c
  97. 24
      test/core/httpcli/httpcli_test.c
  98. 23
      test/core/httpcli/httpscli_test.c
  99. 6
      test/core/iomgr/endpoint_pair_test.c
  100. 56
      test/core/iomgr/fd_posix_test.c
  101. Some files were not shown because too many files have changed in this diff Show More

@ -814,7 +814,6 @@ cc_library(
"src/cpp/client/credentials.cc", "src/cpp/client/credentials.cc",
"src/cpp/client/generic_stub.cc", "src/cpp/client/generic_stub.cc",
"src/cpp/client/insecure_credentials.cc", "src/cpp/client/insecure_credentials.cc",
"src/cpp/common/alarm.cc",
"src/cpp/common/call.cc", "src/cpp/common/call.cc",
"src/cpp/common/channel_arguments.cc", "src/cpp/common/channel_arguments.cc",
"src/cpp/common/completion_queue.cc", "src/cpp/common/completion_queue.cc",
@ -938,7 +937,6 @@ cc_library(
"src/cpp/client/credentials.cc", "src/cpp/client/credentials.cc",
"src/cpp/client/generic_stub.cc", "src/cpp/client/generic_stub.cc",
"src/cpp/client/insecure_credentials.cc", "src/cpp/client/insecure_credentials.cc",
"src/cpp/common/alarm.cc",
"src/cpp/common/call.cc", "src/cpp/common/call.cc",
"src/cpp/common/channel_arguments.cc", "src/cpp/common/channel_arguments.cc",
"src/cpp/common/completion_queue.cc", "src/cpp/common/completion_queue.cc",

@ -2972,7 +2972,6 @@ LIBGRPC++_SRC = \
src/cpp/client/credentials.cc \ src/cpp/client/credentials.cc \
src/cpp/client/generic_stub.cc \ src/cpp/client/generic_stub.cc \
src/cpp/client/insecure_credentials.cc \ src/cpp/client/insecure_credentials.cc \
src/cpp/common/alarm.cc \
src/cpp/common/call.cc \ src/cpp/common/call.cc \
src/cpp/common/channel_arguments.cc \ src/cpp/common/channel_arguments.cc \
src/cpp/common/completion_queue.cc \ src/cpp/common/completion_queue.cc \
@ -3253,7 +3252,6 @@ LIBGRPC++_UNSECURE_SRC = \
src/cpp/client/credentials.cc \ src/cpp/client/credentials.cc \
src/cpp/client/generic_stub.cc \ src/cpp/client/generic_stub.cc \
src/cpp/client/insecure_credentials.cc \ src/cpp/client/insecure_credentials.cc \
src/cpp/common/alarm.cc \
src/cpp/common/call.cc \ src/cpp/common/call.cc \
src/cpp/common/channel_arguments.cc \ src/cpp/common/channel_arguments.cc \
src/cpp/common/completion_queue.cc \ src/cpp/common/completion_queue.cc \

@ -1,4 +1,5 @@
graft src/python/grpcio/grpc recursive-include src/python/grpcio/grpc *.c *.h *.py *.pyx *.pxd *.pxi *.python *.pem
recursive-exclude src/python/grpcio/grpc/_cython *.so *.pyd
graft src/python/grpcio/tests graft src/python/grpcio/tests
graft src/core graft src/core
graft include/grpc graft include/grpc

@ -184,7 +184,6 @@ filegroups:
- src/cpp/client/credentials.cc - src/cpp/client/credentials.cc
- src/cpp/client/generic_stub.cc - src/cpp/client/generic_stub.cc
- src/cpp/client/insecure_credentials.cc - src/cpp/client/insecure_credentials.cc
- src/cpp/common/alarm.cc
- src/cpp/common/call.cc - src/cpp/common/call.cc
- src/cpp/common/channel_arguments.cc - src/cpp/common/channel_arguments.cc
- src/cpp/common/completion_queue.cc - src/cpp/common/completion_queue.cc
@ -1952,6 +1951,7 @@ targets:
- linux - linux
- posix - posix
- name: alarm_cpp_test - name: alarm_cpp_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -1964,6 +1964,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: async_end2end_test - name: async_end2end_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2010,6 +2011,7 @@ targets:
- linux - linux
- posix - posix
- name: auth_property_iterator_test - name: auth_property_iterator_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2022,6 +2024,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: channel_arguments_test - name: channel_arguments_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2031,6 +2034,7 @@ targets:
- grpc - grpc
- gpr - gpr
- name: cli_call_test - name: cli_call_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2043,6 +2047,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: client_crash_test - name: client_crash_test
gtest: true
cpu_cost: 0.1 cpu_cost: 0.1
build: test build: test
language: c++ language: c++
@ -2073,6 +2078,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: credentials_test - name: credentials_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2082,6 +2088,7 @@ targets:
- grpc - grpc
- gpr - gpr
- name: cxx_byte_buffer_test - name: cxx_byte_buffer_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2093,6 +2100,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: cxx_slice_test - name: cxx_slice_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2104,6 +2112,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: cxx_string_ref_test - name: cxx_string_ref_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2111,6 +2120,7 @@ targets:
deps: deps:
- grpc++ - grpc++
- name: cxx_time_test - name: cxx_time_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2122,6 +2132,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: end2end_test - name: end2end_test
gtest: true
cpu_cost: 0.5 cpu_cost: 0.5
build: test build: test
language: c++ language: c++
@ -2152,6 +2163,7 @@ targets:
- linux - linux
- posix - posix
- name: generic_end2end_test - name: generic_end2end_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2228,6 +2240,7 @@ targets:
vs_config_type: Application vs_config_type: Application
vs_project_guid: '{069E9D05-B78B-4751-9252-D21EBAE7DE8E}' vs_project_guid: '{069E9D05-B78B-4751-9252-D21EBAE7DE8E}'
- name: grpclb_api_test - name: grpclb_api_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2239,6 +2252,7 @@ targets:
- grpc++ - grpc++
- grpc - grpc
- name: hybrid_end2end_test - name: hybrid_end2end_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2318,6 +2332,7 @@ targets:
- gpr - gpr
- grpc++_test_config - grpc++_test_config
- name: mock_test - name: mock_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2453,6 +2468,7 @@ targets:
- gpr - gpr
- grpc++_test_config - grpc++_test_config
- name: secure_auth_context_test - name: secure_auth_context_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2482,6 +2498,7 @@ targets:
- linux - linux
- posix - posix
- name: server_crash_test - name: server_crash_test
gtest: true
cpu_cost: 0.1 cpu_cost: 0.1
build: test build: test
language: c++ language: c++
@ -2512,6 +2529,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: shutdown_test - name: shutdown_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2535,6 +2553,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: streaming_throughput_test - name: streaming_throughput_test
gtest: true
build: test build: test
language: c++ language: c++
src: src:
@ -2611,6 +2630,7 @@ targets:
- linux - linux
- posix - posix
- name: thread_stress_test - name: thread_stress_test
gtest: true
cpu_cost: 100 cpu_cost: 100
build: test build: test
language: c++ language: c++
@ -2624,6 +2644,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: zookeeper_test - name: zookeeper_test
gtest: true
build: test build: test
run: false run: false
language: c++ language: c++
@ -2823,7 +2844,6 @@ php_config_m4:
- grpc - grpc
- gpr - gpr
- boringssl - boringssl
- z
headers: headers:
- src/php/ext/grpc/byte_buffer.h - src/php/ext/grpc/byte_buffer.h
- src/php/ext/grpc/call.h - src/php/ext/grpc/call.h

@ -531,22 +531,74 @@ if test "$PHP_GRPC" != "no"; then
third_party/boringssl/ssl/t1_enc.c \ third_party/boringssl/ssl/t1_enc.c \
third_party/boringssl/ssl/t1_lib.c \ third_party/boringssl/ssl/t1_lib.c \
third_party/boringssl/ssl/tls_record.c \ third_party/boringssl/ssl/tls_record.c \
third_party/zlib/adler32.c \ , $ext_shared, , -Wall -Werror \
third_party/zlib/compress.c \ -Wno-parentheses-equality -Wno-unused-value -std=c11 \
third_party/zlib/crc32.c \
third_party/zlib/deflate.c \
third_party/zlib/gzclose.c \
third_party/zlib/gzlib.c \
third_party/zlib/gzread.c \
third_party/zlib/gzwrite.c \
third_party/zlib/infback.c \
third_party/zlib/inffast.c \
third_party/zlib/inflate.c \
third_party/zlib/inftrees.c \
third_party/zlib/trees.c \
third_party/zlib/uncompr.c \
third_party/zlib/zutil.c \
, $ext_shared, , -Wall -Werror -std=c11 \
-fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN \ -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN \
-D_HAS_EXCEPTIONS=0 -DNOMINMAX) -D_HAS_EXCEPTIONS=0 -DNOMINMAX)
PHP_ADD_BUILD_DIR($ext_builddir/src/php/ext/grpc)
PHP_ADD_BUILD_DIR($ext_builddir/src/boringssl)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/census)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/channel)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/client_config)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/client_config/lb_policies)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/client_config/resolvers)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/compression)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/debug)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/httpcli)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/iomgr)
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/proto/grpc/lb/v0)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/security)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/support)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/surface)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/transport)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/transport/chttp2)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/tsi)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/aes)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/asn1)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/base64)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/bio)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/bn)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/bn/asm)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/buf)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/bytestring)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/chacha)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/cipher)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/cmac)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/conf)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/curve25519)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/des)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/dh)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/digest)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/dsa)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/ec)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/ecdh)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/ecdsa)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/engine)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/err)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/evp)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/hkdf)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/hmac)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/lhash)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/md4)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/md5)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/modes)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/obj)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/pem)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/pkcs8)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/poly1305)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/rand)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/rc4)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/rsa)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/sha)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/stack)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/x509)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/crypto/x509v3)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/ssl)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/boringssl/ssl/pqueue)
PHP_ADD_BUILD_DIR($ext_builddir/third_party/nanopb)
fi fi

@ -26,7 +26,7 @@ The server should export a service defined in the following proto:
``` ```
syntax = "proto3"; syntax = "proto3";
package grpc.health.v1alpha; package grpc.health.v1;
message HealthCheckRequest { message HealthCheckRequest {
string service = 1; string service = 1;
@ -49,7 +49,7 @@ service Health {
A client can query the server’s health status by calling the `Check` method, and A client can query the server’s health status by calling the `Check` method, and
a deadline should be set on the rpc. The client can optionally set the service a deadline should be set on the rpc. The client can optionally set the service
name it wants to query for health status. The suggested format of service name name it wants to query for health status. The suggested format of service name
is `package_names.ServiceName`, such as `grpc.health.v1alpha.Health`. is `package_names.ServiceName`, such as `grpc.health.v1.Health`.
The server should register all the services manually and set The server should register all the services manually and set
the individual status, including an empty service name and its status. For each the individual status, including an empty service name and its status. For each

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Grpc.Tools" version="0.12.0" /> <package id="Grpc.Tools" version="0.13.0" />
</packages> </packages>

@ -10,7 +10,7 @@
<RootNamespace>Greeter</RootNamespace> <RootNamespace>Greeter</RootNamespace>
<AssemblyName>Greeter</AssemblyName> <AssemblyName>Greeter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>4eea1d1c</NuGetPackageImportStamp> <NuGetPackageImportStamp>39f4a691</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -31,15 +31,18 @@
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf"> <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference> </Reference>
<Reference Include="Grpc.Core"> <Reference Include="Grpc.Core, Version=0.13.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Core.0.12.0\lib\net45\Grpc.Core.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Grpc.Core.0.13.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Interactive.Async"> <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -53,15 +56,11 @@
<None Include="protos\helloworld.proto" /> <None Include="protos\helloworld.proto" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" /> <Import Project="..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets'))" /> <Error Condition="!Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
</Target> </Target>
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" />
<Import Project="..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
</Project> </Project>

@ -9,16 +9,18 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic; using scg = global::System.Collections.Generic;
namespace Helloworld { namespace Helloworld {
/// <summary>Holder for reflection information generated from helloworld.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Helloworld { public static partial class HelloworldReflection {
#region Descriptor #region Descriptor
/// <summary>File descriptor for helloworld.proto</summary>
public static pbr::FileDescriptor Descriptor { public static pbr::FileDescriptor Descriptor {
get { return descriptor; } get { return descriptor; }
} }
private static pbr::FileDescriptor descriptor; private static pbr::FileDescriptor descriptor;
static Helloworld() { static HelloworldReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"ChBoZWxsb3dvcmxkLnByb3RvEgpoZWxsb3dvcmxkIhwKDEhlbGxvUmVxdWVz", "ChBoZWxsb3dvcmxkLnByb3RvEgpoZWxsb3dvcmxkIhwKDEhlbGxvUmVxdWVz",
@ -26,24 +28,27 @@ namespace Helloworld {
"CTJJCgdHcmVldGVyEj4KCFNheUhlbGxvEhguaGVsbG93b3JsZC5IZWxsb1Jl", "CTJJCgdHcmVldGVyEj4KCFNheUhlbGxvEhguaGVsbG93b3JsZC5IZWxsb1Jl",
"cXVlc3QaFi5oZWxsb3dvcmxkLkhlbGxvUmVwbHkiAEIYChBpby5ncnBjLmV4", "cXVlc3QaFi5oZWxsb3dvcmxkLkhlbGxvUmVwbHkiAEIYChBpby5ncnBjLmV4",
"YW1wbGVzogIDSExXYgZwcm90bzM=")); "YW1wbGVzogIDSExXYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
new pbr::GeneratedCodeInfo(typeof(global::Helloworld.HelloRequest), new[]{ "Name" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Helloworld.HelloRequest), global::Helloworld.HelloRequest.Parser, new[]{ "Name" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Helloworld.HelloReply), new[]{ "Message" }, null, null, null) new pbr::GeneratedCodeInfo(typeof(global::Helloworld.HelloReply), global::Helloworld.HelloReply.Parser, new[]{ "Message" }, null, null, null)
})); }));
} }
#endregion #endregion
} }
#region Messages #region Messages
/// <summary>
/// The request message containing the user's name.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class HelloRequest : pb::IMessage<HelloRequest> { public sealed partial class HelloRequest : pb::IMessage<HelloRequest> {
private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest()); private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest());
public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } } public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Helloworld.Helloworld.Descriptor.MessageTypes[0]; } get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -64,6 +69,7 @@ namespace Helloworld {
return new HelloRequest(this); return new HelloRequest(this);
} }
/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
public string Name { public string Name {
@ -95,7 +101,7 @@ namespace Helloworld {
} }
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.Default.Format(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
@ -139,13 +145,16 @@ namespace Helloworld {
} }
/// <summary>
/// The response message containing the greetings
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class HelloReply : pb::IMessage<HelloReply> { public sealed partial class HelloReply : pb::IMessage<HelloReply> {
private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply()); private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply());
public static pb::MessageParser<HelloReply> Parser { get { return _parser; } } public static pb::MessageParser<HelloReply> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Helloworld.Helloworld.Descriptor.MessageTypes[1]; } get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -166,6 +175,7 @@ namespace Helloworld {
return new HelloReply(this); return new HelloReply(this);
} }
/// <summary>Field number for the "message" field.</summary>
public const int MessageFieldNumber = 1; public const int MessageFieldNumber = 1;
private string message_ = ""; private string message_ = "";
public string Message { public string Message {
@ -197,7 +207,7 @@ namespace Helloworld {
} }
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.Default.Format(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {

@ -25,7 +25,7 @@ namespace Helloworld {
// service descriptor // service descriptor
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{ {
get { return global::Helloworld.Helloworld.Descriptor.Services[0]; } get { return global::Helloworld.HelloworldReflection.Descriptor.Services[0]; }
} }
// client interface // client interface

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" /> <package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
<package id="Grpc" version="0.12.0" targetFramework="net45" /> <package id="Grpc" version="0.13.0" targetFramework="net45" />
<package id="Grpc.Core" version="0.12.0" targetFramework="net45" /> <package id="Grpc.Core" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.204.1" targetFramework="net45" /> <package id="grpc.native.csharp" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.10" targetFramework="net45" /> <package id="Ix-Async" version="1.2.5" targetFramework="net45" />
<package id="grpc.native.csharp" version="0.12.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
</packages> </packages>

@ -10,7 +10,7 @@
<RootNamespace>GreeterClient</RootNamespace> <RootNamespace>GreeterClient</RootNamespace>
<AssemblyName>GreeterClient</AssemblyName> <AssemblyName>GreeterClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>29206d49</NuGetPackageImportStamp> <NuGetPackageImportStamp>dcebbc77</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -31,15 +31,18 @@
<Externalconsole>true</Externalconsole> <Externalconsole>true</Externalconsole>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf"> <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference> </Reference>
<Reference Include="Grpc.Core"> <Reference Include="Grpc.Core, Version=0.13.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Core.0.12.0\lib\net45\Grpc.Core.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Grpc.Core.0.13.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Interactive.Async"> <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -56,15 +59,11 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" /> <Import Project="..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets'))" /> <Error Condition="!Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
</Target> </Target>
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" />
<Import Project="..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
</Project> </Project>

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" /> <package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
<package id="Grpc" version="0.12.0" targetFramework="net45" /> <package id="Grpc" version="0.13.0" targetFramework="net45" />
<package id="Grpc.Core" version="0.12.0" targetFramework="net45" /> <package id="Grpc.Core" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.204.1" targetFramework="net45" /> <package id="grpc.native.csharp" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.10" targetFramework="net45" /> <package id="Ix-Async" version="1.2.5" targetFramework="net45" />
<package id="grpc.native.csharp" version="0.12.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
</packages> </packages>

@ -10,7 +10,7 @@
<RootNamespace>GreeterServer</RootNamespace> <RootNamespace>GreeterServer</RootNamespace>
<AssemblyName>GreeterServer</AssemblyName> <AssemblyName>GreeterServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>8a2cae0f</NuGetPackageImportStamp> <NuGetPackageImportStamp>2ea5dfd0</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -31,15 +31,18 @@
<Externalconsole>true</Externalconsole> <Externalconsole>true</Externalconsole>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf"> <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference> </Reference>
<Reference Include="Grpc.Core"> <Reference Include="Grpc.Core, Version=0.13.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Core.0.12.0\lib\net45\Grpc.Core.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Grpc.Core.0.13.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Interactive.Async"> <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -56,15 +59,11 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" /> <Import Project="..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets'))" /> <Error Condition="!Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
</Target> </Target>
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" />
<Import Project="..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
</Project> </Project>

@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" /> <package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
<package id="Grpc" version="0.12.0" targetFramework="net45" /> <package id="Grpc" version="0.13.0" targetFramework="net45" />
<package id="Grpc.Core" version="0.12.0" targetFramework="net45" /> <package id="Grpc.Core" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.204.1" targetFramework="net45" /> <package id="grpc.native.csharp" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.10" targetFramework="net45" /> <package id="Ix-Async" version="1.2.5" targetFramework="net45" />
<package id="grpc.native.csharp" version="0.12.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
</packages> </packages>

@ -16,35 +16,17 @@ PREREQUISITES
- Visual Studio 2013 or 2015 - Visual Studio 2013 or 2015
**Linux** **Linux**
- Mono - Mono 4.0+
- Monodevelop 5.9 with NuGet Add-in installed - Monodevelop 5.9+ (with NuGet plugin installed)
**Mac OS X** **Mac OS X**
- Xamarin Studio (with NuGet plugin installed) - Xamarin Studio 5.9+
- [homebrew][] - [homebrew][]
BUILD BUILD
------- -------
**Windows** - Open solution `Greeter.sln` with Visual Studio, Monodevelop (on Linux) or Xamarin Studio (on Mac OS X)
- Open solution `Greeter.sln` with Visual Studio
- Build the solution (this will automatically download NuGet dependencies)
**Linux (Debian)**
- Install gRPC C core and C# native extension using [How to use gRPC C#][] instructions
- Open solution `Greeter.sln` in MonoDevelop.
- Build the solution (you need to manually restore dependencies by using `mono nuget.exe restore` if you don't have NuGet add-in)
**Mac OS X**
- Install gRPC C core and C# native extension using [How to use gRPC C#][] instructions
- Open solution `Greeter.sln` with Xamarin Studio
- Build the solution (this will automatically download NuGet dependencies) - Build the solution (this will automatically download NuGet dependencies)
@ -65,7 +47,7 @@ Try it!
> GreeterClient.exe > GreeterClient.exe
``` ```
You can also run the server and client directly from Visual Studio. You can also run the server and client directly from the IDE.
On Linux or Mac, use `mono GreeterServer.exe` and `mono GreeterClient.exe` to run the server and client. On Linux or Mac, use `mono GreeterServer.exe` and `mono GreeterClient.exe` to run the server and client.
@ -76,5 +58,4 @@ You can find a more detailed tutorial in [gRPC Basics: C#][]
[homebrew]:http://brew.sh [homebrew]:http://brew.sh
[helloworld.proto]:../../protos/helloworld.proto [helloworld.proto]:../../protos/helloworld.proto
[How to use gRPC C#]:../../../src/csharp#how-to-use
[gRPC Basics: C#]:http://www.grpc.io/docs/tutorials/basic/csharp.html [gRPC Basics: C#]:http://www.grpc.io/docs/tutorials/basic/csharp.html

@ -5,6 +5,6 @@ setlocal
@rem enter this directory @rem enter this directory
cd /d %~dp0 cd /d %~dp0
packages\Google.Protobuf.3.0.0-alpha4\tools\protoc.exe -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.12.0\tools\grpc_csharp_plugin.exe packages\Google.Protobuf.3.0.0-beta2\tools\protoc.exe -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.13.0\tools\grpc_csharp_plugin.exe
endlocal endlocal

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Grpc.Tools" version="0.12.0" /> <package id="Grpc.Tools" version="0.13.0" />
</packages> </packages>

@ -9,18 +9,18 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic; using scg = global::System.Collections.Generic;
namespace Routeguide { namespace Routeguide {
namespace Proto { /// <summary>Holder for reflection information generated from route_guide.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class RouteGuide { public static partial class RouteGuideReflection {
#region Descriptor #region Descriptor
/// <summary>File descriptor for route_guide.proto</summary>
public static pbr::FileDescriptor Descriptor { public static pbr::FileDescriptor Descriptor {
get { return descriptor; } get { return descriptor; }
} }
private static pbr::FileDescriptor descriptor; private static pbr::FileDescriptor descriptor;
static RouteGuide() { static RouteGuideReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"ChFyb3V0ZV9ndWlkZS5wcm90bxIKcm91dGVndWlkZSIsCgVQb2ludBIQCghs", "ChFyb3V0ZV9ndWlkZS5wcm90bxIKcm91dGVndWlkZSIsCgVQb2ludBIQCghs",
@ -38,28 +38,33 @@ namespace Routeguide {
"dWlkZS5Qb2ludBoYLnJvdXRlZ3VpZGUuUm91dGVTdW1tYXJ5IgAoARI/CglS", "dWlkZS5Qb2ludBoYLnJvdXRlZ3VpZGUuUm91dGVTdW1tYXJ5IgAoARI/CglS",
"b3V0ZUNoYXQSFS5yb3V0ZWd1aWRlLlJvdXRlTm90ZRoVLnJvdXRlZ3VpZGUu", "b3V0ZUNoYXQSFS5yb3V0ZWd1aWRlLlJvdXRlTm90ZRoVLnJvdXRlZ3VpZGUu",
"Um91dGVOb3RlIgAoATABQg8KB2V4LmdycGOiAgNSVEdiBnByb3RvMw==")); "Um91dGVOb3RlIgAoATABQg8KB2V4LmdycGOiAgNSVEdiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
new pbr::GeneratedCodeInfo(typeof(global::Routeguide.Point), new[]{ "Latitude", "Longitude" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Routeguide.Point), global::Routeguide.Point.Parser, new[]{ "Latitude", "Longitude" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Routeguide.Rectangle), new[]{ "Lo", "Hi" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Routeguide.Rectangle), global::Routeguide.Rectangle.Parser, new[]{ "Lo", "Hi" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Routeguide.Feature), new[]{ "Name", "Location" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Routeguide.Feature), global::Routeguide.Feature.Parser, new[]{ "Name", "Location" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Routeguide.RouteNote), new[]{ "Location", "Message" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Routeguide.RouteNote), global::Routeguide.RouteNote.Parser, new[]{ "Location", "Message" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Routeguide.RouteSummary), new[]{ "PointCount", "FeatureCount", "Distance", "ElapsedTime" }, null, null, null) new pbr::GeneratedCodeInfo(typeof(global::Routeguide.RouteSummary), global::Routeguide.RouteSummary.Parser, new[]{ "PointCount", "FeatureCount", "Distance", "ElapsedTime" }, null, null, null)
})); }));
} }
#endregion #endregion
} }
}
#region Messages #region Messages
/// <summary>
/// Points are represented as latitude-longitude pairs in the E7 representation
/// (degrees multiplied by 10**7 and rounded to the nearest integer).
/// Latitudes should be in the range +/- 90 degrees and longitude should be in
/// the range +/- 180 degrees (inclusive).
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class Point : pb::IMessage<Point> { public sealed partial class Point : pb::IMessage<Point> {
private static readonly pb::MessageParser<Point> _parser = new pb::MessageParser<Point>(() => new Point()); private static readonly pb::MessageParser<Point> _parser = new pb::MessageParser<Point>(() => new Point());
public static pb::MessageParser<Point> Parser { get { return _parser; } } public static pb::MessageParser<Point> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Routeguide.Proto.RouteGuide.Descriptor.MessageTypes[0]; } get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[0]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -81,6 +86,7 @@ namespace Routeguide {
return new Point(this); return new Point(this);
} }
/// <summary>Field number for the "latitude" field.</summary>
public const int LatitudeFieldNumber = 1; public const int LatitudeFieldNumber = 1;
private int latitude_; private int latitude_;
public int Latitude { public int Latitude {
@ -90,6 +96,7 @@ namespace Routeguide {
} }
} }
/// <summary>Field number for the "longitude" field.</summary>
public const int LongitudeFieldNumber = 2; public const int LongitudeFieldNumber = 2;
private int longitude_; private int longitude_;
public int Longitude { public int Longitude {
@ -123,7 +130,7 @@ namespace Routeguide {
} }
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.Default.Format(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
@ -181,13 +188,17 @@ namespace Routeguide {
} }
/// <summary>
/// A latitude-longitude rectangle, represented as two diagonally opposite
/// points "lo" and "hi".
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class Rectangle : pb::IMessage<Rectangle> { public sealed partial class Rectangle : pb::IMessage<Rectangle> {
private static readonly pb::MessageParser<Rectangle> _parser = new pb::MessageParser<Rectangle>(() => new Rectangle()); private static readonly pb::MessageParser<Rectangle> _parser = new pb::MessageParser<Rectangle>(() => new Rectangle());
public static pb::MessageParser<Rectangle> Parser { get { return _parser; } } public static pb::MessageParser<Rectangle> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Routeguide.Proto.RouteGuide.Descriptor.MessageTypes[1]; } get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[1]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -209,8 +220,12 @@ namespace Routeguide {
return new Rectangle(this); return new Rectangle(this);
} }
/// <summary>Field number for the "lo" field.</summary>
public const int LoFieldNumber = 1; public const int LoFieldNumber = 1;
private global::Routeguide.Point lo_; private global::Routeguide.Point lo_;
/// <summary>
/// One corner of the rectangle.
/// </summary>
public global::Routeguide.Point Lo { public global::Routeguide.Point Lo {
get { return lo_; } get { return lo_; }
set { set {
@ -218,8 +233,12 @@ namespace Routeguide {
} }
} }
/// <summary>Field number for the "hi" field.</summary>
public const int HiFieldNumber = 2; public const int HiFieldNumber = 2;
private global::Routeguide.Point hi_; private global::Routeguide.Point hi_;
/// <summary>
/// The other corner of the rectangle.
/// </summary>
public global::Routeguide.Point Hi { public global::Routeguide.Point Hi {
get { return hi_; } get { return hi_; }
set { set {
@ -251,7 +270,7 @@ namespace Routeguide {
} }
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.Default.Format(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
@ -321,13 +340,18 @@ namespace Routeguide {
} }
/// <summary>
/// A feature names something at a given point.
///
/// If a feature could not be named, the name is empty.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class Feature : pb::IMessage<Feature> { public sealed partial class Feature : pb::IMessage<Feature> {
private static readonly pb::MessageParser<Feature> _parser = new pb::MessageParser<Feature>(() => new Feature()); private static readonly pb::MessageParser<Feature> _parser = new pb::MessageParser<Feature>(() => new Feature());
public static pb::MessageParser<Feature> Parser { get { return _parser; } } public static pb::MessageParser<Feature> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Routeguide.Proto.RouteGuide.Descriptor.MessageTypes[2]; } get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[2]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -349,8 +373,12 @@ namespace Routeguide {
return new Feature(this); return new Feature(this);
} }
/// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
/// <summary>
/// The name of the feature.
/// </summary>
public string Name { public string Name {
get { return name_; } get { return name_; }
set { set {
@ -358,8 +386,12 @@ namespace Routeguide {
} }
} }
/// <summary>Field number for the "location" field.</summary>
public const int LocationFieldNumber = 2; public const int LocationFieldNumber = 2;
private global::Routeguide.Point location_; private global::Routeguide.Point location_;
/// <summary>
/// The point where the feature is detected.
/// </summary>
public global::Routeguide.Point Location { public global::Routeguide.Point Location {
get { return location_; } get { return location_; }
set { set {
@ -391,7 +423,7 @@ namespace Routeguide {
} }
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.Default.Format(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
@ -455,13 +487,16 @@ namespace Routeguide {
} }
/// <summary>
/// A RouteNote is a message sent while at a given point.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class RouteNote : pb::IMessage<RouteNote> { public sealed partial class RouteNote : pb::IMessage<RouteNote> {
private static readonly pb::MessageParser<RouteNote> _parser = new pb::MessageParser<RouteNote>(() => new RouteNote()); private static readonly pb::MessageParser<RouteNote> _parser = new pb::MessageParser<RouteNote>(() => new RouteNote());
public static pb::MessageParser<RouteNote> Parser { get { return _parser; } } public static pb::MessageParser<RouteNote> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Routeguide.Proto.RouteGuide.Descriptor.MessageTypes[3]; } get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[3]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -483,8 +518,12 @@ namespace Routeguide {
return new RouteNote(this); return new RouteNote(this);
} }
/// <summary>Field number for the "location" field.</summary>
public const int LocationFieldNumber = 1; public const int LocationFieldNumber = 1;
private global::Routeguide.Point location_; private global::Routeguide.Point location_;
/// <summary>
/// The location from which the message is sent.
/// </summary>
public global::Routeguide.Point Location { public global::Routeguide.Point Location {
get { return location_; } get { return location_; }
set { set {
@ -492,8 +531,12 @@ namespace Routeguide {
} }
} }
/// <summary>Field number for the "message" field.</summary>
public const int MessageFieldNumber = 2; public const int MessageFieldNumber = 2;
private string message_ = ""; private string message_ = "";
/// <summary>
/// The message to be sent.
/// </summary>
public string Message { public string Message {
get { return message_; } get { return message_; }
set { set {
@ -525,7 +568,7 @@ namespace Routeguide {
} }
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.Default.Format(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
@ -589,13 +632,20 @@ namespace Routeguide {
} }
/// <summary>
/// A RouteSummary is received in response to a RecordRoute rpc.
///
/// It contains the number of individual points received, the number of
/// detected features, and the total distance covered as the cumulative sum of
/// the distance between each point.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class RouteSummary : pb::IMessage<RouteSummary> { public sealed partial class RouteSummary : pb::IMessage<RouteSummary> {
private static readonly pb::MessageParser<RouteSummary> _parser = new pb::MessageParser<RouteSummary>(() => new RouteSummary()); private static readonly pb::MessageParser<RouteSummary> _parser = new pb::MessageParser<RouteSummary>(() => new RouteSummary());
public static pb::MessageParser<RouteSummary> Parser { get { return _parser; } } public static pb::MessageParser<RouteSummary> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Routeguide.Proto.RouteGuide.Descriptor.MessageTypes[4]; } get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[4]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -619,8 +669,12 @@ namespace Routeguide {
return new RouteSummary(this); return new RouteSummary(this);
} }
/// <summary>Field number for the "point_count" field.</summary>
public const int PointCountFieldNumber = 1; public const int PointCountFieldNumber = 1;
private int pointCount_; private int pointCount_;
/// <summary>
/// The number of points received.
/// </summary>
public int PointCount { public int PointCount {
get { return pointCount_; } get { return pointCount_; }
set { set {
@ -628,8 +682,12 @@ namespace Routeguide {
} }
} }
/// <summary>Field number for the "feature_count" field.</summary>
public const int FeatureCountFieldNumber = 2; public const int FeatureCountFieldNumber = 2;
private int featureCount_; private int featureCount_;
/// <summary>
/// The number of known features passed while traversing the route.
/// </summary>
public int FeatureCount { public int FeatureCount {
get { return featureCount_; } get { return featureCount_; }
set { set {
@ -637,8 +695,12 @@ namespace Routeguide {
} }
} }
/// <summary>Field number for the "distance" field.</summary>
public const int DistanceFieldNumber = 3; public const int DistanceFieldNumber = 3;
private int distance_; private int distance_;
/// <summary>
/// The distance covered in metres.
/// </summary>
public int Distance { public int Distance {
get { return distance_; } get { return distance_; }
set { set {
@ -646,8 +708,12 @@ namespace Routeguide {
} }
} }
/// <summary>Field number for the "elapsed_time" field.</summary>
public const int ElapsedTimeFieldNumber = 4; public const int ElapsedTimeFieldNumber = 4;
private int elapsedTime_; private int elapsedTime_;
/// <summary>
/// The duration of the traversal in seconds.
/// </summary>
public int ElapsedTime { public int ElapsedTime {
get { return elapsedTime_; } get { return elapsedTime_; }
set { set {
@ -683,7 +749,7 @@ namespace Routeguide {
} }
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.Default.Format(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {

@ -11,7 +11,7 @@
<AssemblyName>RouteGuide</AssemblyName> <AssemblyName>RouteGuide</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>68b3dd23</NuGetPackageImportStamp> <NuGetPackageImportStamp>5b6d924a</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -31,11 +31,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf"> <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference> </Reference>
<Reference Include="Grpc.Core"> <Reference Include="Grpc.Core, Version=0.12.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Core.0.12.0\lib\net45\Grpc.Core.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Grpc.Core.0.13.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -65,17 +67,13 @@
</None> </None>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" /> <Import Project="..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets'))" /> <Error Condition="!Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
</Target> </Target>
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" />
<Import Project="..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

@ -49,7 +49,7 @@ namespace Routeguide {
// service descriptor // service descriptor
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{ {
get { return global::Routeguide.Proto.RouteGuide.Descriptor.Services[0]; } get { return global::Routeguide.RouteGuideReflection.Descriptor.Services[0]; }
} }
// client interface // client interface

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" /> <package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
<package id="Grpc" version="0.12.0" targetFramework="net45" /> <package id="Grpc" version="0.13.0" targetFramework="net45" />
<package id="Grpc.Core" version="0.12.0" targetFramework="net45" /> <package id="Grpc.Core" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.204.1" targetFramework="net45" /> <package id="grpc.native.csharp" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.10" targetFramework="net45" />
<package id="grpc.native.csharp" version="0.12.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" /> <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
</packages> </packages>

@ -11,7 +11,7 @@
<AssemblyName>RouteGuideClient</AssemblyName> <AssemblyName>RouteGuideClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>f5579f73</NuGetPackageImportStamp> <NuGetPackageImportStamp>69015b00</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -33,11 +33,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf"> <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference> </Reference>
<Reference Include="Grpc.Core"> <Reference Include="Grpc.Core, Version=0.12.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Core.0.12.0\lib\net45\Grpc.Core.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Grpc.Core.0.13.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -68,17 +70,13 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" /> <Import Project="..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets'))" /> <Error Condition="!Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
</Target> </Target>
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" />
<Import Project="..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" /> <package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
<package id="Grpc" version="0.12.0" targetFramework="net45" /> <package id="Grpc" version="0.13.0" targetFramework="net45" />
<package id="Grpc.Core" version="0.12.0" targetFramework="net45" /> <package id="Grpc.Core" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.204.1" targetFramework="net45" /> <package id="grpc.native.csharp" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.10" targetFramework="net45" />
<package id="grpc.native.csharp" version="0.12.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" /> <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
</packages> </packages>

@ -11,7 +11,7 @@
<AssemblyName>RouteGuideServer</AssemblyName> <AssemblyName>RouteGuideServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>89e15444</NuGetPackageImportStamp> <NuGetPackageImportStamp>656158d8</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -33,11 +33,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf"> <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference> </Reference>
<Reference Include="Grpc.Core"> <Reference Include="Grpc.Core, Version=0.12.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<HintPath>..\packages\Grpc.Core.0.12.0\lib\net45\Grpc.Core.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Grpc.Core.0.13.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -69,17 +71,13 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" /> <Import Project="..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.zlib.redist.targets'))" /> <Error Condition="!Exists('..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.13.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets'))" />
</Target> </Target>
<Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\portable-net45+netcore45+wpa81+wp8\grpc.dependencies.openssl.redist.targets')" />
<Import Project="..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets" Condition="Exists('..\packages\grpc.native.csharp.0.12.0\build\portable-net45+netcore45+wpa81+wp8\grpc.native.csharp.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" /> <package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
<package id="Grpc" version="0.12.0" targetFramework="net45" /> <package id="Grpc" version="0.13.0" targetFramework="net45" />
<package id="Grpc.Core" version="0.12.0" targetFramework="net45" /> <package id="Grpc.Core" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.openssl.redist" version="1.0.204.1" targetFramework="net45" /> <package id="grpc.native.csharp" version="0.13.0" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.10" targetFramework="net45" />
<package id="grpc.native.csharp" version="0.12.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" /> <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
</packages> </packages>

@ -5,6 +5,6 @@ setlocal
@rem enter this directory @rem enter this directory
cd /d %~dp0 cd /d %~dp0
packages\Google.Protobuf.3.0.0-alpha4\tools\protoc.exe -I../../protos --csharp_out RouteGuide ../../protos/route_guide.proto --grpc_out RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.12.0\tools\grpc_csharp_plugin.exe packages\Google.Protobuf.3.0.0-beta2\tools\protoc.exe -I../../protos --csharp_out RouteGuide ../../protos/route_guide.proto --grpc_out RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.13.0\tools\grpc_csharp_plugin.exe
endlocal endlocal

@ -6,24 +6,18 @@ Background
For this sample, we've already generated the server and client stubs from For this sample, we've already generated the server and client stubs from
[helloworld.proto][] and we'll be using a specific reference platform. [helloworld.proto][] and we'll be using a specific reference platform.
Prerequisites
-------------
- Debian 8.2 "Jessie" platform with `root` access
- `git`
- `python2.7`
- `pip`
- Python development headers
Set-up Install gRPC:
-------
```sh ```sh
$ # install the gRPC Core: $ pip install grpcio
$ sudo apt-get install libgrpc-dev ```
$ # install gRPC Python: Or, to install it system wide:
$ sudo pip install -U grpcio==0.11.0b1 ```sh
$ # Since this "hello, world" example uses protocol buffers: $ sudo pip install grpcio
$ sudo pip install -U protobuf==3.0.0a3 ```
Download the example
```sh
$ # Clone the repository to get the example code: $ # Clone the repository to get the example code:
$ git clone https://github.com/grpc/grpc $ git clone https://github.com/grpc/grpc
$ # Navigate to the "hello, world" Python example: $ # Navigate to the "hello, world" Python example:

@ -1,36 +0,0 @@
#!/bin/bash
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This is where you have cloned out the https://github.com/grpc/grpc repository
# And built gRPC Python.
# ADJUST THIS PATH TO WHERE YOUR ACTUAL LOCATION IS
GRPC_ROOT=~/github/grpc
$GRPC_ROOT/python2.7_virtual_environment/bin/python greeter_client.py

@ -1,37 +0,0 @@
#!/bin/bash
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This is where you have cloned out the https://github.com/grpc/grpc repository
# And built gRPC Python.
# ADJUST THIS PATH TO WHERE YOUR ACTUAL LOCATION IS
GRPC_ROOT=~/github/grpc
$GRPC_ROOT/python2.7_virtual_environment/bin/python greeter_server.py

@ -1,36 +0,0 @@
#!/bin/bash
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This is where you have cloned out the https://github.com/grpc/grpc repository
# And built gRPC Python.
# ADJUST THIS PATH TO WHERE YOUR ACTUAL LOCATION IS
GRPC_ROOT=~/github/grpc
$GRPC_ROOT/python2.7_virtual_environment/bin/python -B route_guide_client.py

@ -1,36 +0,0 @@
#!/bin/bash
# Copyright 2015, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# This is where you have cloned out the https://github.com/grpc/grpc repository
# And built gRPC Python.
# ADJUST THIS PATH TO WHERE YOUR ACTUAL LOCATION IS
GRPC_ROOT=~/github/grpc
$GRPC_ROOT/python2.7_virtual_environment/bin/python -B route_guide_server.py

@ -36,9 +36,12 @@
#ifndef GRPCXX_ALARM_H #ifndef GRPCXX_ALARM_H
#define GRPCXX_ALARM_H #define GRPCXX_ALARM_H
#include <grpc++/impl/codegen/completion_queue.h>
#include <grpc++/impl/codegen/completion_queue_tag.h> #include <grpc++/impl/codegen/completion_queue_tag.h>
#include <grpc++/impl/codegen/grpc_library.h> #include <grpc++/impl/codegen/grpc_library.h>
#include <grpc++/impl/codegen/time.h> #include <grpc++/impl/codegen/time.h>
#include <grpc++/impl/grpc_library.h>
#include <grpc/grpc.h>
struct grpc_alarm; struct grpc_alarm;
@ -54,14 +57,22 @@ class Alarm : private GrpcLibrary {
/// Once the alarm expires (at \a deadline) or it's cancelled (see \a Cancel), /// Once the alarm expires (at \a deadline) or it's cancelled (see \a Cancel),
/// an event with tag \a tag will be added to \a cq. If the alarm expired, the /// an event with tag \a tag will be added to \a cq. If the alarm expired, the
/// event's success bit will be true, false otherwise (ie, upon cancellation). /// event's success bit will be true, false otherwise (ie, upon cancellation).
Alarm(CompletionQueue* cq, gpr_timespec deadline, void* tag); /// \internal We rely on the presence of \a cq for grpc initialization. If \a
/// cq were ever to be removed, a reference to a static
/// internal::GrpcLibraryInitializer instance would need to be introduced
/// here. \endinternal.
template <typename T>
Alarm(CompletionQueue* cq, const T& deadline, void* tag)
: tag_(tag),
alarm_(grpc_alarm_create(cq->cq(), TimePoint<T>(deadline).raw_time(),
static_cast<void*>(&tag_))) {}
/// Destroy the given completion queue alarm, cancelling it in the process. /// Destroy the given completion queue alarm, cancelling it in the process.
~Alarm(); ~Alarm() { grpc_alarm_destroy(alarm_); }
/// Cancel a completion queue alarm. Calling this function over an alarm that /// Cancel a completion queue alarm. Calling this function over an alarm that
/// has already fired has no effect. /// has already fired has no effect.
void Cancel(); void Cancel() { grpc_alarm_cancel(alarm_); }
private: private:
class AlarmEntry : public CompletionQueueTag { class AlarmEntry : public CompletionQueueTag {

@ -10,7 +10,7 @@
<email>grpc-packages@google.com</email> <email>grpc-packages@google.com</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2016-02-25</date> <date>2016-02-24</date>
<time>16:06:07</time> <time>16:06:07</time>
<version> <version>
<release>0.8.0</release> <release>0.8.0</release>
@ -854,32 +854,6 @@
<file baseinstalldir="/" name="third_party/boringssl/ssl/t1_enc.c" role="src" /> <file baseinstalldir="/" name="third_party/boringssl/ssl/t1_enc.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/t1_lib.c" role="src" /> <file baseinstalldir="/" name="third_party/boringssl/ssl/t1_lib.c" role="src" />
<file baseinstalldir="/" name="third_party/boringssl/ssl/tls_record.c" role="src" /> <file baseinstalldir="/" name="third_party/boringssl/ssl/tls_record.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/crc32.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/deflate.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/gzguts.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/inffast.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/inffixed.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/inflate.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/inftrees.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/trees.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/zconf.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/zlib.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/zutil.h" role="src" />
<file baseinstalldir="/" name="third_party/zlib/adler32.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/compress.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/crc32.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/deflate.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/gzclose.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/gzlib.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/gzread.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/gzwrite.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/infback.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/inffast.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/inflate.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/inftrees.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/trees.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/uncompr.c" role="src" />
<file baseinstalldir="/" name="third_party/zlib/zutil.c" role="src" />
</dir> </dir>
</contents> </contents>
<dependencies> <dependencies>
@ -987,7 +961,7 @@ Update to wrap gRPC C Core version 0.10.0
<release>beta</release> <release>beta</release>
<api>beta</api> <api>beta</api>
</stability> </stability>
<date>2016-02-25</date> <date>2016-02-24</date>
<license>BSD</license> <license>BSD</license>
<notes> <notes>
- Simplify gRPC PHP installation #4517 - Simplify gRPC PHP installation #4517

@ -208,7 +208,6 @@ PACKAGE_DATA = {
'_credentials/roots.pem', '_credentials/roots.pem',
'_windows/grpc_c.32.python', '_windows/grpc_c.32.python',
'_windows/grpc_c.64.python', '_windows/grpc_c.64.python',
'cygrpc.so',
], ],
} }
if INSTALL_TESTS: if INSTALL_TESTS:

@ -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

@ -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,6 +39,7 @@
#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/httpcli/format_request.h" #include "src/core/httpcli/format_request.h"
#include "src/core/httpcli/parser.h" #include "src/core/httpcli/parser.h"
#include "src/core/iomgr/endpoint.h" #include "src/core/iomgr/endpoint.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

@ -59,7 +59,7 @@ static void httpcli_ssl_destroy(grpc_security_connector *sc) {
} }
static void httpcli_ssl_do_handshake(grpc_exec_ctx *exec_ctx, static void httpcli_ssl_do_handshake(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, grpc_channel_security_connector *sc,
grpc_endpoint *nonsecure_endpoint, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, grpc_security_handshake_done_cb cb,
void *user_data) { void *user_data) {
@ -78,8 +78,8 @@ static void httpcli_ssl_do_handshake(grpc_exec_ctx *exec_ctx,
tsi_result_to_string(result)); tsi_result_to_string(result));
cb(exec_ctx, user_data, GRPC_SECURITY_ERROR, NULL, NULL); cb(exec_ctx, user_data, GRPC_SECURITY_ERROR, NULL, NULL);
} else { } else {
grpc_do_security_handshake(exec_ctx, handshaker, sc, nonsecure_endpoint, cb, grpc_do_security_handshake(exec_ctx, handshaker, &sc->base, true,
user_data); nonsecure_endpoint, cb, user_data);
} }
} }
@ -103,7 +103,7 @@ static void httpcli_ssl_check_peer(grpc_exec_ctx *exec_ctx,
} }
static grpc_security_connector_vtable httpcli_ssl_vtable = { static grpc_security_connector_vtable httpcli_ssl_vtable = {
httpcli_ssl_destroy, httpcli_ssl_do_handshake, httpcli_ssl_check_peer}; httpcli_ssl_destroy, httpcli_ssl_check_peer};
static grpc_security_status httpcli_ssl_channel_security_connector_create( static grpc_security_status httpcli_ssl_channel_security_connector_create(
const unsigned char *pem_root_certs, size_t pem_root_certs_size, const unsigned char *pem_root_certs, size_t pem_root_certs_size,
@ -121,7 +121,6 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
memset(c, 0, sizeof(grpc_httpcli_ssl_channel_security_connector)); memset(c, 0, sizeof(grpc_httpcli_ssl_channel_security_connector));
gpr_ref_init(&c->base.base.refcount, 1); gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.is_client_side = 1;
c->base.base.vtable = &httpcli_ssl_vtable; c->base.base.vtable = &httpcli_ssl_vtable;
if (secure_peer_name != NULL) { if (secure_peer_name != NULL) {
c->secure_peer_name = gpr_strdup(secure_peer_name); c->secure_peer_name = gpr_strdup(secure_peer_name);
@ -136,6 +135,7 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
*sc = NULL; *sc = NULL;
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
} }
c->base.do_handshake = httpcli_ssl_do_handshake;
*sc = &c->base; *sc = &c->base;
return GRPC_SECURITY_OK; return GRPC_SECURITY_OK;
} }
@ -180,8 +180,8 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
GPR_ASSERT(httpcli_ssl_channel_security_connector_create( GPR_ASSERT(httpcli_ssl_channel_security_connector_create(
pem_root_certs, pem_root_certs_size, host, &sc) == pem_root_certs, pem_root_certs_size, host, &sc) ==
GRPC_SECURITY_OK); GRPC_SECURITY_OK);
grpc_security_connector_do_handshake(exec_ctx, &sc->base, tcp, grpc_channel_security_connector_do_handshake(
on_secure_transport_setup_done, c); exec_ctx, sc, tcp, on_secure_transport_setup_done, c);
GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "httpcli"); GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "httpcli");
} }

@ -152,13 +152,6 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *rec,
/* Return 1 if this fd is orphaned, 0 otherwise */ /* Return 1 if this fd is orphaned, 0 otherwise */
static bool fd_is_orphaned(grpc_fd *fd); static bool fd_is_orphaned(grpc_fd *fd);
/* Notification from the poller to an fd that it has become readable or
writable.
If allow_synchronous_callback is 1, allow running the fd callback inline
in this callstack, otherwise register an asynchronous callback and return */
static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd);
static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd);
/* Reference counting for fds */ /* Reference counting for fds */
/*#define GRPC_FD_REF_COUNT_DEBUG*/ /*#define GRPC_FD_REF_COUNT_DEBUG*/
#ifdef GRPC_FD_REF_COUNT_DEBUG #ifdef GRPC_FD_REF_COUNT_DEBUG
@ -205,7 +198,7 @@ struct grpc_pollset {
For example, we may choose a poll() based implementation on linux for For example, we may choose a poll() based implementation on linux for
few fds, and an epoll() based implementation for many fds */ few fds, and an epoll() based implementation for many fds */
const grpc_pollset_vtable *vtable; const grpc_pollset_vtable *vtable;
gpr_mu *mu; gpr_mu mu;
grpc_pollset_worker root_worker; grpc_pollset_worker root_worker;
int in_flight_cbs; int in_flight_cbs;
int shutting_down; int shutting_down;
@ -421,11 +414,11 @@ static bool fd_is_orphaned(grpc_fd *fd) {
} }
static void pollset_kick_locked(grpc_fd_watcher *watcher) { static void pollset_kick_locked(grpc_fd_watcher *watcher) {
gpr_mu_lock(watcher->pollset->mu); gpr_mu_lock(&watcher->pollset->mu);
GPR_ASSERT(watcher->worker); GPR_ASSERT(watcher->worker);
pollset_kick_ext(watcher->pollset, watcher->worker, pollset_kick_ext(watcher->pollset, watcher->worker,
GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP); GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
gpr_mu_unlock(watcher->pollset->mu); gpr_mu_unlock(&watcher->pollset->mu);
} }
static void maybe_wake_one_watcher_locked(grpc_fd *fd) { static void maybe_wake_one_watcher_locked(grpc_fd *fd) {
@ -550,14 +543,6 @@ static int set_ready_locked(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
} }
} }
static void set_ready(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure **st) {
/* only one set_ready can be active at once (but there may be a racing
notify_on) */
gpr_mu_lock(&fd->mu);
set_ready_locked(exec_ctx, fd, st);
gpr_mu_unlock(&fd->mu);
}
static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd) { static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
gpr_mu_lock(&fd->mu); gpr_mu_lock(&fd->mu);
GPR_ASSERT(!fd->shutdown); GPR_ASSERT(!fd->shutdown);
@ -686,14 +671,6 @@ static void fd_end_poll(grpc_exec_ctx *exec_ctx, grpc_fd_watcher *watcher,
GRPC_FD_UNREF(fd, "poll"); GRPC_FD_UNREF(fd, "poll");
} }
static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
set_ready(exec_ctx, fd, &fd->read_closure);
}
static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
set_ready(exec_ctx, fd, &fd->write_closure);
}
/******************************************************************************* /*******************************************************************************
* pollset_posix.c * pollset_posix.c
*/ */
@ -828,8 +805,9 @@ static void kick_poller(void) { grpc_wakeup_fd_wakeup(&grpc_global_wakeup_fd); }
static void become_basic_pollset(grpc_pollset *pollset, grpc_fd *fd_or_null); static void become_basic_pollset(grpc_pollset *pollset, grpc_fd *fd_or_null);
static void pollset_init(grpc_pollset *pollset, gpr_mu *mu) { static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
pollset->mu = mu; gpr_mu_init(&pollset->mu);
*mu = &pollset->mu;
pollset->root_worker.next = pollset->root_worker.prev = &pollset->root_worker; pollset->root_worker.next = pollset->root_worker.prev = &pollset->root_worker;
pollset->in_flight_cbs = 0; pollset->in_flight_cbs = 0;
pollset->shutting_down = 0; pollset->shutting_down = 0;
@ -852,6 +830,7 @@ static void pollset_destroy(grpc_pollset *pollset) {
gpr_free(pollset->local_wakeup_cache); gpr_free(pollset->local_wakeup_cache);
pollset->local_wakeup_cache = next; pollset->local_wakeup_cache = next;
} }
gpr_mu_destroy(&pollset->mu);
} }
static void pollset_reset(grpc_pollset *pollset) { static void pollset_reset(grpc_pollset *pollset) {
@ -868,15 +847,15 @@ static void pollset_reset(grpc_pollset *pollset) {
static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
grpc_fd *fd) { grpc_fd *fd) {
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
pollset->vtable->add_fd(exec_ctx, pollset, fd, 1); pollset->vtable->add_fd(exec_ctx, pollset, fd, 1);
/* the following (enabled only in debug) will reacquire and then release /* the following (enabled only in debug) will reacquire and then release
our lock - meaning that if the unlocking flag passed to add_fd above is our lock - meaning that if the unlocking flag passed to add_fd above is
not respected, the code will deadlock (in a way that we have a chance of not respected, the code will deadlock (in a way that we have a chance of
debugging) */ debugging) */
#ifndef NDEBUG #ifndef NDEBUG
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
#endif #endif
} }
@ -925,7 +904,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
/* Give do_promote priority so we don't starve it out */ /* Give do_promote priority so we don't starve it out */
if (pollset->in_flight_cbs) { if (pollset->in_flight_cbs) {
GPR_TIMER_MARK("pollset_work.in_flight_cbs", 0); GPR_TIMER_MARK("pollset_work.in_flight_cbs", 0);
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
locked = 0; locked = 0;
goto done; goto done;
} }
@ -959,7 +938,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
done: done:
if (!locked) { if (!locked) {
queued_work |= grpc_exec_ctx_flush(exec_ctx); queued_work |= grpc_exec_ctx_flush(exec_ctx);
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
locked = 1; locked = 1;
} }
/* If we're forced to re-evaluate polling (via pollset_kick with /* If we're forced to re-evaluate polling (via pollset_kick with
@ -989,19 +968,19 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
pollset_kick(pollset, NULL); pollset_kick(pollset, NULL);
} else if (!pollset->called_shutdown && pollset->in_flight_cbs == 0) { } else if (!pollset->called_shutdown && pollset->in_flight_cbs == 0) {
pollset->called_shutdown = 1; pollset->called_shutdown = 1;
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
finish_shutdown(exec_ctx, pollset); finish_shutdown(exec_ctx, pollset);
grpc_exec_ctx_flush(exec_ctx); grpc_exec_ctx_flush(exec_ctx);
/* Continuing to access pollset here is safe -- it is the caller's /* Continuing to access pollset here is safe -- it is the caller's
* responsibility to not destroy when it has outstanding calls to * responsibility to not destroy when it has outstanding calls to
* pollset_work. * pollset_work.
* TODO(dklempner): Can we refactor the shutdown logic to avoid this? */ * TODO(dklempner): Can we refactor the shutdown logic to avoid this? */
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
} else if (!grpc_closure_list_empty(pollset->idle_jobs)) { } else if (!grpc_closure_list_empty(pollset->idle_jobs)) {
grpc_exec_ctx_enqueue_list(exec_ctx, &pollset->idle_jobs, NULL); grpc_exec_ctx_enqueue_list(exec_ctx, &pollset->idle_jobs, NULL);
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
grpc_exec_ctx_flush(exec_ctx); grpc_exec_ctx_flush(exec_ctx);
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
} }
} }
*worker_hdl = NULL; *worker_hdl = NULL;
@ -1069,7 +1048,7 @@ static void basic_do_promote(grpc_exec_ctx *exec_ctx, void *args,
* 4. The pollset may be shutting down. * 4. The pollset may be shutting down.
*/ */
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
/* First we need to ensure that nobody is polling concurrently */ /* First we need to ensure that nobody is polling concurrently */
GPR_ASSERT(!pollset_has_workers(pollset)); GPR_ASSERT(!pollset_has_workers(pollset));
@ -1109,7 +1088,7 @@ static void basic_do_promote(grpc_exec_ctx *exec_ctx, void *args,
} }
} }
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
/* Matching ref in basic_pollset_add_fd */ /* Matching ref in basic_pollset_add_fd */
GRPC_FD_UNREF(fd, "basicpoll_add"); GRPC_FD_UNREF(fd, "basicpoll_add");
@ -1161,7 +1140,7 @@ static void basic_pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
exit: exit:
if (and_unlock_pollset) { if (and_unlock_pollset) {
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
} }
} }
@ -1197,14 +1176,14 @@ static void basic_pollset_maybe_work_and_unlock(grpc_exec_ctx *exec_ctx,
pfd[2].fd = fd->fd; pfd[2].fd = fd->fd;
pfd[2].revents = 0; pfd[2].revents = 0;
GRPC_FD_REF(fd, "basicpoll_begin"); GRPC_FD_REF(fd, "basicpoll_begin");
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
pfd[2].events = pfd[2].events =
(short)fd_begin_poll(fd, pollset, worker, POLLIN, POLLOUT, &fd_watcher); (short)fd_begin_poll(fd, pollset, worker, POLLIN, POLLOUT, &fd_watcher);
if (pfd[2].events != 0) { if (pfd[2].events != 0) {
nfds++; nfds++;
} }
} else { } else {
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
} }
/* TODO(vpai): Consider first doing a 0 timeout poll here to avoid /* TODO(vpai): Consider first doing a 0 timeout poll here to avoid
@ -1302,7 +1281,7 @@ static void multipoll_with_poll_pollset_add_fd(grpc_exec_ctx *exec_ctx,
GRPC_FD_REF(fd, "multipoller"); GRPC_FD_REF(fd, "multipoller");
exit: exit:
if (and_unlock_pollset) { if (and_unlock_pollset) {
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
} }
} }
@ -1354,7 +1333,7 @@ static void multipoll_with_poll_pollset_maybe_work_and_unlock(
} }
h->del_count = 0; h->del_count = 0;
h->fd_count = fd_count; h->fd_count = fd_count;
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
for (i = 2; i < pfd_count; i++) { for (i = 2; i < pfd_count; i++) {
pfds[i].events = (short)fd_begin_poll(watchers[i].fd, pollset, worker, pfds[i].events = (short)fd_begin_poll(watchers[i].fd, pollset, worker,
@ -1467,6 +1446,22 @@ static void poll_become_multipoller(grpc_exec_ctx *exec_ctx,
#include "src/core/profiling/timers.h" #include "src/core/profiling/timers.h"
#include "src/core/support/block_annotate.h" #include "src/core/support/block_annotate.h"
static void set_ready(grpc_exec_ctx *exec_ctx, grpc_fd *fd, grpc_closure **st) {
/* only one set_ready can be active at once (but there may be a racing
notify_on) */
gpr_mu_lock(&fd->mu);
set_ready_locked(exec_ctx, fd, st);
gpr_mu_unlock(&fd->mu);
}
static void fd_become_readable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
set_ready(exec_ctx, fd, &fd->read_closure);
}
static void fd_become_writable(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
set_ready(exec_ctx, fd, &fd->write_closure);
}
struct epoll_fd_list { struct epoll_fd_list {
int *epoll_fds; int *epoll_fds;
size_t count; size_t count;
@ -1567,7 +1562,7 @@ static void perform_delayed_add(grpc_exec_ctx *exec_ctx, void *arg,
finally_add_fd(exec_ctx, da->pollset, da->fd); finally_add_fd(exec_ctx, da->pollset, da->fd);
} }
gpr_mu_lock(da->pollset->mu); gpr_mu_lock(&da->pollset->mu);
da->pollset->in_flight_cbs--; da->pollset->in_flight_cbs--;
if (da->pollset->shutting_down) { if (da->pollset->shutting_down) {
/* We don't care about this pollset anymore. */ /* We don't care about this pollset anymore. */
@ -1576,7 +1571,7 @@ static void perform_delayed_add(grpc_exec_ctx *exec_ctx, void *arg,
grpc_exec_ctx_enqueue(exec_ctx, da->pollset->shutdown_done, true, NULL); grpc_exec_ctx_enqueue(exec_ctx, da->pollset->shutdown_done, true, NULL);
} }
} }
gpr_mu_unlock(da->pollset->mu); gpr_mu_unlock(&da->pollset->mu);
GRPC_FD_UNREF(da->fd, "delayed_add"); GRPC_FD_UNREF(da->fd, "delayed_add");
@ -1588,7 +1583,7 @@ static void multipoll_with_epoll_pollset_add_fd(grpc_exec_ctx *exec_ctx,
grpc_fd *fd, grpc_fd *fd,
int and_unlock_pollset) { int and_unlock_pollset) {
if (and_unlock_pollset) { if (and_unlock_pollset) {
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
finally_add_fd(exec_ctx, pollset, fd); finally_add_fd(exec_ctx, pollset, fd);
} else { } else {
delayed_add *da = gpr_malloc(sizeof(*da)); delayed_add *da = gpr_malloc(sizeof(*da));
@ -1620,7 +1615,7 @@ static void multipoll_with_epoll_pollset_maybe_work_and_unlock(
* here. * here.
*/ */
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
timeout_ms = poll_deadline_to_millis_timeout(deadline, now); timeout_ms = poll_deadline_to_millis_timeout(deadline, now);

@ -31,17 +31,6 @@
* *
*/ */
/* This file will be removed shortly: it's here to keep refactoring
* steps simple and auditable.
* It's the combination of the old files:
* - fd_posix.{h,c}
* - pollset_posix.{h,c}
* - pullset_multipoller_with_{poll,epoll}.{h,c}
* The new version will be split into:
* - ev_poll_posix.{h,c}
* - ev_epoll_posix.{h,c}
*/
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SOCKET #ifdef GPR_POSIX_SOCKET
@ -186,7 +175,7 @@ struct grpc_pollset_worker {
}; };
struct grpc_pollset { struct grpc_pollset {
gpr_mu *mu; gpr_mu mu;
grpc_pollset_worker root_worker; grpc_pollset_worker root_worker;
int in_flight_cbs; int in_flight_cbs;
int shutting_down; int shutting_down;
@ -337,11 +326,11 @@ static bool fd_is_orphaned(grpc_fd *fd) {
} }
static void pollset_kick_locked(grpc_fd_watcher *watcher) { static void pollset_kick_locked(grpc_fd_watcher *watcher) {
gpr_mu_lock(watcher->pollset->mu); gpr_mu_lock(&watcher->pollset->mu);
GPR_ASSERT(watcher->worker); GPR_ASSERT(watcher->worker);
pollset_kick_ext(watcher->pollset, watcher->worker, pollset_kick_ext(watcher->pollset, watcher->worker,
GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP); GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP);
gpr_mu_unlock(watcher->pollset->mu); gpr_mu_unlock(&watcher->pollset->mu);
} }
static void maybe_wake_one_watcher_locked(grpc_fd *fd) { static void maybe_wake_one_watcher_locked(grpc_fd *fd) {
@ -718,8 +707,9 @@ static void kick_poller(void) { grpc_wakeup_fd_wakeup(&grpc_global_wakeup_fd); }
/* main interface */ /* main interface */
static void pollset_init(grpc_pollset *pollset, gpr_mu *mu) { static void pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
pollset->mu = mu; gpr_mu_init(&pollset->mu);
*mu = &pollset->mu;
pollset->root_worker.next = pollset->root_worker.prev = &pollset->root_worker; pollset->root_worker.next = pollset->root_worker.prev = &pollset->root_worker;
pollset->in_flight_cbs = 0; pollset->in_flight_cbs = 0;
pollset->shutting_down = 0; pollset->shutting_down = 0;
@ -746,6 +736,7 @@ static void pollset_destroy(grpc_pollset *pollset) {
} }
gpr_free(pollset->fds); gpr_free(pollset->fds);
gpr_free(pollset->dels); gpr_free(pollset->dels);
gpr_mu_destroy(&pollset->mu);
} }
static void pollset_reset(grpc_pollset *pollset) { static void pollset_reset(grpc_pollset *pollset) {
@ -762,7 +753,7 @@ static void pollset_reset(grpc_pollset *pollset) {
static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
grpc_fd *fd) { grpc_fd *fd) {
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
size_t i; size_t i;
/* TODO(ctiller): this is O(num_fds^2); maybe switch to a hash set here */ /* TODO(ctiller): this is O(num_fds^2); maybe switch to a hash set here */
for (i = 0; i < pollset->fd_count; i++) { for (i = 0; i < pollset->fd_count; i++) {
@ -777,7 +768,7 @@ static void pollset_add_fd(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
pollset->fds[pollset->fd_count++] = fd; pollset->fds[pollset->fd_count++] = fd;
GRPC_FD_REF(fd, "multipoller"); GRPC_FD_REF(fd, "multipoller");
exit: exit:
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
} }
static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) { static void finish_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset) {
@ -833,7 +824,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
/* Give do_promote priority so we don't starve it out */ /* Give do_promote priority so we don't starve it out */
if (pollset->in_flight_cbs) { if (pollset->in_flight_cbs) {
GPR_TIMER_MARK("pollset_work.in_flight_cbs", 0); GPR_TIMER_MARK("pollset_work.in_flight_cbs", 0);
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
locked = 0; locked = 0;
goto done; goto done;
} }
@ -895,7 +886,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
} }
pollset->del_count = 0; pollset->del_count = 0;
pollset->fd_count = fd_count; pollset->fd_count = fd_count;
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
for (i = 2; i < pfd_count; i++) { for (i = 2; i < pfd_count; i++) {
pfds[i].events = (short)fd_begin_poll(watchers[i].fd, pollset, &worker, pfds[i].events = (short)fd_begin_poll(watchers[i].fd, pollset, &worker,
@ -952,7 +943,7 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
done: done:
if (!locked) { if (!locked) {
queued_work |= grpc_exec_ctx_flush(exec_ctx); queued_work |= grpc_exec_ctx_flush(exec_ctx);
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
locked = 1; locked = 1;
} }
/* If we're forced to re-evaluate polling (via pollset_kick with /* If we're forced to re-evaluate polling (via pollset_kick with
@ -982,19 +973,19 @@ static void pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
pollset_kick(pollset, NULL); pollset_kick(pollset, NULL);
} else if (!pollset->called_shutdown && pollset->in_flight_cbs == 0) { } else if (!pollset->called_shutdown && pollset->in_flight_cbs == 0) {
pollset->called_shutdown = 1; pollset->called_shutdown = 1;
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
finish_shutdown(exec_ctx, pollset); finish_shutdown(exec_ctx, pollset);
grpc_exec_ctx_flush(exec_ctx); grpc_exec_ctx_flush(exec_ctx);
/* Continuing to access pollset here is safe -- it is the caller's /* Continuing to access pollset here is safe -- it is the caller's
* responsibility to not destroy when it has outstanding calls to * responsibility to not destroy when it has outstanding calls to
* pollset_work. * pollset_work.
* TODO(dklempner): Can we refactor the shutdown logic to avoid this? */ * TODO(dklempner): Can we refactor the shutdown logic to avoid this? */
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
} else if (!grpc_closure_list_empty(pollset->idle_jobs)) { } else if (!grpc_closure_list_empty(pollset->idle_jobs)) {
grpc_exec_ctx_enqueue_list(exec_ctx, &pollset->idle_jobs, NULL); grpc_exec_ctx_enqueue_list(exec_ctx, &pollset->idle_jobs, NULL);
gpr_mu_unlock(pollset->mu); gpr_mu_unlock(&pollset->mu);
grpc_exec_ctx_flush(exec_ctx); grpc_exec_ctx_flush(exec_ctx);
gpr_mu_lock(pollset->mu); gpr_mu_lock(&pollset->mu);
} }
} }
*worker_hdl = NULL; *worker_hdl = NULL;

@ -163,7 +163,7 @@ void grpc_fd_notify_on_write(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
size_t grpc_pollset_size(void) { return g_event_engine->pollset_size; } size_t grpc_pollset_size(void) { return g_event_engine->pollset_size; }
void grpc_pollset_init(grpc_pollset *pollset, gpr_mu *mu) { void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
g_event_engine->pollset_init(pollset, mu); g_event_engine->pollset_init(pollset, mu);
} }

@ -56,7 +56,7 @@ typedef struct grpc_event_engine_vtable {
void (*fd_notify_on_write)(grpc_exec_ctx *exec_ctx, grpc_fd *fd, void (*fd_notify_on_write)(grpc_exec_ctx *exec_ctx, grpc_fd *fd,
grpc_closure *closure); grpc_closure *closure);
void (*pollset_init)(grpc_pollset *pollset, gpr_mu *mu); void (*pollset_init)(grpc_pollset *pollset, gpr_mu **mu);
void (*pollset_shutdown)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, void (*pollset_shutdown)(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,
grpc_closure *closure); grpc_closure *closure);
void (*pollset_reset)(grpc_pollset *pollset); void (*pollset_reset)(grpc_pollset *pollset);

@ -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

@ -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

@ -53,7 +53,7 @@ typedef struct grpc_pollset grpc_pollset;
typedef struct grpc_pollset_worker grpc_pollset_worker; typedef struct grpc_pollset_worker grpc_pollset_worker;
size_t grpc_pollset_size(void); size_t grpc_pollset_size(void);
void grpc_pollset_init(grpc_pollset *pollset, gpr_mu *mu); void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu);
/* Begin shutting down the pollset, and call closure when done. /* Begin shutting down the pollset, and call closure when done.
* GRPC_POLLSET_MU(pollset) must be held */ * GRPC_POLLSET_MU(pollset) must be held */
void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset,

@ -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

@ -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

@ -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

@ -89,12 +89,15 @@ static void push_front_worker(grpc_pollset_worker *root,
worker->links[type].next->links[type].prev = worker; worker->links[type].next->links[type].prev = worker;
} }
size_t grpc_pollset_size(void) { return sizeof(grpc_pollset); }
/* There isn't really any such thing as a pollset under Windows, due to the /* There isn't really any such thing as a pollset under Windows, due to the
nature of the IO completion ports. We're still going to provide a minimal nature of the IO completion ports. We're still going to provide a minimal
set of features for the sake of the rest of grpc. But grpc_pollset_work set of features for the sake of the rest of grpc. But grpc_pollset_work
won't actually do any polling, and return as quickly as possible. */ won't actually do any polling, and return as quickly as possible. */
void grpc_pollset_init(grpc_pollset *pollset) { void grpc_pollset_init(grpc_pollset *pollset, gpr_mu **mu) {
*mu = &grpc_polling_mu;
memset(pollset, 0, sizeof(*pollset)); memset(pollset, 0, sizeof(*pollset));
pollset->root_worker.links[GRPC_POLLSET_WORKER_LINK_POLLSET].next = pollset->root_worker.links[GRPC_POLLSET_WORKER_LINK_POLLSET].next =
pollset->root_worker.links[GRPC_POLLSET_WORKER_LINK_POLLSET].prev = pollset->root_worker.links[GRPC_POLLSET_WORKER_LINK_POLLSET].prev =

@ -72,6 +72,4 @@ struct grpc_pollset {
grpc_closure *on_shutdown; grpc_closure *on_shutdown;
}; };
extern gpr_mu grpc_polling_mu;
#endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */ #endif /* GRPC_INTERNAL_CORE_IOMGR_POLLSET_WINDOWS_H */

@ -56,7 +56,6 @@
#include <unistd.h> #include <unistd.h>
#include "src/core/iomgr/ev_posix.h" #include "src/core/iomgr/ev_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"

@ -310,7 +310,6 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(auth_context != NULL); GPR_ASSERT(auth_context != NULL);
/* initialize members */ /* initialize members */
GPR_ASSERT(sc->is_client_side);
chand->security_connector = chand->security_connector =
(grpc_channel_security_connector *)GRPC_SECURITY_CONNECTOR_REF( (grpc_channel_security_connector *)GRPC_SECURITY_CONNECTOR_REF(
sc, "client_auth_filter"); sc, "client_auth_filter");

@ -166,7 +166,7 @@ void grpc_server_credentials_release(grpc_server_credentials *creds) {
} }
grpc_security_status grpc_server_credentials_create_security_connector( grpc_security_status grpc_server_credentials_create_security_connector(
grpc_server_credentials *creds, grpc_security_connector **sc) { grpc_server_credentials *creds, grpc_server_security_connector **sc) {
if (creds == NULL || creds->vtable->create_security_connector == NULL) { if (creds == NULL || creds->vtable->create_security_connector == NULL) {
gpr_log(GPR_ERROR, "Server credentials cannot create security context."); gpr_log(GPR_ERROR, "Server credentials cannot create security context.");
return GRPC_SECURITY_ERROR; return GRPC_SECURITY_ERROR;
@ -298,7 +298,7 @@ static grpc_security_status ssl_create_security_connector(
} }
static grpc_security_status ssl_server_create_security_connector( static grpc_security_status ssl_server_create_security_connector(
grpc_server_credentials *creds, grpc_security_connector **sc) { grpc_server_credentials *creds, grpc_server_security_connector **sc) {
grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)creds; grpc_ssl_server_credentials *c = (grpc_ssl_server_credentials *)creds;
return grpc_ssl_server_security_connector_create(&c->config, sc); return grpc_ssl_server_security_connector_create(&c->config, sc);
} }
@ -894,7 +894,7 @@ static grpc_security_status fake_transport_security_create_security_connector(
static grpc_security_status static grpc_security_status
fake_transport_security_server_create_security_connector( fake_transport_security_server_create_security_connector(
grpc_server_credentials *c, grpc_security_connector **sc) { grpc_server_credentials *c, grpc_server_security_connector **sc) {
*sc = grpc_fake_server_security_connector_create(); *sc = grpc_fake_server_security_connector_create();
return GRPC_SECURITY_OK; return GRPC_SECURITY_OK;
} }

@ -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
@ -234,7 +234,7 @@ grpc_refresh_token_credentials_create_from_auth_refresh_token(
typedef struct { typedef struct {
void (*destruct)(grpc_server_credentials *c); void (*destruct)(grpc_server_credentials *c);
grpc_security_status (*create_security_connector)( grpc_security_status (*create_security_connector)(
grpc_server_credentials *c, grpc_security_connector **sc); grpc_server_credentials *c, grpc_server_security_connector **sc);
} grpc_server_credentials_vtable; } grpc_server_credentials_vtable;
struct grpc_server_credentials { struct grpc_server_credentials {
@ -245,7 +245,7 @@ struct grpc_server_credentials {
}; };
grpc_security_status grpc_server_credentials_create_security_connector( grpc_security_status grpc_server_credentials_create_security_connector(
grpc_server_credentials *creds, grpc_security_connector **sc); grpc_server_credentials *creds, grpc_server_security_connector **sc);
grpc_server_credentials *grpc_server_credentials_ref( grpc_server_credentials *grpc_server_credentials_ref(
grpc_server_credentials *creds); grpc_server_credentials *creds);

@ -52,10 +52,11 @@
static grpc_channel_credentials *default_credentials = NULL; static grpc_channel_credentials *default_credentials = NULL;
static int compute_engine_detection_done = 0; static int compute_engine_detection_done = 0;
static gpr_mu g_mu; static gpr_mu g_state_mu;
static gpr_mu *g_polling_mu;
static gpr_once g_once = GPR_ONCE_INIT; static gpr_once g_once = GPR_ONCE_INIT;
static void init_default_credentials(void) { gpr_mu_init(&g_mu); } static void init_default_credentials(void) { gpr_mu_init(&g_state_mu); }
typedef struct { typedef struct {
grpc_pollset *pollset; grpc_pollset *pollset;
@ -80,10 +81,10 @@ static void on_compute_engine_detection_http_response(
} }
} }
} }
gpr_mu_lock(&g_mu); gpr_mu_lock(g_polling_mu);
detector->is_done = 1; detector->is_done = 1;
grpc_pollset_kick(detector->pollset, NULL); grpc_pollset_kick(detector->pollset, NULL);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_polling_mu);
} }
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, bool s) { static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, bool s) {
@ -102,7 +103,7 @@ static int is_stack_running_on_compute_engine(void) {
gpr_timespec max_detection_delay = gpr_time_from_seconds(1, GPR_TIMESPAN); gpr_timespec max_detection_delay = gpr_time_from_seconds(1, GPR_TIMESPAN);
detector.pollset = gpr_malloc(grpc_pollset_size()); detector.pollset = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(detector.pollset, &g_mu); grpc_pollset_init(detector.pollset, &g_polling_mu);
detector.is_done = 0; detector.is_done = 0;
detector.success = 0; detector.success = 0;
@ -121,19 +122,20 @@ static int is_stack_running_on_compute_engine(void) {
/* Block until we get the response. This is not ideal but this should only be /* Block until we get the response. This is not ideal but this should only be
called once for the lifetime of the process by the default credentials. */ called once for the lifetime of the process by the default credentials. */
gpr_mu_lock(&g_mu); gpr_mu_lock(g_polling_mu);
while (!detector.is_done) { while (!detector.is_done) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, detector.pollset, &worker, grpc_pollset_work(&exec_ctx, detector.pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC)); gpr_inf_future(GPR_CLOCK_MONOTONIC));
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_polling_mu);
grpc_httpcli_context_destroy(&context); grpc_httpcli_context_destroy(&context);
grpc_closure_init(&destroy_closure, destroy_pollset, &detector.pollset); grpc_closure_init(&destroy_closure, destroy_pollset, detector.pollset);
grpc_pollset_shutdown(&exec_ctx, detector.pollset, &destroy_closure); grpc_pollset_shutdown(&exec_ctx, detector.pollset, &destroy_closure);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
g_polling_mu = NULL;
gpr_free(detector.pollset); gpr_free(detector.pollset);
@ -187,7 +189,7 @@ grpc_channel_credentials *grpc_google_default_credentials_create(void) {
gpr_once_init(&g_once, init_default_credentials); gpr_once_init(&g_once, init_default_credentials);
gpr_mu_lock(&g_mu); gpr_mu_lock(&g_state_mu);
if (default_credentials != NULL) { if (default_credentials != NULL) {
result = grpc_channel_credentials_ref(default_credentials); result = grpc_channel_credentials_ref(default_credentials);
@ -233,19 +235,19 @@ end:
gpr_log(GPR_ERROR, "Could not create google default credentials."); gpr_log(GPR_ERROR, "Could not create google default credentials.");
} }
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_state_mu);
return result; return result;
} }
void grpc_flush_cached_google_default_credentials(void) { void grpc_flush_cached_google_default_credentials(void) {
gpr_once_init(&g_once, init_default_credentials); gpr_once_init(&g_once, init_default_credentials);
gpr_mu_lock(&g_mu); gpr_mu_lock(&g_state_mu);
if (default_credentials != NULL) { if (default_credentials != NULL) {
grpc_channel_credentials_unref(default_credentials); grpc_channel_credentials_unref(default_credentials);
default_credentials = NULL; default_credentials = NULL;
} }
compute_engine_detection_done = 0; compute_engine_detection_done = 0;
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_state_mu);
} }
/* -- Well known credentials path. -- */ /* -- Well known credentials path. -- */

@ -33,6 +33,7 @@
#include "src/core/security/handshake.h" #include "src/core/security/handshake.h"
#include <stdbool.h>
#include <string.h> #include <string.h>
#include "src/core/security/security_context.h" #include "src/core/security/security_context.h"
@ -46,6 +47,7 @@
typedef struct { typedef struct {
grpc_security_connector *connector; grpc_security_connector *connector;
tsi_handshaker *handshaker; tsi_handshaker *handshaker;
bool is_client_side;
unsigned char *handshake_buffer; unsigned char *handshake_buffer;
size_t handshake_buffer_size; size_t handshake_buffer_size;
grpc_endpoint *wrapped_endpoint; grpc_endpoint *wrapped_endpoint;
@ -67,9 +69,11 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx, void *setup,
bool success); bool success);
static void security_connector_remove_handshake(grpc_security_handshake *h) { static void security_connector_remove_handshake(grpc_security_handshake *h) {
GPR_ASSERT(!h->is_client_side);
grpc_security_connector_handshake_list *node; grpc_security_connector_handshake_list *node;
grpc_security_connector_handshake_list *tmp; grpc_security_connector_handshake_list *tmp;
grpc_security_connector *sc = h->connector; grpc_server_security_connector *sc =
(grpc_server_security_connector *)h->connector;
gpr_mu_lock(&sc->mu); gpr_mu_lock(&sc->mu);
node = sc->handshaking_handshakes; node = sc->handshaking_handshakes;
if (node && node->handshake == h) { if (node && node->handshake == h) {
@ -94,7 +98,7 @@ static void security_connector_remove_handshake(grpc_security_handshake *h) {
static void security_handshake_done(grpc_exec_ctx *exec_ctx, static void security_handshake_done(grpc_exec_ctx *exec_ctx,
grpc_security_handshake *h, grpc_security_handshake *h,
int is_success) { int is_success) {
if (!h->connector->is_client_side) { if (!h->is_client_side) {
security_connector_remove_handshake(h); security_connector_remove_handshake(h);
} }
if (is_success) { if (is_success) {
@ -290,6 +294,7 @@ static void on_handshake_data_sent_to_peer(grpc_exec_ctx *exec_ctx,
void grpc_do_security_handshake(grpc_exec_ctx *exec_ctx, void grpc_do_security_handshake(grpc_exec_ctx *exec_ctx,
tsi_handshaker *handshaker, tsi_handshaker *handshaker,
grpc_security_connector *connector, grpc_security_connector *connector,
bool is_client_side,
grpc_endpoint *nonsecure_endpoint, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, grpc_security_handshake_done_cb cb,
void *user_data) { void *user_data) {
@ -298,6 +303,7 @@ void grpc_do_security_handshake(grpc_exec_ctx *exec_ctx,
memset(h, 0, sizeof(grpc_security_handshake)); memset(h, 0, sizeof(grpc_security_handshake));
h->handshaker = handshaker; h->handshaker = handshaker;
h->connector = GRPC_SECURITY_CONNECTOR_REF(connector, "handshake"); h->connector = GRPC_SECURITY_CONNECTOR_REF(connector, "handshake");
h->is_client_side = is_client_side;
h->handshake_buffer_size = GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE; h->handshake_buffer_size = GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE;
h->handshake_buffer = gpr_malloc(h->handshake_buffer_size); h->handshake_buffer = gpr_malloc(h->handshake_buffer_size);
h->wrapped_endpoint = nonsecure_endpoint; h->wrapped_endpoint = nonsecure_endpoint;
@ -310,13 +316,15 @@ void grpc_do_security_handshake(grpc_exec_ctx *exec_ctx,
gpr_slice_buffer_init(&h->left_overs); gpr_slice_buffer_init(&h->left_overs);
gpr_slice_buffer_init(&h->outgoing); gpr_slice_buffer_init(&h->outgoing);
gpr_slice_buffer_init(&h->incoming); gpr_slice_buffer_init(&h->incoming);
if (!connector->is_client_side) { if (!is_client_side) {
grpc_server_security_connector *server_connector =
(grpc_server_security_connector *)connector;
handshake_node = gpr_malloc(sizeof(grpc_security_connector_handshake_list)); handshake_node = gpr_malloc(sizeof(grpc_security_connector_handshake_list));
handshake_node->handshake = h; handshake_node->handshake = h;
gpr_mu_lock(&connector->mu); gpr_mu_lock(&server_connector->mu);
handshake_node->next = connector->handshaking_handshakes; handshake_node->next = server_connector->handshaking_handshakes;
connector->handshaking_handshakes = handshake_node; server_connector->handshaking_handshakes = handshake_node;
gpr_mu_unlock(&connector->mu); gpr_mu_unlock(&server_connector->mu);
} }
send_handshake_bytes_to_peer(exec_ctx, h); send_handshake_bytes_to_peer(exec_ctx, 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
@ -41,6 +41,7 @@
void grpc_do_security_handshake(grpc_exec_ctx *exec_ctx, void grpc_do_security_handshake(grpc_exec_ctx *exec_ctx,
tsi_handshaker *handshaker, tsi_handshaker *handshaker,
grpc_security_connector *connector, grpc_security_connector *connector,
bool is_client_side,
grpc_endpoint *nonsecure_endpoint, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, grpc_security_handshake_done_cb cb,
void *user_data); void *user_data);

@ -33,6 +33,7 @@
#include "src/core/security/security_connector.h" #include "src/core/security/security_connector.h"
#include <stdbool.h>
#include <string.h> #include <string.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
@ -110,10 +111,9 @@ const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer,
return NULL; return NULL;
} }
void grpc_security_connector_shutdown(grpc_exec_ctx *exec_ctx, void grpc_server_security_connector_shutdown(
grpc_security_connector *connector) { grpc_exec_ctx *exec_ctx, grpc_server_security_connector *connector) {
grpc_security_connector_handshake_list *tmp; grpc_security_connector_handshake_list *tmp;
if (!connector->is_client_side) {
gpr_mu_lock(&connector->mu); gpr_mu_lock(&connector->mu);
while (connector->handshaking_handshakes) { while (connector->handshaking_handshakes) {
tmp = connector->handshaking_handshakes; tmp = connector->handshaking_handshakes;
@ -123,18 +123,27 @@ void grpc_security_connector_shutdown(grpc_exec_ctx *exec_ctx,
gpr_free(tmp); gpr_free(tmp);
} }
gpr_mu_unlock(&connector->mu); gpr_mu_unlock(&connector->mu);
}
} }
void grpc_security_connector_do_handshake(grpc_exec_ctx *exec_ctx, void grpc_channel_security_connector_do_handshake(
grpc_security_connector *sc, grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
grpc_endpoint *nonsecure_endpoint, grpc_endpoint *nonsecure_endpoint, grpc_security_handshake_done_cb cb,
grpc_security_handshake_done_cb cb,
void *user_data) { void *user_data) {
if (sc == NULL || nonsecure_endpoint == NULL) { if (sc == NULL || nonsecure_endpoint == NULL) {
cb(exec_ctx, user_data, GRPC_SECURITY_ERROR, NULL, NULL); cb(exec_ctx, user_data, GRPC_SECURITY_ERROR, NULL, NULL);
} else { } else {
sc->vtable->do_handshake(exec_ctx, sc, nonsecure_endpoint, cb, user_data); sc->do_handshake(exec_ctx, sc, nonsecure_endpoint, cb, user_data);
}
}
void grpc_server_security_connector_do_handshake(
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
grpc_tcp_server_acceptor *acceptor, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, void *user_data) {
if (sc == NULL || nonsecure_endpoint == NULL) {
cb(exec_ctx, user_data, GRPC_SECURITY_ERROR, NULL, NULL);
} else {
sc->do_handshake(exec_ctx, sc, acceptor, nonsecure_endpoint, cb, user_data);
} }
} }
@ -248,7 +257,8 @@ static void fake_channel_destroy(grpc_security_connector *sc) {
} }
static void fake_server_destroy(grpc_security_connector *sc) { static void fake_server_destroy(grpc_security_connector *sc) {
gpr_mu_destroy(&sc->mu); grpc_server_security_connector *c = (grpc_server_security_connector *)sc;
gpr_mu_destroy(&c->mu);
gpr_free(sc); gpr_free(sc);
} }
@ -298,49 +308,52 @@ static void fake_channel_check_call_host(grpc_exec_ctx *exec_ctx,
} }
static void fake_channel_do_handshake(grpc_exec_ctx *exec_ctx, static void fake_channel_do_handshake(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, grpc_channel_security_connector *sc,
grpc_endpoint *nonsecure_endpoint, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, grpc_security_handshake_done_cb cb,
void *user_data) { void *user_data) {
grpc_do_security_handshake(exec_ctx, tsi_create_fake_handshaker(1), sc, grpc_do_security_handshake(exec_ctx, tsi_create_fake_handshaker(1), &sc->base,
nonsecure_endpoint, cb, user_data); true, nonsecure_endpoint, cb, user_data);
} }
static void fake_server_do_handshake(grpc_exec_ctx *exec_ctx, static void fake_server_do_handshake(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, grpc_server_security_connector *sc,
grpc_tcp_server_acceptor *acceptor,
grpc_endpoint *nonsecure_endpoint, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, grpc_security_handshake_done_cb cb,
void *user_data) { void *user_data) {
grpc_do_security_handshake(exec_ctx, tsi_create_fake_handshaker(0), sc, grpc_do_security_handshake(exec_ctx, tsi_create_fake_handshaker(0), &sc->base,
nonsecure_endpoint, cb, user_data); false, nonsecure_endpoint, cb, user_data);
} }
static grpc_security_connector_vtable fake_channel_vtable = { static grpc_security_connector_vtable fake_channel_vtable = {
fake_channel_destroy, fake_channel_do_handshake, fake_check_peer}; fake_channel_destroy, fake_check_peer};
static grpc_security_connector_vtable fake_server_vtable = { static grpc_security_connector_vtable fake_server_vtable = {fake_server_destroy,
fake_server_destroy, fake_server_do_handshake, fake_check_peer}; fake_check_peer};
grpc_channel_security_connector *grpc_fake_channel_security_connector_create( grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
grpc_call_credentials *request_metadata_creds) { grpc_call_credentials *request_metadata_creds) {
grpc_channel_security_connector *c = gpr_malloc(sizeof(*c)); grpc_channel_security_connector *c = gpr_malloc(sizeof(*c));
memset(c, 0, sizeof(*c)); memset(c, 0, sizeof(*c));
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.refcount, 1);
c->base.is_client_side = 1;
c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME; c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
c->base.vtable = &fake_channel_vtable; c->base.vtable = &fake_channel_vtable;
c->request_metadata_creds = grpc_call_credentials_ref(request_metadata_creds); c->request_metadata_creds = grpc_call_credentials_ref(request_metadata_creds);
c->check_call_host = fake_channel_check_call_host; c->check_call_host = fake_channel_check_call_host;
c->do_handshake = fake_channel_do_handshake;
return c; return c;
} }
grpc_security_connector *grpc_fake_server_security_connector_create(void) { grpc_server_security_connector *grpc_fake_server_security_connector_create(
grpc_security_connector *c = gpr_malloc(sizeof(grpc_security_connector)); void) {
memset(c, 0, sizeof(grpc_security_connector)); grpc_server_security_connector *c =
gpr_ref_init(&c->refcount, 1); gpr_malloc(sizeof(grpc_server_security_connector));
c->is_client_side = 0; memset(c, 0, sizeof(*c));
c->vtable = &fake_server_vtable; gpr_ref_init(&c->base.refcount, 1);
c->url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME; c->base.vtable = &fake_server_vtable;
c->base.url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME;
c->do_handshake = fake_server_do_handshake;
gpr_mu_init(&c->mu); gpr_mu_init(&c->mu);
return c; return c;
} }
@ -355,7 +368,7 @@ typedef struct {
} grpc_ssl_channel_security_connector; } grpc_ssl_channel_security_connector;
typedef struct { typedef struct {
grpc_security_connector base; grpc_server_security_connector base;
tsi_ssl_handshaker_factory *handshaker_factory; tsi_ssl_handshaker_factory *handshaker_factory;
} grpc_ssl_server_security_connector; } grpc_ssl_server_security_connector;
@ -378,12 +391,12 @@ static void ssl_server_destroy(grpc_security_connector *sc) {
if (c->handshaker_factory != NULL) { if (c->handshaker_factory != NULL) {
tsi_ssl_handshaker_factory_destroy(c->handshaker_factory); tsi_ssl_handshaker_factory_destroy(c->handshaker_factory);
} }
gpr_mu_destroy(&sc->mu); gpr_mu_destroy(&c->base.mu);
gpr_free(sc); gpr_free(sc);
} }
static grpc_security_status ssl_create_handshaker( static grpc_security_status ssl_create_handshaker(
tsi_ssl_handshaker_factory *handshaker_factory, int is_client, tsi_ssl_handshaker_factory *handshaker_factory, bool is_client,
const char *peer_name, tsi_handshaker **handshaker) { const char *peer_name, tsi_handshaker **handshaker) {
tsi_result result = TSI_OK; tsi_result result = TSI_OK;
if (handshaker_factory == NULL) return GRPC_SECURITY_ERROR; if (handshaker_factory == NULL) return GRPC_SECURITY_ERROR;
@ -398,7 +411,7 @@ static grpc_security_status ssl_create_handshaker(
} }
static void ssl_channel_do_handshake(grpc_exec_ctx *exec_ctx, static void ssl_channel_do_handshake(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, grpc_channel_security_connector *sc,
grpc_endpoint *nonsecure_endpoint, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, grpc_security_handshake_done_cb cb,
void *user_data) { void *user_data) {
@ -406,20 +419,21 @@ static void ssl_channel_do_handshake(grpc_exec_ctx *exec_ctx,
(grpc_ssl_channel_security_connector *)sc; (grpc_ssl_channel_security_connector *)sc;
tsi_handshaker *handshaker; tsi_handshaker *handshaker;
grpc_security_status status = ssl_create_handshaker( grpc_security_status status = ssl_create_handshaker(
c->handshaker_factory, 1, c->handshaker_factory, true,
c->overridden_target_name != NULL ? c->overridden_target_name c->overridden_target_name != NULL ? c->overridden_target_name
: c->target_name, : c->target_name,
&handshaker); &handshaker);
if (status != GRPC_SECURITY_OK) { if (status != GRPC_SECURITY_OK) {
cb(exec_ctx, user_data, status, NULL, NULL); cb(exec_ctx, user_data, status, NULL, NULL);
} else { } else {
grpc_do_security_handshake(exec_ctx, handshaker, sc, nonsecure_endpoint, cb, grpc_do_security_handshake(exec_ctx, handshaker, &sc->base, true,
user_data); nonsecure_endpoint, cb, user_data);
} }
} }
static void ssl_server_do_handshake(grpc_exec_ctx *exec_ctx, static void ssl_server_do_handshake(grpc_exec_ctx *exec_ctx,
grpc_security_connector *sc, grpc_server_security_connector *sc,
grpc_tcp_server_acceptor *acceptor,
grpc_endpoint *nonsecure_endpoint, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, grpc_security_handshake_done_cb cb,
void *user_data) { void *user_data) {
@ -427,12 +441,12 @@ static void ssl_server_do_handshake(grpc_exec_ctx *exec_ctx,
(grpc_ssl_server_security_connector *)sc; (grpc_ssl_server_security_connector *)sc;
tsi_handshaker *handshaker; tsi_handshaker *handshaker;
grpc_security_status status = grpc_security_status status =
ssl_create_handshaker(c->handshaker_factory, 0, NULL, &handshaker); ssl_create_handshaker(c->handshaker_factory, false, NULL, &handshaker);
if (status != GRPC_SECURITY_OK) { if (status != GRPC_SECURITY_OK) {
cb(exec_ctx, user_data, status, NULL, NULL); cb(exec_ctx, user_data, status, NULL, NULL);
} else { } else {
grpc_do_security_handshake(exec_ctx, handshaker, sc, nonsecure_endpoint, cb, grpc_do_security_handshake(exec_ctx, handshaker, &sc->base, false,
user_data); nonsecure_endpoint, cb, user_data);
} }
} }
@ -603,10 +617,10 @@ static void ssl_channel_check_call_host(grpc_exec_ctx *exec_ctx,
} }
static grpc_security_connector_vtable ssl_channel_vtable = { static grpc_security_connector_vtable ssl_channel_vtable = {
ssl_channel_destroy, ssl_channel_do_handshake, ssl_channel_check_peer}; ssl_channel_destroy, ssl_channel_check_peer};
static grpc_security_connector_vtable ssl_server_vtable = { static grpc_security_connector_vtable ssl_server_vtable = {
ssl_server_destroy, ssl_server_do_handshake, ssl_server_check_peer}; ssl_server_destroy, ssl_server_check_peer};
static gpr_slice compute_default_pem_root_certs_once(void) { static gpr_slice compute_default_pem_root_certs_once(void) {
gpr_slice result = gpr_empty_slice(); gpr_slice result = gpr_empty_slice();
@ -700,11 +714,11 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
gpr_ref_init(&c->base.base.refcount, 1); gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.vtable = &ssl_channel_vtable; c->base.base.vtable = &ssl_channel_vtable;
c->base.base.is_client_side = 1;
c->base.base.url_scheme = GRPC_SSL_URL_SCHEME; c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;
c->base.request_metadata_creds = c->base.request_metadata_creds =
grpc_call_credentials_ref(request_metadata_creds); grpc_call_credentials_ref(request_metadata_creds);
c->base.check_call_host = ssl_channel_check_call_host; c->base.check_call_host = ssl_channel_check_call_host;
c->base.do_handshake = ssl_channel_do_handshake;
gpr_split_host_port(target_name, &c->target_name, &port); gpr_split_host_port(target_name, &c->target_name, &port);
gpr_free(port); gpr_free(port);
if (overridden_target_name != NULL) { if (overridden_target_name != NULL) {
@ -735,7 +749,7 @@ error:
} }
grpc_security_status grpc_ssl_server_security_connector_create( grpc_security_status grpc_ssl_server_security_connector_create(
const grpc_ssl_server_config *config, grpc_security_connector **sc) { const grpc_ssl_server_config *config, grpc_server_security_connector **sc) {
size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions(); size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions();
const unsigned char **alpn_protocol_strings = const unsigned char **alpn_protocol_strings =
gpr_malloc(sizeof(const char *) * num_alpn_protocols); gpr_malloc(sizeof(const char *) * num_alpn_protocols);
@ -759,9 +773,9 @@ grpc_security_status grpc_ssl_server_security_connector_create(
c = gpr_malloc(sizeof(grpc_ssl_server_security_connector)); c = gpr_malloc(sizeof(grpc_ssl_server_security_connector));
memset(c, 0, sizeof(grpc_ssl_server_security_connector)); memset(c, 0, sizeof(grpc_ssl_server_security_connector));
gpr_ref_init(&c->base.refcount, 1); gpr_ref_init(&c->base.base.refcount, 1);
c->base.url_scheme = GRPC_SSL_URL_SCHEME; c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;
c->base.vtable = &ssl_server_vtable; c->base.base.vtable = &ssl_server_vtable;
result = tsi_create_ssl_server_handshaker_factory( result = tsi_create_ssl_server_handshaker_factory(
(const unsigned char **)config->pem_private_keys, (const unsigned char **)config->pem_private_keys,
config->pem_private_keys_sizes, config->pem_private_keys_sizes,
@ -774,11 +788,12 @@ grpc_security_status grpc_ssl_server_security_connector_create(
if (result != TSI_OK) { if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
tsi_result_to_string(result)); tsi_result_to_string(result));
ssl_server_destroy(&c->base); ssl_server_destroy(&c->base.base);
*sc = NULL; *sc = NULL;
goto error; goto error;
} }
gpr_mu_init(&c->base.mu); gpr_mu_init(&c->base.mu);
c->base.do_handshake = ssl_server_do_handshake;
*sc = &c->base; *sc = &c->base;
gpr_free((void *)alpn_protocol_strings); gpr_free((void *)alpn_protocol_strings);
gpr_free(alpn_protocol_string_lengths); gpr_free(alpn_protocol_string_lengths);

@ -36,6 +36,7 @@
#include <grpc/grpc_security.h> #include <grpc/grpc_security.h>
#include "src/core/iomgr/endpoint.h" #include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/tcp_server.h"
#include "src/core/tsi/transport_security_interface.h" #include "src/core/tsi/transport_security_interface.h"
/* --- status enum. --- */ /* --- status enum. --- */
@ -68,9 +69,6 @@ typedef void (*grpc_security_handshake_done_cb)(
typedef struct { typedef struct {
void (*destroy)(grpc_security_connector *sc); void (*destroy)(grpc_security_connector *sc);
void (*do_handshake)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc,
grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, void *user_data);
void (*check_peer)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc, void (*check_peer)(grpc_exec_ctx *exec_ctx, grpc_security_connector *sc,
tsi_peer peer, grpc_security_peer_check_cb cb, tsi_peer peer, grpc_security_peer_check_cb cb,
void *user_data); void *user_data);
@ -84,13 +82,7 @@ typedef struct grpc_security_connector_handshake_list {
struct grpc_security_connector { struct grpc_security_connector {
const grpc_security_connector_vtable *vtable; const grpc_security_connector_vtable *vtable;
gpr_refcount refcount; gpr_refcount refcount;
int is_client_side;
const char *url_scheme; const char *url_scheme;
/* Used on server side only. */
/* TODO(yangg): Create a grpc_server_security_connector with these. */
gpr_mu mu;
grpc_security_connector_handshake_list *handshaking_handshakes;
const grpc_channel_args *channel_args;
}; };
/* Refcounting. */ /* Refcounting. */
@ -113,13 +105,6 @@ grpc_security_connector *grpc_security_connector_ref(
void grpc_security_connector_unref(grpc_security_connector *policy); void grpc_security_connector_unref(grpc_security_connector *policy);
#endif #endif
/* Handshake. */
void grpc_security_connector_do_handshake(grpc_exec_ctx *exec_ctx,
grpc_security_connector *connector,
grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb,
void *user_data);
/* Check the peer. Callee takes ownership of the peer object. /* Check the peer. Callee takes ownership of the peer object.
The callback will include the resulting auth_context. */ The callback will include the resulting auth_context. */
void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx, void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx,
@ -128,9 +113,6 @@ void grpc_security_connector_check_peer(grpc_exec_ctx *exec_ctx,
grpc_security_peer_check_cb cb, grpc_security_peer_check_cb cb,
void *user_data); void *user_data);
void grpc_security_connector_shutdown(grpc_exec_ctx *exec_ctx,
grpc_security_connector *connector);
/* Util to encapsulate the connector in a channel arg. */ /* Util to encapsulate the connector in a channel arg. */
grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc); grpc_arg grpc_security_connector_to_arg(grpc_security_connector *sc);
@ -153,12 +135,16 @@ typedef void (*grpc_security_call_host_check_cb)(grpc_exec_ctx *exec_ctx,
grpc_security_status status); grpc_security_status status);
struct grpc_channel_security_connector { struct grpc_channel_security_connector {
grpc_security_connector base; /* requires is_client_side to be non 0. */ grpc_security_connector base;
grpc_call_credentials *request_metadata_creds; grpc_call_credentials *request_metadata_creds;
void (*check_call_host)(grpc_exec_ctx *exec_ctx, void (*check_call_host)(grpc_exec_ctx *exec_ctx,
grpc_channel_security_connector *sc, const char *host, grpc_channel_security_connector *sc, const char *host,
grpc_auth_context *auth_context, grpc_auth_context *auth_context,
grpc_security_call_host_check_cb cb, void *user_data); grpc_security_call_host_check_cb cb, void *user_data);
void (*do_handshake)(grpc_exec_ctx *exec_ctx,
grpc_channel_security_connector *sc,
grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, void *user_data);
}; };
/* Checks that the host that will be set for a call is acceptable. */ /* Checks that the host that will be set for a call is acceptable. */
@ -167,6 +153,39 @@ void grpc_channel_security_connector_check_call_host(
const char *host, grpc_auth_context *auth_context, const char *host, grpc_auth_context *auth_context,
grpc_security_call_host_check_cb cb, void *user_data); grpc_security_call_host_check_cb cb, void *user_data);
/* Handshake. */
void grpc_channel_security_connector_do_handshake(
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector,
grpc_endpoint *nonsecure_endpoint, grpc_security_handshake_done_cb cb,
void *user_data);
/* --- server_security_connector object. ---
A server security connector object represents away to configure the
underlying transport security mechanism on the server side. */
typedef struct grpc_server_security_connector grpc_server_security_connector;
struct grpc_server_security_connector {
grpc_security_connector base;
gpr_mu mu;
grpc_security_connector_handshake_list *handshaking_handshakes;
const grpc_channel_args *channel_args;
void (*do_handshake)(grpc_exec_ctx *exec_ctx,
grpc_server_security_connector *sc,
grpc_tcp_server_acceptor *acceptor,
grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, void *user_data);
};
void grpc_server_security_connector_do_handshake(
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
grpc_tcp_server_acceptor *acceptor, grpc_endpoint *nonsecure_endpoint,
grpc_security_handshake_done_cb cb, void *user_data);
void grpc_server_security_connector_shutdown(
grpc_exec_ctx *exec_ctx, grpc_server_security_connector *connector);
/* --- Creation security connectors. --- */ /* --- Creation security connectors. --- */
/* For TESTING ONLY! /* For TESTING ONLY!
@ -176,7 +195,8 @@ grpc_channel_security_connector *grpc_fake_channel_security_connector_create(
/* For TESTING ONLY! /* For TESTING ONLY!
Creates a fake connector that emulates real server security. */ Creates a fake connector that emulates real server security. */
grpc_security_connector *grpc_fake_server_security_connector_create(void); grpc_server_security_connector *grpc_fake_server_security_connector_create(
void);
/* Config for ssl clients. */ /* Config for ssl clients. */
typedef struct { typedef struct {
@ -231,7 +251,7 @@ typedef struct {
specific error code otherwise. specific error code otherwise.
*/ */
grpc_security_status grpc_ssl_server_security_connector_create( grpc_security_status grpc_ssl_server_security_connector_create(
const grpc_ssl_server_config *config, grpc_security_connector **sc); const grpc_ssl_server_config *config, grpc_server_security_connector **sc);
/* Util. */ /* Util. */
const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer, const tsi_peer_property *tsi_peer_get_property_by_name(const tsi_peer *peer,

@ -55,7 +55,7 @@
typedef struct grpc_server_secure_state { typedef struct grpc_server_secure_state {
grpc_server *server; grpc_server *server;
grpc_tcp_server *tcp; grpc_tcp_server *tcp;
grpc_security_connector *sc; grpc_server_security_connector *sc;
grpc_server_credentials *creds; grpc_server_credentials *creds;
int is_shutdown; int is_shutdown;
gpr_mu mu; gpr_mu mu;
@ -74,7 +74,7 @@ static void state_unref(grpc_server_secure_state *state) {
gpr_mu_lock(&state->mu); gpr_mu_lock(&state->mu);
gpr_mu_unlock(&state->mu); gpr_mu_unlock(&state->mu);
/* clean up */ /* clean up */
GRPC_SECURITY_CONNECTOR_UNREF(state->sc, "server"); GRPC_SECURITY_CONNECTOR_UNREF(&state->sc->base, "server");
grpc_server_credentials_unref(state->creds); grpc_server_credentials_unref(state->creds);
gpr_free(state); gpr_free(state);
} }
@ -130,8 +130,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *statep, grpc_endpoint *tcp,
grpc_tcp_server_acceptor *acceptor) { grpc_tcp_server_acceptor *acceptor) {
grpc_server_secure_state *state = statep; grpc_server_secure_state *state = statep;
state_ref(state); state_ref(state);
grpc_security_connector_do_handshake(exec_ctx, state->sc, tcp, grpc_server_security_connector_do_handshake(
on_secure_handshake_done, state); exec_ctx, state->sc, acceptor, tcp, on_secure_handshake_done, state);
} }
/* Server callback: start listening on our ports */ /* Server callback: start listening on our ports */
@ -148,7 +148,7 @@ static void destroy_done(grpc_exec_ctx *exec_ctx, void *statep, bool success) {
state->destroy_callback->cb(exec_ctx, state->destroy_callback->cb_arg, state->destroy_callback->cb(exec_ctx, state->destroy_callback->cb_arg,
success); success);
} }
grpc_security_connector_shutdown(exec_ctx, state->sc); grpc_server_security_connector_shutdown(exec_ctx, state->sc);
state_unref(state); state_unref(state);
} }
@ -176,7 +176,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
int port_num = -1; int port_num = -1;
int port_temp; int port_temp;
grpc_security_status status = GRPC_SECURITY_ERROR; grpc_security_status status = GRPC_SECURITY_ERROR;
grpc_security_connector *sc = NULL; grpc_server_security_connector *sc = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GRPC_API_TRACE( GRPC_API_TRACE(
@ -256,7 +256,7 @@ error:
grpc_tcp_server_unref(&exec_ctx, tcp); grpc_tcp_server_unref(&exec_ctx, tcp);
} else { } else {
if (sc) { if (sc) {
GRPC_SECURITY_CONNECTOR_UNREF(sc, "server"); GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "server");
} }
if (state) { if (state) {
gpr_free(state); gpr_free(state);

@ -64,8 +64,9 @@ grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline,
alarm->tag = tag; alarm->tag = tag;
grpc_cq_begin_op(cq, tag); grpc_cq_begin_op(cq, tag);
grpc_timer_init(&exec_ctx, &alarm->alarm, deadline, alarm_cb, alarm, grpc_timer_init(&exec_ctx, &alarm->alarm,
gpr_now(GPR_CLOCK_MONOTONIC)); gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC),
alarm_cb, alarm, gpr_now(GPR_CLOCK_MONOTONIC));
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
return alarm; return alarm;
} }

@ -57,7 +57,8 @@ typedef struct {
/* Completion queue structure */ /* Completion queue structure */
struct grpc_completion_queue { struct grpc_completion_queue {
gpr_mu mu; /** owned by pollset */
gpr_mu *mu;
/** completed events */ /** completed events */
grpc_cq_completion completed_head; grpc_cq_completion completed_head;
grpc_cq_completion *completed_tail; grpc_cq_completion *completed_tail;
@ -97,7 +98,6 @@ void grpc_cq_global_shutdown(void) {
while (g_freelist) { while (g_freelist) {
grpc_completion_queue *next = g_freelist->next_free; grpc_completion_queue *next = g_freelist->next_free;
grpc_pollset_destroy(POLLSET_FROM_CQ(g_freelist)); grpc_pollset_destroy(POLLSET_FROM_CQ(g_freelist));
gpr_mu_destroy(&g_freelist->mu);
#ifndef NDEBUG #ifndef NDEBUG
gpr_free(g_freelist->outstanding_tags); gpr_free(g_freelist->outstanding_tags);
#endif #endif
@ -128,7 +128,6 @@ grpc_completion_queue *grpc_completion_queue_create(void *reserved) {
gpr_mu_unlock(&g_freelist_mu); gpr_mu_unlock(&g_freelist_mu);
cc = gpr_malloc(sizeof(grpc_completion_queue) + grpc_pollset_size()); cc = gpr_malloc(sizeof(grpc_completion_queue) + grpc_pollset_size());
gpr_mu_init(&cc->mu);
grpc_pollset_init(POLLSET_FROM_CQ(cc), &cc->mu); grpc_pollset_init(POLLSET_FROM_CQ(cc), &cc->mu);
#ifndef NDEBUG #ifndef NDEBUG
cc->outstanding_tags = NULL; cc->outstanding_tags = NULL;
@ -198,7 +197,7 @@ void grpc_cq_internal_unref(grpc_completion_queue *cc) {
void grpc_cq_begin_op(grpc_completion_queue *cc, void *tag) { void grpc_cq_begin_op(grpc_completion_queue *cc, void *tag) {
#ifndef NDEBUG #ifndef NDEBUG
gpr_mu_lock(&cc->mu); gpr_mu_lock(cc->mu);
GPR_ASSERT(!cc->shutdown_called); GPR_ASSERT(!cc->shutdown_called);
if (cc->outstanding_tag_count == cc->outstanding_tag_capacity) { if (cc->outstanding_tag_count == cc->outstanding_tag_capacity) {
cc->outstanding_tag_capacity = GPR_MAX(4, 2 * cc->outstanding_tag_capacity); cc->outstanding_tag_capacity = GPR_MAX(4, 2 * cc->outstanding_tag_capacity);
@ -207,7 +206,7 @@ void grpc_cq_begin_op(grpc_completion_queue *cc, void *tag) {
cc->outstanding_tag_capacity); cc->outstanding_tag_capacity);
} }
cc->outstanding_tags[cc->outstanding_tag_count++] = tag; cc->outstanding_tags[cc->outstanding_tag_count++] = tag;
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
#endif #endif
gpr_ref(&cc->pending_events); gpr_ref(&cc->pending_events);
} }
@ -235,7 +234,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
storage->next = storage->next =
((uintptr_t)&cc->completed_head) | ((uintptr_t)(success != 0)); ((uintptr_t)&cc->completed_head) | ((uintptr_t)(success != 0));
gpr_mu_lock(&cc->mu); gpr_mu_lock(cc->mu);
#ifndef NDEBUG #ifndef NDEBUG
for (i = 0; i < (int)cc->outstanding_tag_count; i++) { for (i = 0; i < (int)cc->outstanding_tag_count; i++) {
if (cc->outstanding_tags[i] == tag) { if (cc->outstanding_tags[i] == tag) {
@ -261,7 +260,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
} }
} }
grpc_pollset_kick(POLLSET_FROM_CQ(cc), pluck_worker); grpc_pollset_kick(POLLSET_FROM_CQ(cc), pluck_worker);
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
} else { } else {
cc->completed_tail->next = cc->completed_tail->next =
((uintptr_t)storage) | (1u & (uintptr_t)cc->completed_tail->next); ((uintptr_t)storage) | (1u & (uintptr_t)cc->completed_tail->next);
@ -271,7 +270,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc,
cc->shutdown = 1; cc->shutdown = 1;
grpc_pollset_shutdown(exec_ctx, POLLSET_FROM_CQ(cc), grpc_pollset_shutdown(exec_ctx, POLLSET_FROM_CQ(cc),
&cc->pollset_shutdown_done); &cc->pollset_shutdown_done);
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
} }
GPR_TIMER_END("grpc_cq_end_op", 0); GPR_TIMER_END("grpc_cq_end_op", 0);
@ -299,7 +298,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
GRPC_CQ_INTERNAL_REF(cc, "next"); GRPC_CQ_INTERNAL_REF(cc, "next");
gpr_mu_lock(&cc->mu); gpr_mu_lock(cc->mu);
for (;;) { for (;;) {
if (cc->completed_tail != &cc->completed_head) { if (cc->completed_tail != &cc->completed_head) {
grpc_cq_completion *c = (grpc_cq_completion *)cc->completed_head.next; grpc_cq_completion *c = (grpc_cq_completion *)cc->completed_head.next;
@ -307,7 +306,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
if (c == cc->completed_tail) { if (c == cc->completed_tail) {
cc->completed_tail = &cc->completed_head; cc->completed_tail = &cc->completed_head;
} }
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
ret.type = GRPC_OP_COMPLETE; ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u; ret.success = c->next & 1u;
ret.tag = c->tag; ret.tag = c->tag;
@ -315,14 +314,14 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
break; break;
} }
if (cc->shutdown) { if (cc->shutdown) {
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
memset(&ret, 0, sizeof(ret)); memset(&ret, 0, sizeof(ret));
ret.type = GRPC_QUEUE_SHUTDOWN; ret.type = GRPC_QUEUE_SHUTDOWN;
break; break;
} }
now = gpr_now(GPR_CLOCK_MONOTONIC); now = gpr_now(GPR_CLOCK_MONOTONIC);
if (!first_loop && gpr_time_cmp(now, deadline) >= 0) { if (!first_loop && gpr_time_cmp(now, deadline) >= 0) {
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
memset(&ret, 0, sizeof(ret)); memset(&ret, 0, sizeof(ret));
ret.type = GRPC_QUEUE_TIMEOUT; ret.type = GRPC_QUEUE_TIMEOUT;
break; break;
@ -335,9 +334,9 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc,
gpr_timespec iteration_deadline = deadline; gpr_timespec iteration_deadline = deadline;
if (grpc_timer_check(&exec_ctx, now, &iteration_deadline)) { if (grpc_timer_check(&exec_ctx, now, &iteration_deadline)) {
GPR_TIMER_MARK("alarm_triggered", 0); GPR_TIMER_MARK("alarm_triggered", 0);
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(&cc->mu); gpr_mu_lock(cc->mu);
continue; continue;
} else { } else {
grpc_pollset_work(&exec_ctx, POLLSET_FROM_CQ(cc), &worker, now, grpc_pollset_work(&exec_ctx, POLLSET_FROM_CQ(cc), &worker, now,
@ -401,7 +400,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
GRPC_CQ_INTERNAL_REF(cc, "pluck"); GRPC_CQ_INTERNAL_REF(cc, "pluck");
gpr_mu_lock(&cc->mu); gpr_mu_lock(cc->mu);
for (;;) { for (;;) {
prev = &cc->completed_head; prev = &cc->completed_head;
while ((c = (grpc_cq_completion *)(prev->next & ~(uintptr_t)1)) != while ((c = (grpc_cq_completion *)(prev->next & ~(uintptr_t)1)) !=
@ -411,7 +410,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
if (c == cc->completed_tail) { if (c == cc->completed_tail) {
cc->completed_tail = prev; cc->completed_tail = prev;
} }
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
ret.type = GRPC_OP_COMPLETE; ret.type = GRPC_OP_COMPLETE;
ret.success = c->next & 1u; ret.success = c->next & 1u;
ret.tag = c->tag; ret.tag = c->tag;
@ -421,7 +420,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
prev = c; prev = c;
} }
if (cc->shutdown) { if (cc->shutdown) {
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
memset(&ret, 0, sizeof(ret)); memset(&ret, 0, sizeof(ret));
ret.type = GRPC_QUEUE_SHUTDOWN; ret.type = GRPC_QUEUE_SHUTDOWN;
break; break;
@ -431,7 +430,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
"Too many outstanding grpc_completion_queue_pluck calls: maximum " "Too many outstanding grpc_completion_queue_pluck calls: maximum "
"is %d", "is %d",
GRPC_MAX_COMPLETION_QUEUE_PLUCKERS); GRPC_MAX_COMPLETION_QUEUE_PLUCKERS);
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
memset(&ret, 0, sizeof(ret)); memset(&ret, 0, sizeof(ret));
/* TODO(ctiller): should we use a different result here */ /* TODO(ctiller): should we use a different result here */
ret.type = GRPC_QUEUE_TIMEOUT; ret.type = GRPC_QUEUE_TIMEOUT;
@ -440,7 +439,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
now = gpr_now(GPR_CLOCK_MONOTONIC); now = gpr_now(GPR_CLOCK_MONOTONIC);
if (!first_loop && gpr_time_cmp(now, deadline) >= 0) { if (!first_loop && gpr_time_cmp(now, deadline) >= 0) {
del_plucker(cc, tag, &worker); del_plucker(cc, tag, &worker);
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
memset(&ret, 0, sizeof(ret)); memset(&ret, 0, sizeof(ret));
ret.type = GRPC_QUEUE_TIMEOUT; ret.type = GRPC_QUEUE_TIMEOUT;
break; break;
@ -453,10 +452,9 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag,
gpr_timespec iteration_deadline = deadline; gpr_timespec iteration_deadline = deadline;
if (grpc_timer_check(&exec_ctx, now, &iteration_deadline)) { if (grpc_timer_check(&exec_ctx, now, &iteration_deadline)) {
GPR_TIMER_MARK("alarm_triggered", 0); GPR_TIMER_MARK("alarm_triggered", 0);
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(&cc->mu); gpr_mu_lock(cc->mu);
continue;
} else { } else {
grpc_pollset_work(&exec_ctx, POLLSET_FROM_CQ(cc), &worker, now, grpc_pollset_work(&exec_ctx, POLLSET_FROM_CQ(cc), &worker, now,
iteration_deadline); iteration_deadline);
@ -479,9 +477,9 @@ void grpc_completion_queue_shutdown(grpc_completion_queue *cc) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0); GPR_TIMER_BEGIN("grpc_completion_queue_shutdown", 0);
GRPC_API_TRACE("grpc_completion_queue_shutdown(cc=%p)", 1, (cc)); GRPC_API_TRACE("grpc_completion_queue_shutdown(cc=%p)", 1, (cc));
gpr_mu_lock(&cc->mu); gpr_mu_lock(cc->mu);
if (cc->shutdown_called) { if (cc->shutdown_called) {
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
GPR_TIMER_END("grpc_completion_queue_shutdown", 0); GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
return; return;
} }
@ -492,7 +490,7 @@ void grpc_completion_queue_shutdown(grpc_completion_queue *cc) {
grpc_pollset_shutdown(&exec_ctx, POLLSET_FROM_CQ(cc), grpc_pollset_shutdown(&exec_ctx, POLLSET_FROM_CQ(cc),
&cc->pollset_shutdown_done); &cc->pollset_shutdown_done);
} }
gpr_mu_unlock(&cc->mu); gpr_mu_unlock(cc->mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
GPR_TIMER_END("grpc_completion_queue_shutdown", 0); GPR_TIMER_END("grpc_completion_queue_shutdown", 0);
} }

@ -130,7 +130,7 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
static void on_initial_connect_string_sent(grpc_exec_ctx *exec_ctx, void *arg, static void on_initial_connect_string_sent(grpc_exec_ctx *exec_ctx, void *arg,
bool success) { bool success) {
connector *c = arg; connector *c = arg;
grpc_security_connector_do_handshake(exec_ctx, &c->security_connector->base, grpc_channel_security_connector_do_handshake(exec_ctx, c->security_connector,
c->connecting_endpoint, c->connecting_endpoint,
on_secure_handshake_done, c); on_secure_handshake_done, c);
} }
@ -153,9 +153,8 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer, grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer,
&c->initial_string_sent); &c->initial_string_sent);
} else { } else {
grpc_security_connector_do_handshake(exec_ctx, grpc_channel_security_connector_do_handshake(
&c->security_connector->base, tcp, exec_ctx, c->security_connector, tcp, on_secure_handshake_done, c);
on_secure_handshake_done, c);
} }
} else { } else {
memset(c->result, 0, sizeof(*c->result)); memset(c->result, 0, sizeof(*c->result));

@ -1,51 +0,0 @@
/*
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <grpc++/alarm.h>
#include <grpc++/completion_queue.h>
#include <grpc++/impl/grpc_library.h>
#include <grpc/grpc.h>
namespace grpc {
static internal::GrpcLibraryInitializer g_gli_initializer;
Alarm::Alarm(CompletionQueue* cq, gpr_timespec deadline, void* tag)
: tag_(tag),
alarm_(grpc_alarm_create(cq->cq(), deadline, static_cast<void*>(&tag_))) {
g_gli_initializer.summon();
}
Alarm::~Alarm() { grpc_alarm_destroy(alarm_); }
void Alarm::Cancel() { grpc_alarm_cancel(alarm_); }
} // namespace grpc

@ -53,12 +53,18 @@ namespace Grpc.Core.Internal
static PlatformApis() static PlatformApis()
{ {
#if DNXCORE50
isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
isMacOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
#else
var platform = Environment.OSVersion.Platform; var platform = Environment.OSVersion.Platform;
// PlatformID.MacOSX is never returned, commonly used trick is to identify Mac is by using uname. // PlatformID.MacOSX is never returned, commonly used trick is to identify Mac is by using uname.
isMacOSX = (platform == PlatformID.Unix && GetUname() == "Darwin"); isMacOSX = (platform == PlatformID.Unix && GetUname() == "Darwin");
isLinux = (platform == PlatformID.Unix && !isMacOSX); isLinux = (platform == PlatformID.Unix && !isMacOSX);
isWindows = (platform == PlatformID.Win32NT || platform == PlatformID.Win32S || platform == PlatformID.Win32Windows); isWindows = (platform == PlatformID.Win32NT || platform == PlatformID.Win32S || platform == PlatformID.Win32Windows);
#endif
isMono = Type.GetType("Mono.Runtime") != null; isMono = Type.GetType("Mono.Runtime") != null;
} }

@ -36,7 +36,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Grpc.Core; using Grpc.Core;
using Grpc.Health.V1Alpha; using Grpc.Health.V1;
using NUnit.Framework; using NUnit.Framework;
namespace Grpc.HealthCheck.Tests namespace Grpc.HealthCheck.Tests
@ -49,7 +49,7 @@ namespace Grpc.HealthCheck.Tests
const string Host = "localhost"; const string Host = "localhost";
Server server; Server server;
Channel channel; Channel channel;
Grpc.Health.V1Alpha.Health.IHealthClient client; Grpc.Health.V1.Health.IHealthClient client;
Grpc.HealthCheck.HealthServiceImpl serviceImpl; Grpc.HealthCheck.HealthServiceImpl serviceImpl;
[TestFixtureSetUp] [TestFixtureSetUp]
@ -59,13 +59,13 @@ namespace Grpc.HealthCheck.Tests
server = new Server server = new Server
{ {
Services = { Grpc.Health.V1Alpha.Health.BindService(serviceImpl) }, Services = { Grpc.Health.V1.Health.BindService(serviceImpl) },
Ports = { { Host, ServerPort.PickUnused, ServerCredentials.Insecure } } Ports = { { Host, ServerPort.PickUnused, ServerCredentials.Insecure } }
}; };
server.Start(); server.Start();
channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure); channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure);
client = Grpc.Health.V1Alpha.Health.NewClient(channel); client = Grpc.Health.V1.Health.NewClient(channel);
} }
[TestFixtureTearDown] [TestFixtureTearDown]
@ -79,16 +79,16 @@ namespace Grpc.HealthCheck.Tests
[Test] [Test]
public void ServiceIsRunning() public void ServiceIsRunning()
{ {
serviceImpl.SetStatus("", "", HealthCheckResponse.Types.ServingStatus.SERVING); serviceImpl.SetStatus("", HealthCheckResponse.Types.ServingStatus.SERVING);
var response = client.Check(new HealthCheckRequest { Host = "", Service = "" }); var response = client.Check(new HealthCheckRequest { Service = "" });
Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.SERVING, response.Status); Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.SERVING, response.Status);
} }
[Test] [Test]
public void ServiceDoesntExist() public void ServiceDoesntExist()
{ {
Assert.Throws(Is.TypeOf(typeof(RpcException)).And.Property("Status").Property("StatusCode").EqualTo(StatusCode.NotFound), () => client.Check(new HealthCheckRequest { Host = "", Service = "nonexistent.service" })); Assert.Throws(Is.TypeOf(typeof(RpcException)).And.Property("Status").Property("StatusCode").EqualTo(StatusCode.NotFound), () => client.Check(new HealthCheckRequest { Service = "nonexistent.service" }));
} }
// TODO(jtattermusch): add test with timeout once timeouts are supported // TODO(jtattermusch): add test with timeout once timeouts are supported

@ -1,5 +1,5 @@
#region Copyright notice and license #region Copyright notice and license
// 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,7 +36,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Grpc.Core; using Grpc.Core;
using Grpc.Health.V1Alpha; using Grpc.Health.V1;
using NUnit.Framework; using NUnit.Framework;
namespace Grpc.HealthCheck.Tests namespace Grpc.HealthCheck.Tests
@ -50,58 +50,56 @@ namespace Grpc.HealthCheck.Tests
public void SetStatus() public void SetStatus()
{ {
var impl = new HealthServiceImpl(); var impl = new HealthServiceImpl();
impl.SetStatus("", "", HealthCheckResponse.Types.ServingStatus.SERVING); impl.SetStatus("", HealthCheckResponse.Types.ServingStatus.SERVING);
Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.SERVING, GetStatusHelper(impl, "", "")); Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.SERVING, GetStatusHelper(impl, ""));
impl.SetStatus("", "", HealthCheckResponse.Types.ServingStatus.NOT_SERVING); impl.SetStatus("", HealthCheckResponse.Types.ServingStatus.NOT_SERVING);
Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.NOT_SERVING, GetStatusHelper(impl, "", "")); Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.NOT_SERVING, GetStatusHelper(impl, ""));
impl.SetStatus("virtual-host", "", HealthCheckResponse.Types.ServingStatus.UNKNOWN); impl.SetStatus("", HealthCheckResponse.Types.ServingStatus.UNKNOWN);
Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.UNKNOWN, GetStatusHelper(impl, "virtual-host", "")); Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.UNKNOWN, GetStatusHelper(impl, ""));
impl.SetStatus("virtual-host", "grpc.test.TestService", HealthCheckResponse.Types.ServingStatus.SERVING); impl.SetStatus("grpc.test.TestService", HealthCheckResponse.Types.ServingStatus.SERVING);
Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.SERVING, GetStatusHelper(impl, "virtual-host", "grpc.test.TestService")); Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.SERVING, GetStatusHelper(impl, "grpc.test.TestService"));
} }
[Test] [Test]
public void ClearStatus() public void ClearStatus()
{ {
var impl = new HealthServiceImpl(); var impl = new HealthServiceImpl();
impl.SetStatus("", "", HealthCheckResponse.Types.ServingStatus.SERVING); impl.SetStatus("", HealthCheckResponse.Types.ServingStatus.SERVING);
impl.SetStatus("virtual-host", "", HealthCheckResponse.Types.ServingStatus.UNKNOWN); impl.SetStatus("grpc.test.TestService", HealthCheckResponse.Types.ServingStatus.UNKNOWN);
impl.ClearStatus("", ""); impl.ClearStatus("");
Assert.Throws(Is.TypeOf(typeof(RpcException)).And.Property("Status").Property("StatusCode").EqualTo(StatusCode.NotFound), () => GetStatusHelper(impl, "", "")); Assert.Throws(Is.TypeOf(typeof(RpcException)).And.Property("Status").Property("StatusCode").EqualTo(StatusCode.NotFound), () => GetStatusHelper(impl, ""));
Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.UNKNOWN, GetStatusHelper(impl, "virtual-host", "")); Assert.AreEqual(HealthCheckResponse.Types.ServingStatus.UNKNOWN, GetStatusHelper(impl, "grpc.test.TestService"));
} }
[Test] [Test]
public void ClearAll() public void ClearAll()
{ {
var impl = new HealthServiceImpl(); var impl = new HealthServiceImpl();
impl.SetStatus("", "", HealthCheckResponse.Types.ServingStatus.SERVING); impl.SetStatus("", HealthCheckResponse.Types.ServingStatus.SERVING);
impl.SetStatus("virtual-host", "", HealthCheckResponse.Types.ServingStatus.UNKNOWN); impl.SetStatus("grpc.test.TestService", HealthCheckResponse.Types.ServingStatus.UNKNOWN);
impl.ClearAll(); impl.ClearAll();
Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, "", "")); Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, ""));
Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, "virtual-host", "")); Assert.Throws(typeof(RpcException), () => GetStatusHelper(impl, "grpc.test.TestService"));
} }
[Test] [Test]
public void NullsRejected() public void NullsRejected()
{ {
var impl = new HealthServiceImpl(); var impl = new HealthServiceImpl();
Assert.Throws(typeof(ArgumentNullException), () => impl.SetStatus(null, "", HealthCheckResponse.Types.ServingStatus.SERVING)); Assert.Throws(typeof(ArgumentNullException), () => impl.SetStatus(null, HealthCheckResponse.Types.ServingStatus.SERVING));
Assert.Throws(typeof(ArgumentNullException), () => impl.SetStatus("", null, HealthCheckResponse.Types.ServingStatus.SERVING));
Assert.Throws(typeof(ArgumentNullException), () => impl.ClearStatus(null, "")); Assert.Throws(typeof(ArgumentNullException), () => impl.ClearStatus(null));
Assert.Throws(typeof(ArgumentNullException), () => impl.ClearStatus("", null));
} }
private static HealthCheckResponse.Types.ServingStatus GetStatusHelper(HealthServiceImpl impl, string host, string service) private static HealthCheckResponse.Types.ServingStatus GetStatusHelper(HealthServiceImpl impl, string service)
{ {
return impl.Check(new HealthCheckRequest { Host = host, Service = service }, null).Result.Status; return impl.Check(new HealthCheckRequest { Service = service }, null).Result.Status;
} }
} }
} }

@ -4,7 +4,7 @@
<id>Grpc.HealthCheck</id> <id>Grpc.HealthCheck</id>
<title>gRPC C# Healthchecking</title> <title>gRPC C# Healthchecking</title>
<summary>Implementation of gRPC health service</summary> <summary>Implementation of gRPC health service</summary>
<description>Example implementation of grpc.health.v1alpha service that can be used for health-checking.</description> <description>Example implementation of grpc.health.v1 service that can be used for health-checking.</description>
<version>$version$</version> <version>$version$</version>
<authors>Google Inc.</authors> <authors>Google Inc.</authors>
<owners>grpc-packages</owners> <owners>grpc-packages</owners>

@ -7,7 +7,7 @@ using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections; using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection; using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic; using scg = global::System.Collections.Generic;
namespace Grpc.Health.V1Alpha { namespace Grpc.Health.V1 {
/// <summary>Holder for reflection information generated from health.proto</summary> /// <summary>Holder for reflection information generated from health.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@ -23,20 +23,19 @@ namespace Grpc.Health.V1Alpha {
static HealthReflection() { static HealthReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"CgxoZWFsdGgucHJvdG8SE2dycGMuaGVhbHRoLnYxYWxwaGEiMwoSSGVhbHRo", "CgxoZWFsdGgucHJvdG8SDmdycGMuaGVhbHRoLnYxIiUKEkhlYWx0aENoZWNr",
"Q2hlY2tSZXF1ZXN0EgwKBGhvc3QYASABKAkSDwoHc2VydmljZRgCIAEoCSKZ", "UmVxdWVzdBIPCgdzZXJ2aWNlGAEgASgJIpQBChNIZWFsdGhDaGVja1Jlc3Bv",
"AQoTSGVhbHRoQ2hlY2tSZXNwb25zZRJGCgZzdGF0dXMYASABKA4yNi5ncnBj", "bnNlEkEKBnN0YXR1cxgBIAEoDjIxLmdycGMuaGVhbHRoLnYxLkhlYWx0aENo",
"LmhlYWx0aC52MWFscGhhLkhlYWx0aENoZWNrUmVzcG9uc2UuU2VydmluZ1N0", "ZWNrUmVzcG9uc2UuU2VydmluZ1N0YXR1cyI6Cg1TZXJ2aW5nU3RhdHVzEgsK",
"YXR1cyI6Cg1TZXJ2aW5nU3RhdHVzEgsKB1VOS05PV04QABILCgdTRVJWSU5H", "B1VOS05PV04QABILCgdTRVJWSU5HEAESDwoLTk9UX1NFUlZJTkcQAjJaCgZI",
"EAESDwoLTk9UX1NFUlZJTkcQAjJkCgZIZWFsdGgSWgoFQ2hlY2sSJy5ncnBj", "ZWFsdGgSUAoFQ2hlY2sSIi5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jl",
"LmhlYWx0aC52MWFscGhhLkhlYWx0aENoZWNrUmVxdWVzdBooLmdycGMuaGVh", "cXVlc3QaIy5ncnBjLmhlYWx0aC52MS5IZWFsdGhDaGVja1Jlc3BvbnNlQhGq",
"bHRoLnYxYWxwaGEuSGVhbHRoQ2hlY2tSZXNwb25zZUIWqgITR3JwYy5IZWFs", "Ag5HcnBjLkhlYWx0aC5WMWIGcHJvdG8z"));
"dGguVjFBbHBoYWIGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] { new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Health.V1Alpha.HealthCheckRequest), global::Grpc.Health.V1Alpha.HealthCheckRequest.Parser, new[]{ "Host", "Service" }, null, null, null), new pbr::GeneratedCodeInfo(typeof(global::Grpc.Health.V1.HealthCheckRequest), global::Grpc.Health.V1.HealthCheckRequest.Parser, new[]{ "Service" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Health.V1Alpha.HealthCheckResponse), global::Grpc.Health.V1Alpha.HealthCheckResponse.Parser, new[]{ "Status" }, null, new[]{ typeof(global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus) }, null) new pbr::GeneratedCodeInfo(typeof(global::Grpc.Health.V1.HealthCheckResponse), global::Grpc.Health.V1.HealthCheckResponse.Parser, new[]{ "Status" }, null, new[]{ typeof(global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus) }, null)
})); }));
} }
#endregion #endregion
@ -49,7 +48,7 @@ namespace Grpc.Health.V1Alpha {
public static pb::MessageParser<HealthCheckRequest> Parser { get { return _parser; } } public static pb::MessageParser<HealthCheckRequest> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Grpc.Health.V1Alpha.HealthReflection.Descriptor.MessageTypes[0]; } get { return global::Grpc.Health.V1.HealthReflection.Descriptor.MessageTypes[0]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -63,7 +62,6 @@ namespace Grpc.Health.V1Alpha {
partial void OnConstruction(); partial void OnConstruction();
public HealthCheckRequest(HealthCheckRequest other) : this() { public HealthCheckRequest(HealthCheckRequest other) : this() {
host_ = other.host_;
service_ = other.service_; service_ = other.service_;
} }
@ -71,18 +69,8 @@ namespace Grpc.Health.V1Alpha {
return new HealthCheckRequest(this); return new HealthCheckRequest(this);
} }
/// <summary>Field number for the "host" field.</summary>
public const int HostFieldNumber = 1;
private string host_ = "";
public string Host {
get { return host_; }
set {
host_ = pb::Preconditions.CheckNotNull(value, "value");
}
}
/// <summary>Field number for the "service" field.</summary> /// <summary>Field number for the "service" field.</summary>
public const int ServiceFieldNumber = 2; public const int ServiceFieldNumber = 1;
private string service_ = ""; private string service_ = "";
public string Service { public string Service {
get { return service_; } get { return service_; }
@ -102,14 +90,12 @@ namespace Grpc.Health.V1Alpha {
if (ReferenceEquals(other, this)) { if (ReferenceEquals(other, this)) {
return true; return true;
} }
if (Host != other.Host) return false;
if (Service != other.Service) return false; if (Service != other.Service) return false;
return true; return true;
} }
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (Host.Length != 0) hash ^= Host.GetHashCode();
if (Service.Length != 0) hash ^= Service.GetHashCode(); if (Service.Length != 0) hash ^= Service.GetHashCode();
return hash; return hash;
} }
@ -119,21 +105,14 @@ namespace Grpc.Health.V1Alpha {
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
if (Host.Length != 0) {
output.WriteRawTag(10);
output.WriteString(Host);
}
if (Service.Length != 0) { if (Service.Length != 0) {
output.WriteRawTag(18); output.WriteRawTag(10);
output.WriteString(Service); output.WriteString(Service);
} }
} }
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
if (Host.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Host);
}
if (Service.Length != 0) { if (Service.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Service); size += 1 + pb::CodedOutputStream.ComputeStringSize(Service);
} }
@ -144,9 +123,6 @@ namespace Grpc.Health.V1Alpha {
if (other == null) { if (other == null) {
return; return;
} }
if (other.Host.Length != 0) {
Host = other.Host;
}
if (other.Service.Length != 0) { if (other.Service.Length != 0) {
Service = other.Service; Service = other.Service;
} }
@ -160,10 +136,6 @@ namespace Grpc.Health.V1Alpha {
input.SkipLastField(); input.SkipLastField();
break; break;
case 10: { case 10: {
Host = input.ReadString();
break;
}
case 18: {
Service = input.ReadString(); Service = input.ReadString();
break; break;
} }
@ -179,7 +151,7 @@ namespace Grpc.Health.V1Alpha {
public static pb::MessageParser<HealthCheckResponse> Parser { get { return _parser; } } public static pb::MessageParser<HealthCheckResponse> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Grpc.Health.V1Alpha.HealthReflection.Descriptor.MessageTypes[1]; } get { return global::Grpc.Health.V1.HealthReflection.Descriptor.MessageTypes[1]; }
} }
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
@ -202,8 +174,8 @@ namespace Grpc.Health.V1Alpha {
/// <summary>Field number for the "status" field.</summary> /// <summary>Field number for the "status" field.</summary>
public const int StatusFieldNumber = 1; public const int StatusFieldNumber = 1;
private global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus status_ = global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus.UNKNOWN; private global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus status_ = global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus.UNKNOWN;
public global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus Status { public global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus Status {
get { return status_; } get { return status_; }
set { set {
status_ = value; status_ = value;
@ -227,7 +199,7 @@ namespace Grpc.Health.V1Alpha {
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (Status != global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus.UNKNOWN) hash ^= Status.GetHashCode(); if (Status != global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus.UNKNOWN) hash ^= Status.GetHashCode();
return hash; return hash;
} }
@ -236,7 +208,7 @@ namespace Grpc.Health.V1Alpha {
} }
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
if (Status != global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus.UNKNOWN) { if (Status != global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus.UNKNOWN) {
output.WriteRawTag(8); output.WriteRawTag(8);
output.WriteEnum((int) Status); output.WriteEnum((int) Status);
} }
@ -244,7 +216,7 @@ namespace Grpc.Health.V1Alpha {
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
if (Status != global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus.UNKNOWN) { if (Status != global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus.UNKNOWN) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status); size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status);
} }
return size; return size;
@ -254,7 +226,7 @@ namespace Grpc.Health.V1Alpha {
if (other == null) { if (other == null) {
return; return;
} }
if (other.Status != global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus.UNKNOWN) { if (other.Status != global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus.UNKNOWN) {
Status = other.Status; Status = other.Status;
} }
} }
@ -267,7 +239,7 @@ namespace Grpc.Health.V1Alpha {
input.SkipLastField(); input.SkipLastField();
break; break;
case 8: { case 8: {
status_ = (global::Grpc.Health.V1Alpha.HealthCheckResponse.Types.ServingStatus) input.ReadEnum(); status_ = (global::Grpc.Health.V1.HealthCheckResponse.Types.ServingStatus) input.ReadEnum();
break; break;
} }
} }

@ -7,15 +7,15 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Grpc.Core; using Grpc.Core;
namespace Grpc.Health.V1Alpha { namespace Grpc.Health.V1 {
public static class Health public static class Health
{ {
static readonly string __ServiceName = "grpc.health.v1alpha.Health"; static readonly string __ServiceName = "grpc.health.v1.Health";
static readonly Marshaller<global::Grpc.Health.V1Alpha.HealthCheckRequest> __Marshaller_HealthCheckRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1Alpha.HealthCheckRequest.Parser.ParseFrom); static readonly Marshaller<global::Grpc.Health.V1.HealthCheckRequest> __Marshaller_HealthCheckRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckRequest.Parser.ParseFrom);
static readonly Marshaller<global::Grpc.Health.V1Alpha.HealthCheckResponse> __Marshaller_HealthCheckResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1Alpha.HealthCheckResponse.Parser.ParseFrom); static readonly Marshaller<global::Grpc.Health.V1.HealthCheckResponse> __Marshaller_HealthCheckResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Health.V1.HealthCheckResponse.Parser.ParseFrom);
static readonly Method<global::Grpc.Health.V1Alpha.HealthCheckRequest, global::Grpc.Health.V1Alpha.HealthCheckResponse> __Method_Check = new Method<global::Grpc.Health.V1Alpha.HealthCheckRequest, global::Grpc.Health.V1Alpha.HealthCheckResponse>( static readonly Method<global::Grpc.Health.V1.HealthCheckRequest, global::Grpc.Health.V1.HealthCheckResponse> __Method_Check = new Method<global::Grpc.Health.V1.HealthCheckRequest, global::Grpc.Health.V1.HealthCheckResponse>(
MethodType.Unary, MethodType.Unary,
__ServiceName, __ServiceName,
"Check", "Check",
@ -25,22 +25,22 @@ namespace Grpc.Health.V1Alpha {
// service descriptor // service descriptor
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
{ {
get { return global::Grpc.Health.V1Alpha.HealthReflection.Descriptor.Services[0]; } get { return global::Grpc.Health.V1.HealthReflection.Descriptor.Services[0]; }
} }
// client interface // client interface
public interface IHealthClient public interface IHealthClient
{ {
global::Grpc.Health.V1Alpha.HealthCheckResponse Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); global::Grpc.Health.V1.HealthCheckResponse Check(global::Grpc.Health.V1.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
global::Grpc.Health.V1Alpha.HealthCheckResponse Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, CallOptions options); global::Grpc.Health.V1.HealthCheckResponse Check(global::Grpc.Health.V1.HealthCheckRequest request, CallOptions options);
AsyncUnaryCall<global::Grpc.Health.V1Alpha.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1Alpha.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); AsyncUnaryCall<global::Grpc.Health.V1.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
AsyncUnaryCall<global::Grpc.Health.V1Alpha.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1Alpha.HealthCheckRequest request, CallOptions options); AsyncUnaryCall<global::Grpc.Health.V1.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1.HealthCheckRequest request, CallOptions options);
} }
// server-side interface // server-side interface
public interface IHealth public interface IHealth
{ {
Task<global::Grpc.Health.V1Alpha.HealthCheckResponse> Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, ServerCallContext context); Task<global::Grpc.Health.V1.HealthCheckResponse> Check(global::Grpc.Health.V1.HealthCheckRequest request, ServerCallContext context);
} }
// client stub // client stub
@ -49,22 +49,22 @@ namespace Grpc.Health.V1Alpha {
public HealthClient(Channel channel) : base(channel) public HealthClient(Channel channel) : base(channel)
{ {
} }
public global::Grpc.Health.V1Alpha.HealthCheckResponse Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) public global::Grpc.Health.V1.HealthCheckResponse Check(global::Grpc.Health.V1.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__Method_Check, new CallOptions(headers, deadline, cancellationToken)); var call = CreateCall(__Method_Check, new CallOptions(headers, deadline, cancellationToken));
return Calls.BlockingUnaryCall(call, request); return Calls.BlockingUnaryCall(call, request);
} }
public global::Grpc.Health.V1Alpha.HealthCheckResponse Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, CallOptions options) public global::Grpc.Health.V1.HealthCheckResponse Check(global::Grpc.Health.V1.HealthCheckRequest request, CallOptions options)
{ {
var call = CreateCall(__Method_Check, options); var call = CreateCall(__Method_Check, options);
return Calls.BlockingUnaryCall(call, request); return Calls.BlockingUnaryCall(call, request);
} }
public AsyncUnaryCall<global::Grpc.Health.V1Alpha.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1Alpha.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) public AsyncUnaryCall<global::Grpc.Health.V1.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1.HealthCheckRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__Method_Check, new CallOptions(headers, deadline, cancellationToken)); var call = CreateCall(__Method_Check, new CallOptions(headers, deadline, cancellationToken));
return Calls.AsyncUnaryCall(call, request); return Calls.AsyncUnaryCall(call, request);
} }
public AsyncUnaryCall<global::Grpc.Health.V1Alpha.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1Alpha.HealthCheckRequest request, CallOptions options) public AsyncUnaryCall<global::Grpc.Health.V1.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1.HealthCheckRequest request, CallOptions options)
{ {
var call = CreateCall(__Method_Check, options); var call = CreateCall(__Method_Check, options);
return Calls.AsyncUnaryCall(call, request); return Calls.AsyncUnaryCall(call, request);

@ -37,7 +37,7 @@ using System.Threading.Tasks;
using Grpc.Core; using Grpc.Core;
using Grpc.Core.Utils; using Grpc.Core.Utils;
using Grpc.Health.V1Alpha; using Grpc.Health.V1;
namespace Grpc.HealthCheck namespace Grpc.HealthCheck
{ {
@ -48,44 +48,42 @@ namespace Grpc.HealthCheck
/// <code> /// <code>
/// var serviceImpl = new HealthServiceImpl(); /// var serviceImpl = new HealthServiceImpl();
/// server = new Server(); /// server = new Server();
/// server.AddServiceDefinition(Grpc.Health.V1Alpha.Health.BindService(serviceImpl)); /// server.AddServiceDefinition(Grpc.Health.V1.Health.BindService(serviceImpl));
/// </code> /// </code>
/// </summary> /// </summary>
public class HealthServiceImpl : Grpc.Health.V1Alpha.Health.IHealth public class HealthServiceImpl : Grpc.Health.V1.Health.IHealth
{ {
private readonly object myLock = new object(); private readonly object myLock = new object();
private readonly Dictionary<Key, HealthCheckResponse.Types.ServingStatus> statusMap = private readonly Dictionary<string, HealthCheckResponse.Types.ServingStatus> statusMap =
new Dictionary<Key, HealthCheckResponse.Types.ServingStatus>(); new Dictionary<string, HealthCheckResponse.Types.ServingStatus>();
/// <summary> /// <summary>
/// Sets the health status for given host and service. /// Sets the health status for given service.
/// </summary> /// </summary>
/// <param name="host">The host. Cannot be null.</param>
/// <param name="service">The service. Cannot be null.</param> /// <param name="service">The service. Cannot be null.</param>
/// <param name="status">the health status</param> /// <param name="status">the health status</param>
public void SetStatus(string host, string service, HealthCheckResponse.Types.ServingStatus status) public void SetStatus(string service, HealthCheckResponse.Types.ServingStatus status)
{ {
lock (myLock) lock (myLock)
{ {
statusMap[CreateKey(host, service)] = status; statusMap[service] = status;
} }
} }
/// <summary> /// <summary>
/// Clears health status for given host and service. /// Clears health status for given service.
/// </summary> /// </summary>
/// <param name="host">The host. Cannot be null.</param>
/// <param name="service">The service. Cannot be null.</param> /// <param name="service">The service. Cannot be null.</param>
public void ClearStatus(string host, string service) public void ClearStatus(string service)
{ {
lock (myLock) lock (myLock)
{ {
statusMap.Remove(CreateKey(host, service)); statusMap.Remove(service);
} }
} }
/// <summary> /// <summary>
/// Clears statuses for all hosts and services. /// Clears statuses for all services.
/// </summary> /// </summary>
public void ClearAll() public void ClearAll()
{ {
@ -105,11 +103,10 @@ namespace Grpc.HealthCheck
{ {
lock (myLock) lock (myLock)
{ {
var host = request.Host;
var service = request.Service; var service = request.Service;
HealthCheckResponse.Types.ServingStatus status; HealthCheckResponse.Types.ServingStatus status;
if (!statusMap.TryGetValue(CreateKey(host, service), out status)) if (!statusMap.TryGetValue(service, out status))
{ {
// TODO(jtattermusch): returning specific status from server handler is not supported yet. // TODO(jtattermusch): returning specific status from server handler is not supported yet.
throw new RpcException(new Status(StatusCode.NotFound, "")); throw new RpcException(new Status(StatusCode.NotFound, ""));
@ -117,22 +114,5 @@ namespace Grpc.HealthCheck
return Task.FromResult(new HealthCheckResponse { Status = status }); return Task.FromResult(new HealthCheckResponse { Status = status });
} }
} }
private static Key CreateKey(string host, string service)
{
return new Key(host, service);
}
private struct Key
{
public Key(string host, string service)
{
this.Host = GrpcPreconditions.CheckNotNull(host);
this.Service = GrpcPreconditions.CheckNotNull(service);
}
readonly string Host;
readonly string Service;
}
} }
} }

@ -12,9 +12,9 @@ Beta
PREREQUISITES PREREQUISITES
-------------- --------------
- Windows: .NET Framework 4.5+, Visual Studio 2013 or 2015. - Windows: .NET Framework 4.5+, Visual Studio 2013 or 2015
- Linux: Mono 3.2.8+, MonoDevelop 5.9 with NuGet add-in installed. - Linux: Mono 4+, MonoDevelop 5.9+ (with NuGet add-in installed)
- Mac OS X: [homebrew][], Xamarin Studio with NuGet add-in installed. - Mac OS X: Xamarin Studio 5.9+
HOW TO USE HOW TO USE
-------------- --------------
@ -24,66 +24,28 @@ HOW TO USE
- Open Visual Studio and start a new project/solution. - Open Visual Studio and start a new project/solution.
- Add NuGet package `Grpc` as a dependency (Project options -> Manage NuGet Packages). - Add NuGet package `Grpc` as a dependency (Project options -> Manage NuGet Packages).
That will also pull all the transitive dependencies (including the native libraries that That will also pull all the transitive dependencies (including the gRPC native library that
gRPC C# is using internally). gRPC C# is using internally).
**Linux (Debian)** **Linux (Debian)**
- Add [Debian jessie-backports][] to your `sources.list` file. Example:
```sh
echo "deb http://http.debian.net/debian jessie-backports main" | \
sudo tee -a /etc/apt/sources.list
```
- Install the gRPC Debian package
```sh
sudo apt-get update
sudo apt-get install libgrpc0
```
- gRPC C# depends on native shared library `libgrpc_csharp_ext.so` (Unix flavor of grpc_csharp_ext.dll).
This library is not part of the base gRPC debian package and needs to be installed manually from
a `.deb` file. Download the debian package `libgrpc_csharp_ext` from corresponding gRPC release on GitHub
and install it using `dpkg`.
```sh
# choose version corresponding to the version of libgrpc you've installed.
wget https://github.com/grpc/grpc/releases/download/release-0_11_0/libgrpc-csharp-ext0_0.11.0.0-1_amd64.deb
dpkg -i libgrpc-csharp-ext0_0.11.0.0-1_amd64.deb
```
- Open MonoDevelop and start a new project/solution. - Open MonoDevelop and start a new project/solution.
- Add NuGet package `Grpc` as a dependency (Project -> Add NuGet packages). - Add NuGet package `Grpc` as a dependency (Project -> Add NuGet packages).
That will also pull all the transitive dependencies (including the gRPC native library that
gRPC C# is using internally).
- NOTE: Currently, there are no debian packages for the latest version Protocol Buffers compiler (_protoc_) - NOTE: gRPC C# doesn't have a good story yet for shipping precompiled Linux version of Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin. You can install them using [gRPC Linuxbrew instructions][].
and the gRPC _protoc_ plugin. You can install them using [gRPC Linuxbrew instructions][].
**Mac OS X** **Mac OS X**
- WARNING: As of now gRPC C# only works on 64bit version of Mono (because we don't compile
the native extension for C# in 32bit mode yet). That means your development experience
with Xamarin Studio on MacOS will not be great, as you won't be able to run your
code directly from Xamarin Studio (which requires 32bit version of Mono).
- Install [homebrew][]. Run the following command to install gRPC C# native dependencies.
```sh
$ curl -fsSL https://goo.gl/getgrpc | bash -
```
This will download and run the [gRPC install script][], then install the latest version of gRPC C core and native C# extension.
It also installs Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin for C#.
- Install 64-bit version of mono with command `brew install mono`.
- Open Xamarin Studio and start a new project/solution. - Open Xamarin Studio and start a new project/solution.
- Add NuGet package `Grpc` as a dependency (Project -> Add NuGet packages). - Add NuGet package `Grpc` as a dependency (Project -> Add NuGet packages).
That will also pull all the transitive dependencies (including the gRPC native library that
gRPC C# is using internally).
- *You will be able to build your project in Xamarin Studio, but to run or test it, - NOTE: gRPC C# doesn't have a good story yet for shipping precompiled Mac OS X version of Protocol Buffers compiler (_protoc_) and the gRPC _protoc_ plugin. You can install them using [gRPC Homebrew instructions][].
you will need to run it under 64-bit version of Mono.*
BUILD FROM SOURCE BUILD FROM SOURCE
----------------- -----------------
@ -94,7 +56,7 @@ If you are a user of gRPC C#, go to Usage section above.
**Windows** **Windows**
- The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution. You can - The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution. You can
either build the native solution in `vsprojects/grpc.sln` from Visual Studio manually, or you can use either build the native solution in `vsprojects/grpc_csharp_ext.sln` from Visual Studio manually, or you can use
a convenience batch script that builds everything for you. a convenience batch script that builds everything for you.
``` ```
@ -102,30 +64,28 @@ If you are a user of gRPC C#, go to Usage section above.
> buildall.bat > buildall.bat
``` ```
- Open Grpc.sln using Visual Studio. NuGet dependencies will be restored - Open Grpc.sln using Visual Studio.
upon build (you need to have NuGet add-in installed).
**Linux** **Linux**
- The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution:
```sh ```sh
$ sudo apt-get install mono-devel # from the gRPC repository root
$ sudo apt-get install nunit nunit-console $ make CONFIG=dbg grpc_csharp_ext
``` ```
You can use older versions of MonoDevelop, but then you might need to restore - Use MonoDevelop to open the solution Grpc.sln
NuGet dependencies manually (by `nuget restore`), because older versions of MonoDevelop
don't support NuGet add-in. **Mac OS X**
- The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution.
- Compile and install the gRPC C# extension library (that will be used via
P/Invoke from C#).
```sh ```sh
$ make grpc_csharp_ext # from the gRPC repository root
$ sudo make install_grpc_csharp_ext $ tools/run_tests/run_tests.py -c dbg -l csharp --build_only
``` ```
- Use MonoDevelop to open the solution Grpc.sln - Use Xamarin Studio to open the solution Grpc.sln
- Build the solution & run all the tests from test view.
RUNNING TESTS RUNNING TESTS
------------- -------------
@ -135,17 +95,9 @@ gRPC C# is using NUnit as the testing framework.
Under Visual Studio, make sure NUnit test adapter is installed (under "Extensions and Updates"). Under Visual Studio, make sure NUnit test adapter is installed (under "Extensions and Updates").
Then you should be able to run all the tests using Test Explorer. Then you should be able to run all the tests using Test Explorer.
Under Monodevelop, make sure you installed "NUnit support" in Add-in manager. Under Monodevelop or Xamarin Studio, make sure you installed "NUnit support" in Add-in manager.
Then you should be able to run all the test from the Test View. Then you should be able to run all the test from the Test View.
After building the solution, you can also run the tests from command line
using nunit-console tool.
```sh
# from Grpc.Core.Test/bin/Debug directory
$ nunit-console Grpc.Core.Tests.dll
```
gRPC team uses a Python script to simplify facilitate running tests for gRPC team uses a Python script to simplify facilitate running tests for
different languages. different languages.
@ -176,27 +128,15 @@ CONTENTS
- Grpc.IntegrationTesting: - Grpc.IntegrationTesting:
Cross-language gRPC implementation testing (interop testing). Cross-language gRPC implementation testing (interop testing).
TROUBLESHOOTING THE NATIVE DEPENDENCY
--------------- ---------------
### Problem: Unable to load DLL 'grpc_csharp_ext.dll' Internally, gRPC C# uses a native library written in C (gRPC C core) and invokes its functionality via P/Invoke. `grpc_csharp_ext` library is a native extension library that facilitates this by wrapping some C core API into a form that's more digestible for P/Invoke.
Internally, gRPC C# uses a native library written in C (gRPC C core) and invokes its functionality via P/Invoke. `grpc_csharp_ext` library is a native extension library that facilitates this by wrapping some C core API into a form that's more digestible for P/Invoke. If you get the above error, it means that the native dependencies could not be located by the C# runtime (or they are incompatible with the current runtime, so they could not be loaded). The solution to this is environment specific.
- If you are developing on Windows in Visual Studio, the `grpc_csharp_ext.dll` that is shipped by gRPC nuget packages should be automatically copied to your build destination folder once you build. By adjusting project properties in your VS project file, you can influence which exact configuration of `grpc_csharp_ext.dll` will be used (based on VS version, bitness, debug/release configuration).
- If you are running your application that is using gRPC on Windows machine that doesn't have Visual Studio installed, you might need to install [Visual C++ 2013 redistributable](https://www.microsoft.com/en-us/download/details.aspx?id=40784) that contains some system .dll libraries that `grpc_csharp_ext.dll` depends on (see #905 for more details).
- On Linux (or Docker), you need to first install gRPC C core and `libgrpc_csharp_ext.so` shared libraries.
See [How to Use](#how-to-use) section for details how to install it.
Installation on a machine where your application is going to be deployed is no different.
- On Mac, you need to first install gRPC C core and `libgrpc_csharp_ext.dylib` shared libraries using Homebrew. See above for installation instruction.
Installation on a machine where your application is going to be deployed is no different.
- Possible cause for the problem is that the `grpc_csharp_ext` library is installed, but it has different bitness (32/64bit) than your C# runtime (in case you are using mono) or C# application. Prior to version 0.13, installing `grpc_csharp_ext` was required to make gRPC work on Linux and MacOS. Starting with version 0.13, we have improved the packaging story significantly and precompiled versions of the native library for all supported platforms are now shipped with the NuGet package. Just installing the `Grpc` NuGet package should be the only step needed to use gRPC C#, regardless of your platform (Windows, Linux or Mac) and the bitness (32 or 64bit).
[gRPC Linuxbrew instructions]:https://github.com/grpc/homebrew-grpc#quick-install-linux [gRPC Linuxbrew instructions]:https://github.com/grpc/homebrew-grpc#quick-install-linux
[gRPC Homebrew instructions]:https://github.com/grpc/homebrew-grpc#quick-install-linux
[homebrew]:http://brew.sh [homebrew]:http://brew.sh
[gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install [gRPC install script]:https://raw.githubusercontent.com/grpc/homebrew-grpc/master/scripts/install
[grpc.io]: http://www.grpc.io/docs/installation/csharp.html [grpc.io]: http://www.grpc.io/docs/installation/csharp.html

@ -42,7 +42,7 @@ $PROTOC --plugin=$PLUGIN --csharp_out=$EXAMPLES_DIR --grpc_out=$EXAMPLES_DIR \
-I src/proto/math src/proto/math/math.proto -I src/proto/math src/proto/math/math.proto
$PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_DIR \ $PROTOC --plugin=$PLUGIN --csharp_out=$HEALTHCHECK_DIR --grpc_out=$HEALTHCHECK_DIR \
-I src/proto/grpc/health/v1alpha src/proto/grpc/health/v1alpha/health.proto -I src/proto/grpc/health/v1 src/proto/grpc/health/v1/health.proto
$PROTOC --plugin=$PLUGIN --csharp_out=$TESTING_DIR --grpc_out=$TESTING_DIR \ $PROTOC --plugin=$PLUGIN --csharp_out=$TESTING_DIR --grpc_out=$TESTING_DIR \
-I . src/proto/grpc/testing/{control,empty,messages,payloads,services,stats,test}.proto -I . src/proto/grpc/testing/{control,empty,messages,payloads,services,stats,test}.proto

@ -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,9 +38,9 @@ var grpc = require('../');
var _ = require('lodash'); var _ = require('lodash');
var health_proto = grpc.load(__dirname + var health_proto = grpc.load(__dirname +
'/../../proto/grpc/health/v1alpha/health.proto'); '/../../proto/grpc/health/v1/health.proto');
var HealthClient = health_proto.grpc.health.v1alpha.Health; var HealthClient = health_proto.grpc.health.v1.Health;
function HealthImplementation(statusMap) { function HealthImplementation(statusMap) {
this.statusMap = _.clone(statusMap); this.statusMap = _.clone(statusMap);

@ -29,12 +29,11 @@
syntax = "proto3"; syntax = "proto3";
package grpc.health.v1alpha; package grpc.health.v1;
option csharp_namespace = "Grpc.Health.V1Alpha"; option csharp_namespace = "Grpc.Health.V1";
message HealthCheckRequest { message HealthCheckRequest {
string host = 1; string service = 1;
string service = 2;
} }
message HealthCheckResponse { message HealthCheckResponse {

@ -100,3 +100,5 @@ def update_setup_arguments(setup_arguments):
sys.stderr.write( sys.stderr.write(
'could not write precompiled extension to directory: {} -> {}\n' 'could not write precompiled extension to directory: {} -> {}\n'
.format(url, target_path)) .format(url, target_path))
return
setup_arguments['package_data']['grpc._cython'].append('cygrpc.so')

@ -1,4 +1,4 @@
# 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

@ -1,4 +1,4 @@
// 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
@ -29,7 +29,7 @@
syntax = "proto3"; syntax = "proto3";
package grpc.health.v1alpha; package grpc.health.v1;
message HealthCheckRequest { message HealthCheckRequest {
string service = 1; string service = 1;

@ -1,4 +1,4 @@
# 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
@ -33,7 +33,7 @@ import abc
import enum import enum
import threading import threading
from grpc.health.v1alpha import health_pb2 from grpc.health.v1 import health_pb2
@enum.unique @enum.unique
@ -64,7 +64,7 @@ class _HealthServicer(health_pb2.EarlyAdopterHealthServicer):
def set(service, status): def set(service, status):
if not isinstance(status, HealthStatus): if not isinstance(status, HealthStatus):
raise TypeError('expected grpc.health.v1alpha.health.HealthStatus ' raise TypeError('expected grpc.health.v1.health.HealthStatus '
'for argument `status` but got {}'.format(status)) 'for argument `status` but got {}'.format(status))
with self._server_status_lock: with self._server_status_lock:
self._server_status[service] = status self._server_status[service] = status

@ -7,7 +7,7 @@ AllCops:
- 'bin/apis/**/*' - 'bin/apis/**/*'
- 'bin/math.rb' - 'bin/math.rb'
- 'bin/math_services.rb' - 'bin/math_services.rb'
- 'pb/grpc/health/v1alpha/*' - 'pb/grpc/health/v1/*'
- 'pb/test/**/*' - 'pb/test/**/*'
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:

@ -269,20 +269,9 @@ static void Init_grpc_time_consts() {
id_tv_nsec = rb_intern("tv_nsec"); id_tv_nsec = rb_intern("tv_nsec");
} }
/* static void grpc_rb_shutdown(void) {
TODO: find an alternative to ruby_vm_at_exit that is ok in Ruby 2.0 where
RUBY_TYPED_FREE_IMMEDIATELY is not defined.
At the moment, registering a function using ruby_vm_at_exit segfaults in Ruby
2.0. This is not an issue with the gRPC handler. More likely, this was an
in issue with 2.0 that got resolved in 2.1 and has not been backported.
*/
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
static void grpc_rb_shutdown(ruby_vm_t *vm) {
(void)vm;
grpc_shutdown(); grpc_shutdown();
} }
#endif
/* Initialize the GRPC module structs */ /* Initialize the GRPC module structs */
@ -300,18 +289,30 @@ VALUE sym_code = Qundef;
VALUE sym_details = Qundef; VALUE sym_details = Qundef;
VALUE sym_metadata = Qundef; VALUE sym_metadata = Qundef;
static gpr_once g_once_init = GPR_ONCE_INIT;
static void grpc_ruby_once_init() {
grpc_init();
atexit(grpc_rb_shutdown);
}
void Init_grpc_c() { void Init_grpc_c() {
if (!grpc_rb_load_core()) { if (!grpc_rb_load_core()) {
rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core"); rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core");
return; return;
} }
grpc_init(); /* ruby_vm_at_exit doesn't seem to be working. It would crash once every
* blue moon, and some users are getting it repeatedly. See the discussions
/* TODO: find alternative to ruby_vm_at_exit that is ok in Ruby 2.0 */ * - https://github.com/grpc/grpc/pull/5337
#ifdef RUBY_TYPED_FREE_IMMEDIATELY * - https://bugs.ruby-lang.org/issues/12095
ruby_vm_at_exit(grpc_rb_shutdown); *
#endif * In order to still be able to handle the (unlikely) situation where the
* extension is loaded by a first Ruby VM that is subsequently destroyed,
* then loaded again by another VM within the same process, we need to
* schedule our initialization and destruction only once.
*/
gpr_once_init(&g_once_init, grpc_ruby_once_init);
grpc_rb_mGRPC = rb_define_module("GRPC"); grpc_rb_mGRPC = rb_define_module("GRPC");
grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core"); grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core");

@ -1,4 +1,4 @@
# 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
@ -27,7 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'grpc' require 'grpc/grpc'
# GRPC contains the General RPC module. # GRPC contains the General RPC module.
module GRPC module GRPC

@ -1,4 +1,4 @@
# 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
@ -27,7 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'grpc' require 'grpc/grpc'
# GRPC contains the General RPC module. # GRPC contains the General RPC module.
module GRPC module GRPC

@ -11,7 +11,7 @@ The code is is generated using the protoc (> 3.0.0.alpha.1) and the
grpc_ruby_plugin. These must be installed to regenerate the IDL defined grpc_ruby_plugin. These must be installed to regenerate the IDL defined
classes, but that's not necessary just to use them. classes, but that's not necessary just to use them.
health_check/v1alpha health_check/v1
-------------------- --------------------
This package defines the surface of a simple health check service that gRPC This package defines the surface of a simple health check service that gRPC
@ -20,7 +20,7 @@ re-generate the surface.
```bash ```bash
$ # (from this directory) $ # (from this directory)
$ protoc -I ../../proto ../../proto/grpc/health/v1alpha/health.proto \ $ protoc -I ../../proto ../../proto/grpc/health/v1/health.proto \
--grpc_out=. \ --grpc_out=. \
--ruby_out=. \ --ruby_out=. \
--plugin=protoc-gen-grpc=`which grpc_ruby_plugin` --plugin=protoc-gen-grpc=`which grpc_ruby_plugin`

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# 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,7 +35,7 @@ cd $(dirname $0)/../../..
PROTOC=bins/opt/protobuf/protoc PROTOC=bins/opt/protobuf/protoc
PLUGIN=protoc-gen-grpc=bins/opt/grpc_ruby_plugin PLUGIN=protoc-gen-grpc=bins/opt/grpc_ruby_plugin
$PROTOC -I src/proto src/proto/grpc/health/v1alpha/health.proto \ $PROTOC -I src/proto src/proto/grpc/health/v1/health.proto \
--grpc_out=src/ruby/pb \ --grpc_out=src/ruby/pb \
--ruby_out=src/ruby/pb \ --ruby_out=src/ruby/pb \
--plugin=$PLUGIN --plugin=$PLUGIN

@ -1,4 +1,4 @@
# 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
@ -28,7 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'grpc' require 'grpc'
require 'grpc/health/v1alpha/health_services' require 'grpc/health/v1/health_services'
require 'thread' require 'thread'
module Grpc module Grpc
@ -36,9 +36,9 @@ module Grpc
# service. # service.
module Health module Health
# Checker is implementation of the schema-specified health checking service. # Checker is implementation of the schema-specified health checking service.
class Checker < V1alpha::Health::Service class Checker < V1::Health::Service
StatusCodes = GRPC::Core::StatusCodes StatusCodes = GRPC::Core::StatusCodes
HealthCheckResponse = V1alpha::HealthCheckResponse HealthCheckResponse = V1::HealthCheckResponse
# Initializes the statuses of participating services # Initializes the statuses of participating services
def initialize def initialize
@ -50,20 +50,20 @@ module Grpc
def check(req, _call) def check(req, _call)
status = nil status = nil
@status_mutex.synchronize do @status_mutex.synchronize do
status = @statuses["#{req.host}/#{req.service}"] status = @statuses["#{req.service}"]
end end
fail GRPC::BadStatus, StatusCodes::NOT_FOUND if status.nil? fail GRPC::BadStatus, StatusCodes::NOT_FOUND if status.nil?
HealthCheckResponse.new(status: status) HealthCheckResponse.new(status: status)
end end
# Adds the health status for a given host and service. # Adds the health status for a given service.
def add_status(host, service, status) def add_status(service, status)
@status_mutex.synchronize { @statuses["#{host}/#{service}"] = status } @status_mutex.synchronize { @statuses["#{service}"] = status }
end end
# Clears the status for the given host or service. # Clears the status for the given service.
def clear_status(host, service) def clear_status(service)
@status_mutex.synchronize { @statuses.delete("#{host}/#{service}") } @status_mutex.synchronize { @statuses.delete("#{service}") }
end end
# Clears alls the statuses. # Clears alls the statuses.

@ -0,0 +1,28 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: grpc/health/v1/health.proto
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "grpc.health.v1.HealthCheckRequest" do
optional :service, :string, 1
end
add_message "grpc.health.v1.HealthCheckResponse" do
optional :status, :enum, 1, "grpc.health.v1.HealthCheckResponse.ServingStatus"
end
add_enum "grpc.health.v1.HealthCheckResponse.ServingStatus" do
value :UNKNOWN, 0
value :SERVING, 1
value :NOT_SERVING, 2
end
end
module Grpc
module Health
module V1
HealthCheckRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.health.v1.HealthCheckRequest").msgclass
HealthCheckResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.health.v1.HealthCheckResponse").msgclass
HealthCheckResponse::ServingStatus = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.health.v1.HealthCheckResponse.ServingStatus").enummodule
end
end
end

@ -1,12 +1,12 @@
# Generated by the protocol buffer compiler. DO NOT EDIT! # Generated by the protocol buffer compiler. DO NOT EDIT!
# Source: grpc/health/v1alpha/health.proto for package 'grpc.health.v1alpha' # Source: grpc/health/v1/health.proto for package 'grpc.health.v1'
require 'grpc' require 'grpc'
require 'grpc/health/v1alpha/health' require 'grpc/health/v1/health'
module Grpc module Grpc
module Health module Health
module V1alpha module V1
module Health module Health
# TODO: add proto service documentation here # TODO: add proto service documentation here
@ -16,7 +16,7 @@ module Grpc
self.marshal_class_method = :encode self.marshal_class_method = :encode
self.unmarshal_class_method = :decode self.unmarshal_class_method = :decode
self.service_name = 'grpc.health.v1alpha.Health' self.service_name = 'grpc.health.v1.Health'
rpc :Check, HealthCheckRequest, HealthCheckResponse rpc :Check, HealthCheckRequest, HealthCheckResponse
end end

@ -1,29 +0,0 @@
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: grpc/health/v1alpha/health.proto
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "grpc.health.v1alpha.HealthCheckRequest" do
optional :host, :string, 1
optional :service, :string, 2
end
add_message "grpc.health.v1alpha.HealthCheckResponse" do
optional :status, :enum, 1, "grpc.health.v1alpha.HealthCheckResponse.ServingStatus"
end
add_enum "grpc.health.v1alpha.HealthCheckResponse.ServingStatus" do
value :UNKNOWN, 0
value :SERVING, 1
value :NOT_SERVING, 2
end
end
module Grpc
module Health
module V1alpha
HealthCheckRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.health.v1alpha.HealthCheckRequest").msgclass
HealthCheckResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.health.v1alpha.HealthCheckResponse").msgclass
HealthCheckResponse::ServingStatus = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.health.v1alpha.HealthCheckResponse.ServingStatus").enummodule
end
end
end

@ -28,7 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
require 'grpc' require 'grpc'
require 'grpc/health/v1alpha/health' require 'grpc/health/v1/health'
require 'grpc/health/checker' require 'grpc/health/checker'
require 'open3' require 'open3'
require 'tmpdir' require 'tmpdir'
@ -43,7 +43,7 @@ describe 'Health protobuf code generation' do
skip 'protoc || grpc_ruby_plugin missing, cannot verify health code-gen' skip 'protoc || grpc_ruby_plugin missing, cannot verify health code-gen'
else else
it 'should already be loaded indirectly i.e, used by the other specs' do it 'should already be loaded indirectly i.e, used by the other specs' do
expect(require('grpc/health/v1alpha/health_services')).to be(false) expect(require('grpc/health/v1/health_services')).to be(false)
end end
it 'should have the same content as created by code generation' do it 'should have the same content as created by code generation' do
@ -52,7 +52,7 @@ describe 'Health protobuf code generation' do
# Get the current content # Get the current content
service_path = File.join(root_dir, 'ruby', 'pb', 'grpc', service_path = File.join(root_dir, 'ruby', 'pb', 'grpc',
'health', 'v1alpha', 'health_services.rb') 'health', 'v1', 'health_services.rb')
want = nil want = nil
File.open(service_path) { |f| want = f.read } File.open(service_path) { |f| want = f.read }
@ -61,12 +61,12 @@ describe 'Health protobuf code generation' do
plugin = plugin.strip plugin = plugin.strip
got = nil got = nil
Dir.mktmpdir do |tmp_dir| Dir.mktmpdir do |tmp_dir|
gen_out = File.join(tmp_dir, 'grpc', 'health', 'v1alpha', gen_out = File.join(tmp_dir, 'grpc', 'health', 'v1',
'health_services.rb') 'health_services.rb')
pid = spawn( pid = spawn(
'protoc', 'protoc',
'-I.', '-I.',
'grpc/health/v1alpha/health.proto', 'grpc/health/v1/health.proto',
"--grpc_out=#{tmp_dir}", "--grpc_out=#{tmp_dir}",
"--plugin=protoc-gen-grpc=#{plugin}", "--plugin=protoc-gen-grpc=#{plugin}",
chdir: pb_dir) chdir: pb_dir)
@ -81,27 +81,17 @@ end
describe Grpc::Health::Checker do describe Grpc::Health::Checker do
StatusCodes = GRPC::Core::StatusCodes StatusCodes = GRPC::Core::StatusCodes
ServingStatus = Grpc::Health::V1alpha::HealthCheckResponse::ServingStatus ServingStatus = Grpc::Health::V1::HealthCheckResponse::ServingStatus
HCResp = Grpc::Health::V1alpha::HealthCheckResponse HCResp = Grpc::Health::V1::HealthCheckResponse
HCReq = Grpc::Health::V1alpha::HealthCheckRequest HCReq = Grpc::Health::V1::HealthCheckRequest
success_tests = success_tests =
[ [
{ {
desc: 'neither host or service are specified', desc: 'the service is not specified',
host: '',
service: '' service: ''
}, { }, {
desc: 'only the host is specified', desc: 'the service is specified',
host: 'test-fake-host',
service: ''
}, {
desc: 'the host and service are specified',
host: 'test-fake-host',
service: 'fake-service-1' service: 'fake-service-1'
}, {
desc: 'only the service is specified',
host: '',
service: 'fake-service-2'
} }
] ]
@ -114,9 +104,8 @@ describe Grpc::Health::Checker do
context 'method `add_status` and `check`' do context 'method `add_status` and `check`' do
success_tests.each do |t| success_tests.each do |t|
it "should succeed when #{t[:desc]}" do it "should succeed when #{t[:desc]}" do
subject.add_status(t[:host], t[:service], ServingStatus::NOT_SERVING) subject.add_status(t[:service], ServingStatus::NOT_SERVING)
got = subject.check(HCReq.new(host: t[:host], service: t[:service]), got = subject.check(HCReq.new(service: t[:service]), nil)
nil)
want = HCResp.new(status: ServingStatus::NOT_SERVING) want = HCResp.new(status: ServingStatus::NOT_SERVING)
expect(got).to eq(want) expect(got).to eq(want)
end end
@ -127,7 +116,7 @@ describe Grpc::Health::Checker do
success_tests.each do |t| success_tests.each do |t|
it "should fail with NOT_FOUND when #{t[:desc]}" do it "should fail with NOT_FOUND when #{t[:desc]}" do
blk = proc do blk = proc do
subject.check(HCReq.new(host: t[:host], service: t[:service]), nil) subject.check(HCReq.new(service: t[:service]), nil)
end end
expected_msg = /#{StatusCodes::NOT_FOUND}/ expected_msg = /#{StatusCodes::NOT_FOUND}/
expect(&blk).to raise_error GRPC::BadStatus, expected_msg expect(&blk).to raise_error GRPC::BadStatus, expected_msg
@ -138,16 +127,14 @@ describe Grpc::Health::Checker do
context 'method `clear_status`' do context 'method `clear_status`' do
success_tests.each do |t| success_tests.each do |t|
it "should fail after clearing status when #{t[:desc]}" do it "should fail after clearing status when #{t[:desc]}" do
subject.add_status(t[:host], t[:service], ServingStatus::NOT_SERVING) subject.add_status(t[:service], ServingStatus::NOT_SERVING)
got = subject.check(HCReq.new(host: t[:host], service: t[:service]), got = subject.check(HCReq.new(service: t[:service]), nil)
nil)
want = HCResp.new(status: ServingStatus::NOT_SERVING) want = HCResp.new(status: ServingStatus::NOT_SERVING)
expect(got).to eq(want) expect(got).to eq(want)
subject.clear_status(t[:host], t[:service]) subject.clear_status(t[:service])
blk = proc do blk = proc do
subject.check(HCReq.new(host: t[:host], service: t[:service]), subject.check(HCReq.new(service: t[:service]), nil)
nil)
end end
expected_msg = /#{StatusCodes::NOT_FOUND}/ expected_msg = /#{StatusCodes::NOT_FOUND}/
expect(&blk).to raise_error GRPC::BadStatus, expected_msg expect(&blk).to raise_error GRPC::BadStatus, expected_msg
@ -158,9 +145,8 @@ describe Grpc::Health::Checker do
context 'method `clear_all`' do context 'method `clear_all`' do
it 'should return NOT_FOUND after being invoked' do it 'should return NOT_FOUND after being invoked' do
success_tests.each do |t| success_tests.each do |t|
subject.add_status(t[:host], t[:service], ServingStatus::NOT_SERVING) subject.add_status(t[:service], ServingStatus::NOT_SERVING)
got = subject.check(HCReq.new(host: t[:host], service: t[:service]), got = subject.check(HCReq.new(service: t[:service]), nil)
nil)
want = HCResp.new(status: ServingStatus::NOT_SERVING) want = HCResp.new(status: ServingStatus::NOT_SERVING)
expect(got).to eq(want) expect(got).to eq(want)
end end
@ -169,7 +155,7 @@ describe Grpc::Health::Checker do
success_tests.each do |t| success_tests.each do |t|
blk = proc do blk = proc do
subject.check(HCReq.new(host: t[:host], service: t[:service]), nil) subject.check(HCReq.new(service: t[:service]), nil)
end end
expected_msg = /#{StatusCodes::NOT_FOUND}/ expected_msg = /#{StatusCodes::NOT_FOUND}/
expect(&blk).to raise_error GRPC::BadStatus, expected_msg expect(&blk).to raise_error GRPC::BadStatus, expected_msg
@ -203,7 +189,7 @@ describe Grpc::Health::Checker do
it 'should receive the correct status', server: true do it 'should receive the correct status', server: true do
@srv.handle(subject) @srv.handle(subject)
subject.add_status('', '', ServingStatus::NOT_SERVING) subject.add_status('', ServingStatus::NOT_SERVING)
t = Thread.new { @srv.run } t = Thread.new { @srv.run }
@srv.wait_till_running @srv.wait_till_running
@ -221,7 +207,7 @@ describe Grpc::Health::Checker do
@srv.wait_till_running @srv.wait_till_running
blk = proc do blk = proc do
stub = CheckerStub.new(@host, :this_channel_is_insecure, **@client_opts) stub = CheckerStub.new(@host, :this_channel_is_insecure, **@client_opts)
stub.check(HCReq.new(host: 'unknown', service: 'unknown')) stub.check(HCReq.new(service: 'unknown'))
end end
expected_msg = /#{StatusCodes::NOT_FOUND}/ expected_msg = /#{StatusCodes::NOT_FOUND}/
expect(&blk).to raise_error GRPC::BadStatus, expected_msg expect(&blk).to raise_error GRPC::BadStatus, expected_msg

@ -38,7 +38,22 @@
% endfor % endfor
% endif % endif
% endfor % endfor
, $ext_shared, , -Wall -Werror -std=c11 ${"\\"} , $ext_shared, , -Wall -Werror ${"\\"}
-Wno-parentheses-equality -Wno-unused-value -std=c11 ${"\\"}
-fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN ${"\\"} -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN ${"\\"}
-D_HAS_EXCEPTIONS=0 -DNOMINMAX) -D_HAS_EXCEPTIONS=0 -DNOMINMAX)
PHP_ADD_BUILD_DIR($ext_builddir/src/php/ext/grpc)
<%
dirs = {}
for lib in libs:
if lib.name in php_config_m4.get('deps', []):
for source in lib.src:
dirs[source[:source.rfind('/')]] = 1
dirs = dirs.keys()
dirs.sort()
%>
% for dir in dirs:
PHP_ADD_BUILD_DIR($ext_builddir/${dir})
% endfor
fi fi

@ -12,7 +12,7 @@
<email>grpc-packages@google.com</email> <email>grpc-packages@google.com</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<%! from time import strftime %><date>${"%Y-%m-%d" | strftime}</date> <date>2016-02-24</date>
<time>16:06:07</time> <time>16:06:07</time>
<version> <version>
<release>0.8.0</release> <release>0.8.0</release>
@ -149,7 +149,7 @@
<release>beta</release> <release>beta</release>
<api>beta</api> <api>beta</api>
</stability> </stability>
<date>${"%Y-%m-%d" | strftime}</date> <date>2016-02-24</date>
<license>BSD</license> <license>BSD</license>
<notes> <notes>
- Simplify gRPC PHP installation #4517 - Simplify gRPC PHP installation #4517

@ -8,6 +8,7 @@
"language": tgt.language, "language": tgt.language,
"platforms": tgt.platforms, "platforms": tgt.platforms,
"ci_platforms": tgt.ci_platforms, "ci_platforms": tgt.ci_platforms,
"gtest": tgt.gtest,
"exclude_configs": tgt.get("exclude_configs", []), "exclude_configs": tgt.get("exclude_configs", []),
"args": [], "args": [],
"flaky": tgt.flaky, "flaky": tgt.flaky,

@ -253,8 +253,7 @@ static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *arg, bool success) {
} }
static grpc_connected_subchannel *connect_subchannel(grpc_subchannel *c) { static grpc_connected_subchannel *connect_subchannel(grpc_subchannel *c) {
gpr_mu mu; gpr_mu *mu;
gpr_mu_init(&mu);
grpc_pollset *pollset = gpr_malloc(grpc_pollset_size()); grpc_pollset *pollset = gpr_malloc(grpc_pollset_size());
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_pollset_init(pollset, &mu); grpc_pollset_init(pollset, &mu);
@ -264,22 +263,21 @@ static grpc_connected_subchannel *connect_subchannel(grpc_subchannel *c) {
&g_state, &g_state,
grpc_closure_create(state_changed, c)); grpc_closure_create(state_changed, c));
grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(&mu); gpr_mu_lock(mu);
while (g_state != GRPC_CHANNEL_READY) { while (g_state != GRPC_CHANNEL_READY) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), grpc_pollset_work(&exec_ctx, pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1)); GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1));
gpr_mu_unlock(&mu); gpr_mu_unlock(mu);
grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(&mu); gpr_mu_lock(mu);
} }
grpc_pollset_shutdown(&exec_ctx, pollset, grpc_pollset_shutdown(&exec_ctx, pollset,
grpc_closure_create(destroy_pollset, pollset)); grpc_closure_create(destroy_pollset, pollset));
grpc_pollset_set_destroy(g_interested_parties); grpc_pollset_set_destroy(g_interested_parties);
gpr_mu_unlock(&mu); gpr_mu_unlock(mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_free(pollset); gpr_free(pollset);
gpr_mu_destroy(&mu);
return grpc_subchannel_get_connected_subchannel(c); return grpc_subchannel_get_connected_subchannel(c);
} }

@ -47,7 +47,7 @@
static int g_done = 0; static int g_done = 0;
static grpc_httpcli_context g_context; static grpc_httpcli_context g_context;
static gpr_mu g_mu; static gpr_mu *g_mu;
static grpc_pollset *g_pollset; static grpc_pollset *g_pollset;
static gpr_timespec n_seconds_time(int seconds) { static gpr_timespec n_seconds_time(int seconds) {
@ -64,10 +64,10 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg,
GPR_ASSERT(response->status == 200); GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect)); GPR_ASSERT(response->body_length == strlen(expect));
GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length)); GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
g_done = 1; g_done = 1;
grpc_pollset_kick(g_pollset, NULL); grpc_pollset_kick(g_pollset, NULL);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
} }
static void test_get(int port) { static void test_get(int port) {
@ -88,16 +88,16 @@ static void test_get(int port) {
grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15), grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15),
on_finish, (void *)42); on_finish, (void *)42);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
while (!g_done) { while (!g_done) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20)); gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20));
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
gpr_free(host); gpr_free(host);
} }
@ -119,16 +119,16 @@ static void test_post(int port) {
grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5, grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5,
n_seconds_time(15), on_finish, (void *)42); n_seconds_time(15), on_finish, (void *)42);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
while (!g_done) { while (!g_done) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20)); gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20));
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
gpr_free(host); gpr_free(host);
} }
@ -177,7 +177,6 @@ int main(int argc, char **argv) {
grpc_init(); grpc_init();
grpc_httpcli_context_init(&g_context); grpc_httpcli_context_init(&g_context);
g_pollset = gpr_malloc(grpc_pollset_size()); g_pollset = gpr_malloc(grpc_pollset_size());
gpr_mu_init(&g_mu);
grpc_pollset_init(g_pollset, &g_mu); grpc_pollset_init(g_pollset, &g_mu);
test_get(port); test_get(port);
@ -189,7 +188,6 @@ int main(int argc, char **argv) {
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown(); grpc_shutdown();
gpr_mu_destroy(&g_mu);
gpr_free(g_pollset); gpr_free(g_pollset);
gpr_subprocess_destroy(server); gpr_subprocess_destroy(server);

@ -47,7 +47,7 @@
static int g_done = 0; static int g_done = 0;
static grpc_httpcli_context g_context; static grpc_httpcli_context g_context;
static gpr_mu g_mu; static gpr_mu *g_mu;
static grpc_pollset *g_pollset; static grpc_pollset *g_pollset;
static gpr_timespec n_seconds_time(int seconds) { static gpr_timespec n_seconds_time(int seconds) {
@ -64,10 +64,10 @@ static void on_finish(grpc_exec_ctx *exec_ctx, void *arg,
GPR_ASSERT(response->status == 200); GPR_ASSERT(response->status == 200);
GPR_ASSERT(response->body_length == strlen(expect)); GPR_ASSERT(response->body_length == strlen(expect));
GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length)); GPR_ASSERT(0 == memcmp(expect, response->body, response->body_length));
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
g_done = 1; g_done = 1;
grpc_pollset_kick(g_pollset, NULL); grpc_pollset_kick(g_pollset, NULL);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
} }
static void test_get(int port) { static void test_get(int port) {
@ -89,16 +89,16 @@ static void test_get(int port) {
grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15), grpc_httpcli_get(&exec_ctx, &g_context, g_pollset, &req, n_seconds_time(15),
on_finish, (void *)42); on_finish, (void *)42);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
while (!g_done) { while (!g_done) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20)); gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20));
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
gpr_free(host); gpr_free(host);
} }
@ -121,16 +121,16 @@ static void test_post(int port) {
grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5, grpc_httpcli_post(&exec_ctx, &g_context, g_pollset, &req, "hello", 5,
n_seconds_time(15), on_finish, (void *)42); n_seconds_time(15), on_finish, (void *)42);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
while (!g_done) { while (!g_done) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20)); gpr_now(GPR_CLOCK_MONOTONIC), n_seconds_time(20));
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
gpr_free(host); gpr_free(host);
} }
@ -192,7 +192,6 @@ int main(int argc, char **argv) {
grpc_shutdown(); grpc_shutdown();
gpr_free(g_pollset); gpr_free(g_pollset);
gpr_mu_destroy(&g_mu);
gpr_subprocess_destroy(server); gpr_subprocess_destroy(server);

@ -42,7 +42,7 @@
#include "test/core/iomgr/endpoint_tests.h" #include "test/core/iomgr/endpoint_tests.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
static gpr_mu g_mu; static gpr_mu *g_mu;
static grpc_pollset *g_pollset; static grpc_pollset *g_pollset;
static void clean_up(void) {} static void clean_up(void) {}
@ -73,17 +73,15 @@ static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, bool success) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
grpc_closure destroyed; grpc_closure destroyed;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_mu_init(&g_mu);
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_init(); grpc_init();
g_pollset = gpr_malloc(grpc_pollset_size()); g_pollset = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(g_pollset, &g_mu); grpc_pollset_init(g_pollset, &g_mu);
grpc_endpoint_tests(configs[0], g_pollset, &g_mu); grpc_endpoint_tests(configs[0], g_pollset, g_mu);
grpc_closure_init(&destroyed, destroy_pollset, g_pollset); grpc_closure_init(&destroyed, destroy_pollset, g_pollset);
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed); grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown(); grpc_shutdown();
gpr_mu_destroy(&g_mu);
gpr_free(g_pollset); gpr_free(g_pollset);
return 0; return 0;

@ -53,7 +53,7 @@
#include "src/core/iomgr/iomgr.h" #include "src/core/iomgr/iomgr.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
static gpr_mu g_mu; static gpr_mu *g_mu;
static grpc_pollset *g_pollset; static grpc_pollset *g_pollset;
/* buffer size used to send and receive data. /* buffer size used to send and receive data.
@ -182,10 +182,10 @@ static void listen_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg /*server */,
grpc_fd_orphan(exec_ctx, sv->em_fd, NULL, NULL, "b"); grpc_fd_orphan(exec_ctx, sv->em_fd, NULL, NULL, "b");
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
sv->done = 1; sv->done = 1;
grpc_pollset_kick(g_pollset, NULL); grpc_pollset_kick(g_pollset, NULL);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
} }
/* Called when a new TCP connection request arrives in the listening port. */ /* Called when a new TCP connection request arrives in the listening port. */
@ -252,18 +252,18 @@ static int server_start(grpc_exec_ctx *exec_ctx, server *sv) {
/* Wait and shutdown a sever. */ /* Wait and shutdown a sever. */
static void server_wait_and_shutdown(server *sv) { static void server_wait_and_shutdown(server *sv) {
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
while (!sv->done) { while (!sv->done) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC)); gpr_inf_future(GPR_CLOCK_MONOTONIC));
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
} }
/* ===An upload client to test notify_on_write=== */ /* ===An upload client to test notify_on_write=== */
@ -310,9 +310,9 @@ static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */
ssize_t write_once = 0; ssize_t write_once = 0;
if (!success) { if (!success) {
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
client_session_shutdown_cb(exec_ctx, arg, 1); client_session_shutdown_cb(exec_ctx, arg, 1);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
return; return;
} }
@ -322,7 +322,7 @@ static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */
} while (write_once > 0); } while (write_once > 0);
if (errno == EAGAIN) { if (errno == EAGAIN) {
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
if (cl->client_write_cnt < CLIENT_TOTAL_WRITE_CNT) { if (cl->client_write_cnt < CLIENT_TOTAL_WRITE_CNT) {
cl->write_closure.cb = client_session_write; cl->write_closure.cb = client_session_write;
cl->write_closure.cb_arg = cl; cl->write_closure.cb_arg = cl;
@ -331,7 +331,7 @@ static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */
} else { } else {
client_session_shutdown_cb(exec_ctx, arg, 1); client_session_shutdown_cb(exec_ctx, arg, 1);
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
} else { } else {
gpr_log(GPR_ERROR, "unknown errno %s", strerror(errno)); gpr_log(GPR_ERROR, "unknown errno %s", strerror(errno));
abort(); abort();
@ -367,18 +367,18 @@ static void client_start(grpc_exec_ctx *exec_ctx, client *cl, int port) {
/* Wait for the signal to shutdown a client. */ /* Wait for the signal to shutdown a client. */
static void client_wait_and_shutdown(client *cl) { static void client_wait_and_shutdown(client *cl) {
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
while (!cl->done) { while (!cl->done) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC)); gpr_inf_future(GPR_CLOCK_MONOTONIC));
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
} }
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
} }
/* Test grpc_fd. Start an upload server and client, upload a stream of /* Test grpc_fd. Start an upload server and client, upload a stream of
@ -413,20 +413,20 @@ static void first_read_callback(grpc_exec_ctx *exec_ctx,
void *arg /* fd_change_data */, bool success) { void *arg /* fd_change_data */, bool success) {
fd_change_data *fdc = arg; fd_change_data *fdc = arg;
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
fdc->cb_that_ran = first_read_callback; fdc->cb_that_ran = first_read_callback;
grpc_pollset_kick(g_pollset, NULL); grpc_pollset_kick(g_pollset, NULL);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
} }
static void second_read_callback(grpc_exec_ctx *exec_ctx, static void second_read_callback(grpc_exec_ctx *exec_ctx,
void *arg /* fd_change_data */, bool success) { void *arg /* fd_change_data */, bool success) {
fd_change_data *fdc = arg; fd_change_data *fdc = arg;
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
fdc->cb_that_ran = second_read_callback; fdc->cb_that_ran = second_read_callback;
grpc_pollset_kick(g_pollset, NULL); grpc_pollset_kick(g_pollset, NULL);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
} }
/* Test that changing the callback we use for notify_on_read actually works. /* Test that changing the callback we use for notify_on_read actually works.
@ -468,18 +468,18 @@ static void test_grpc_fd_change(void) {
GPR_ASSERT(result == 1); GPR_ASSERT(result == 1);
/* And now wait for it to run. */ /* And now wait for it to run. */
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
while (a.cb_that_ran == NULL) { while (a.cb_that_ran == NULL) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC)); gpr_inf_future(GPR_CLOCK_MONOTONIC));
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
} }
GPR_ASSERT(a.cb_that_ran == first_read_callback); GPR_ASSERT(a.cb_that_ran == first_read_callback);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
/* And drain the socket so we can generate a new read edge */ /* And drain the socket so we can generate a new read edge */
result = read(sv[0], &data, 1); result = read(sv[0], &data, 1);
@ -492,19 +492,19 @@ static void test_grpc_fd_change(void) {
result = write(sv[1], &data, 1); result = write(sv[1], &data, 1);
GPR_ASSERT(result == 1); GPR_ASSERT(result == 1);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
while (b.cb_that_ran == NULL) { while (b.cb_that_ran == NULL) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
grpc_pollset_work(&exec_ctx, g_pollset, &worker, grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC)); gpr_inf_future(GPR_CLOCK_MONOTONIC));
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(&g_mu); gpr_mu_lock(g_mu);
} }
/* Except now we verify that second_read_callback ran instead */ /* Except now we verify that second_read_callback ran instead */
GPR_ASSERT(b.cb_that_ran == second_read_callback); GPR_ASSERT(b.cb_that_ran == second_read_callback);
gpr_mu_unlock(&g_mu); gpr_mu_unlock(g_mu);
grpc_fd_orphan(&exec_ctx, em_fd, NULL, NULL, "d"); grpc_fd_orphan(&exec_ctx, em_fd, NULL, NULL, "d");
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
@ -522,7 +522,6 @@ int main(int argc, char **argv) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
grpc_iomgr_init(); grpc_iomgr_init();
gpr_mu_init(&g_mu);
g_pollset = gpr_malloc(grpc_pollset_size()); g_pollset = gpr_malloc(grpc_pollset_size());
grpc_pollset_init(g_pollset, &g_mu); grpc_pollset_init(g_pollset, &g_mu);
test_grpc_fd(); test_grpc_fd();
@ -531,7 +530,6 @@ int main(int argc, char **argv) {
grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed); grpc_pollset_shutdown(&exec_ctx, g_pollset, &destroyed);
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
gpr_free(g_pollset); gpr_free(g_pollset);
gpr_mu_destroy(&g_mu);
grpc_iomgr_shutdown(); grpc_iomgr_shutdown();
return 0; return 0;
} }

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

Loading…
Cancel
Save