Merge branch 'master' into fd_rw_atm_closure

pull/9683/head
Sree Kuchibhotla 8 years ago
commit 1d15f24327
  1. 1
      BUILD
  2. 343
      CMakeLists.txt
  3. 2
      Makefile
  4. 1
      build.yaml
  5. 2
      include/grpc/impl/codegen/grpc_types.h
  6. 6
      src/core/ext/client_channel/http_proxy.c
  7. 2
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  8. 28
      src/core/lib/iomgr/combiner.c
  9. 23
      src/core/lib/iomgr/combiner.h
  10. 2
      src/core/lib/iomgr/resource_quota.c
  11. 331
      src/core/lib/iomgr/tcp_server_posix.c
  12. 8
      src/csharp/Grpc.Core.Tests/project.json
  13. 2
      src/csharp/Grpc.Core/NativeDeps.Windows.targets
  14. 8
      src/csharp/Grpc.Examples.MathClient/project.json
  15. 8
      src/csharp/Grpc.Examples.MathServer/project.json
  16. 8
      src/csharp/Grpc.Examples.Tests/project.json
  17. 8
      src/csharp/Grpc.HealthCheck.Tests/project.json
  18. 8
      src/csharp/Grpc.IntegrationTesting.Client/project.json
  19. 8
      src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json
  20. 8
      src/csharp/Grpc.IntegrationTesting.Server/project.json
  21. 8
      src/csharp/Grpc.IntegrationTesting.StressClient/project.json
  22. 8
      src/csharp/Grpc.IntegrationTesting/project.json
  23. 8
      src/csharp/Grpc.Reflection.Tests/project.json
  24. 18
      src/csharp/README.md
  25. 59
      src/csharp/buildall.bat
  26. 35
      src/python/grpcio_tests/tests/protoc_plugin/_split_definitions_test.py
  27. 13
      templates/CMakeLists.txt.template
  28. 8
      templates/src/csharp/build_options.include
  29. 27
      test/core/handshake/client_ssl.c
  30. 8
      test/core/iomgr/combiner_test.c
  31. 294
      test/core/iomgr/tcp_server_posix_test.c
  32. 2
      tools/doxygen/Doxyfile.c++
  33. 2
      tools/doxygen/Doxyfile.c++.internal
  34. 16
      tools/run_tests/artifacts/artifact_targets.py
  35. 10
      tools/run_tests/artifacts/build_artifact_csharp.bat
  36. 3
      tools/run_tests/generated/sources_and_headers.json
  37. 13
      tools/run_tests/helper_scripts/pre_build_csharp.bat
  38. 8
      tools/run_tests/run_microbenchmark.py
  39. 27
      tools/run_tests/run_tests.py
  40. 2
      vsprojects/vcxproj/grpc++/grpc++.vcxproj
  41. 6
      vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters

@ -140,6 +140,7 @@ grpc_cc_library(
"grpc++_base", "grpc++_base",
"grpc++_codegen_base", "grpc++_codegen_base",
"grpc++_codegen_base_src", "grpc++_codegen_base_src",
"grpc++_codegen_proto",
], ],
) )

@ -700,6 +700,17 @@ add_library(gpr
src/core/lib/support/wrap_memcpy.c src/core/lib/support/wrap_memcpy.c
) )
if(WIN32 AND MSVC)
set_target_properties(gpr PROPERTIES COMPILE_PDB_NAME "gpr"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gpr.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(gpr target_include_directories(gpr
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -778,6 +789,17 @@ add_library(gpr_test_util
test/core/util/test_config.c test/core/util/test_config.c
) )
if(WIN32 AND MSVC)
set_target_properties(gpr_test_util PROPERTIES COMPILE_PDB_NAME "gpr_test_util"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gpr_test_util.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(gpr_test_util target_include_directories(gpr_test_util
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -1026,6 +1048,17 @@ add_library(grpc
src/core/plugin_registry/grpc_plugin_registry.c src/core/plugin_registry/grpc_plugin_registry.c
) )
if(WIN32 AND MSVC)
set_target_properties(grpc PROPERTIES COMPILE_PDB_NAME "grpc"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc target_include_directories(grpc
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -1293,6 +1326,17 @@ add_library(grpc_cronet
src/core/plugin_registry/grpc_cronet_plugin_registry.c src/core/plugin_registry/grpc_cronet_plugin_registry.c
) )
if(WIN32 AND MSVC)
set_target_properties(grpc_cronet PROPERTIES COMPILE_PDB_NAME "grpc_cronet"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_cronet.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc_cronet target_include_directories(grpc_cronet
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -1504,6 +1548,17 @@ add_library(grpc_test_util
src/core/lib/transport/transport_op_string.c src/core/lib/transport/transport_op_string.c
) )
if(WIN32 AND MSVC)
set_target_properties(grpc_test_util PROPERTIES COMPILE_PDB_NAME "grpc_test_util"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_test_util.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc_test_util target_include_directories(grpc_test_util
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -1582,6 +1637,17 @@ add_library(grpc_test_util_unsecure
test/core/util/slice_splitter.c test/core/util/slice_splitter.c
) )
if(WIN32 AND MSVC)
set_target_properties(grpc_test_util_unsecure PROPERTIES COMPILE_PDB_NAME "grpc_test_util_unsecure"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_test_util_unsecure.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc_test_util_unsecure target_include_directories(grpc_test_util_unsecure
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -1804,6 +1870,17 @@ add_library(grpc_unsecure
src/core/plugin_registry/grpc_unsecure_plugin_registry.c src/core/plugin_registry/grpc_unsecure_plugin_registry.c
) )
if(WIN32 AND MSVC)
set_target_properties(grpc_unsecure PROPERTIES COMPILE_PDB_NAME "grpc_unsecure"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_unsecure.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc_unsecure target_include_directories(grpc_unsecure
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -1875,6 +1952,17 @@ add_library(reconnect_server
test/core/util/reconnect_server.c test/core/util/reconnect_server.c
) )
if(WIN32 AND MSVC)
set_target_properties(reconnect_server PROPERTIES COMPILE_PDB_NAME "reconnect_server"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/reconnect_server.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(reconnect_server target_include_directories(reconnect_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -1904,6 +1992,17 @@ add_library(test_tcp_server
test/core/util/test_tcp_server.c test/core/util/test_tcp_server.c
) )
if(WIN32 AND MSVC)
set_target_properties(test_tcp_server PROPERTIES COMPILE_PDB_NAME "test_tcp_server"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/test_tcp_server.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(test_tcp_server target_include_directories(test_tcp_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -1967,6 +2066,17 @@ add_library(grpc++
src/cpp/codegen/codegen_init.cc src/cpp/codegen/codegen_init.cc
) )
if(WIN32 AND MSVC)
set_target_properties(grpc++ PROPERTIES COMPILE_PDB_NAME "grpc++"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc++ target_include_directories(grpc++
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -2080,6 +2190,8 @@ foreach(_hdr
include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_generic.h
include/grpc/impl/codegen/sync_posix.h include/grpc/impl/codegen/sync_posix.h
include/grpc/impl/codegen/sync_windows.h include/grpc/impl/codegen/sync_windows.h
include/grpc++/impl/codegen/proto_utils.h
include/grpc++/impl/codegen/config_protobuf.h
) )
string(REPLACE "include/" "" _path ${_hdr}) string(REPLACE "include/" "" _path ${_hdr})
get_filename_component(_path ${_path} PATH) get_filename_component(_path ${_path} PATH)
@ -2317,6 +2429,17 @@ add_library(grpc++_cronet
third_party/nanopb/pb_encode.c third_party/nanopb/pb_encode.c
) )
if(WIN32 AND MSVC)
set_target_properties(grpc++_cronet PROPERTIES COMPILE_PDB_NAME "grpc++_cronet"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_cronet.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc++_cronet target_include_directories(grpc++_cronet
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -2468,6 +2591,17 @@ add_library(grpc++_proto_reflection_desc_db
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h
) )
if(WIN32 AND MSVC)
set_target_properties(grpc++_proto_reflection_desc_db PROPERTIES COMPILE_PDB_NAME "grpc++_proto_reflection_desc_db"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_proto_reflection_desc_db.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/reflection/v1alpha/reflection.proto src/proto/grpc/reflection/v1alpha/reflection.proto
) )
@ -2513,6 +2647,17 @@ add_library(grpc++_reflection
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h
) )
if(WIN32 AND MSVC)
set_target_properties(grpc++_reflection PROPERTIES COMPILE_PDB_NAME "grpc++_reflection"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_reflection.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/reflection/v1alpha/reflection.proto src/proto/grpc/reflection/v1alpha/reflection.proto
) )
@ -2560,6 +2705,17 @@ add_library(grpc++_test
src/cpp/test/server_context_test_spouse.cc src/cpp/test/server_context_test_spouse.cc
) )
if(WIN32 AND MSVC)
set_target_properties(grpc++_test PROPERTIES COMPILE_PDB_NAME "grpc++_test"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_test.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc++_test target_include_directories(grpc++_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -2589,6 +2745,17 @@ add_library(grpc++_test_config
test/cpp/util/test_config_cc.cc test/cpp/util/test_config_cc.cc
) )
if(WIN32 AND MSVC)
set_target_properties(grpc++_test_config PROPERTIES COMPILE_PDB_NAME "grpc++_test_config"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_test_config.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc++_test_config target_include_directories(grpc++_test_config
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -2635,6 +2802,17 @@ add_library(grpc++_test_util
src/cpp/codegen/codegen_init.cc src/cpp/codegen/codegen_init.cc
) )
if(WIN32 AND MSVC)
set_target_properties(grpc++_test_util PROPERTIES COMPILE_PDB_NAME "grpc++_test_util"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_test_util.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/testing/echo_messages.proto src/proto/grpc/testing/echo_messages.proto
) )
@ -2765,6 +2943,17 @@ add_library(grpc++_unsecure
src/cpp/codegen/codegen_init.cc src/cpp/codegen/codegen_init.cc
) )
if(WIN32 AND MSVC)
set_target_properties(grpc++_unsecure PROPERTIES COMPILE_PDB_NAME "grpc++_unsecure"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_unsecure.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc++_unsecure target_include_directories(grpc++_unsecure
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -2909,6 +3098,17 @@ add_library(grpc_cli_libs
${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h ${_gRPC_PROTO_GENS_DIR}/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h
) )
if(WIN32 AND MSVC)
set_target_properties(grpc_cli_libs PROPERTIES COMPILE_PDB_NAME "grpc_cli_libs"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_cli_libs.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/reflection/v1alpha/reflection.proto src/proto/grpc/reflection/v1alpha/reflection.proto
) )
@ -2956,6 +3156,17 @@ add_library(grpc_plugin_support
src/compiler/ruby_generator.cc src/compiler/ruby_generator.cc
) )
if(WIN32 AND MSVC)
set_target_properties(grpc_plugin_support PROPERTIES COMPILE_PDB_NAME "grpc_plugin_support"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_plugin_support.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc_plugin_support target_include_directories(grpc_plugin_support
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -3012,6 +3223,17 @@ add_library(http2_client_main
test/cpp/interop/http2_client.cc test/cpp/interop/http2_client.cc
) )
if(WIN32 AND MSVC)
set_target_properties(http2_client_main PROPERTIES COMPILE_PDB_NAME "http2_client_main"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/http2_client_main.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/testing/empty.proto src/proto/grpc/testing/empty.proto
) )
@ -3058,6 +3280,17 @@ add_library(interop_client_helper
test/cpp/interop/client_helper.cc test/cpp/interop/client_helper.cc
) )
if(WIN32 AND MSVC)
set_target_properties(interop_client_helper PROPERTIES COMPILE_PDB_NAME "interop_client_helper"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_client_helper.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/testing/messages.proto src/proto/grpc/testing/messages.proto
) )
@ -3107,6 +3340,17 @@ add_library(interop_client_main
test/cpp/interop/interop_client.cc test/cpp/interop/interop_client.cc
) )
if(WIN32 AND MSVC)
set_target_properties(interop_client_main PROPERTIES COMPILE_PDB_NAME "interop_client_main"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_client_main.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/testing/empty.proto src/proto/grpc/testing/empty.proto
) )
@ -3152,6 +3396,17 @@ add_library(interop_server_helper
test/cpp/interop/server_helper.cc test/cpp/interop/server_helper.cc
) )
if(WIN32 AND MSVC)
set_target_properties(interop_server_helper PROPERTIES COMPILE_PDB_NAME "interop_server_helper"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_server_helper.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(interop_server_helper target_include_directories(interop_server_helper
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -3197,6 +3452,17 @@ add_library(interop_server_lib
test/cpp/interop/interop_server.cc test/cpp/interop/interop_server.cc
) )
if(WIN32 AND MSVC)
set_target_properties(interop_server_lib PROPERTIES COMPILE_PDB_NAME "interop_server_lib"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_server_lib.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/testing/empty.proto src/proto/grpc/testing/empty.proto
) )
@ -3242,6 +3508,17 @@ add_library(interop_server_main
test/cpp/interop/interop_server_bootstrap.cc test/cpp/interop/interop_server_bootstrap.cc
) )
if(WIN32 AND MSVC)
set_target_properties(interop_server_main PROPERTIES COMPILE_PDB_NAME "interop_server_main"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_server_main.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(interop_server_main target_include_directories(interop_server_main
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -3300,6 +3577,17 @@ add_library(qps
test/cpp/util/benchmark_config.cc test/cpp/util/benchmark_config.cc
) )
if(WIN32 AND MSVC)
set_target_properties(qps PROPERTIES COMPILE_PDB_NAME "qps"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qps.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(
src/proto/grpc/testing/messages.proto src/proto/grpc/testing/messages.proto
) )
@ -3345,6 +3633,17 @@ add_library(grpc_csharp_ext SHARED
src/csharp/ext/grpc_csharp_ext.c src/csharp/ext/grpc_csharp_ext.c
) )
if(WIN32 AND MSVC)
set_target_properties(grpc_csharp_ext PROPERTIES COMPILE_PDB_NAME "grpc_csharp_ext"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_csharp_ext.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(grpc_csharp_ext target_include_directories(grpc_csharp_ext
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -3379,6 +3678,17 @@ add_library(bad_client_test
test/core/bad_client/bad_client.c test/core/bad_client/bad_client.c
) )
if(WIN32 AND MSVC)
set_target_properties(bad_client_test PROPERTIES COMPILE_PDB_NAME "bad_client_test"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bad_client_test.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(bad_client_test target_include_directories(bad_client_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -3407,6 +3717,17 @@ add_library(bad_ssl_test_server
test/core/bad_ssl/server_common.c test/core/bad_ssl/server_common.c
) )
if(WIN32 AND MSVC)
set_target_properties(bad_ssl_test_server PROPERTIES COMPILE_PDB_NAME "bad_ssl_test_server"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bad_ssl_test_server.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(bad_ssl_test_server target_include_directories(bad_ssl_test_server
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -3485,6 +3806,17 @@ add_library(end2end_tests
test/core/end2end/tests/write_buffering_at_end.c test/core/end2end/tests/write_buffering_at_end.c
) )
if(WIN32 AND MSVC)
set_target_properties(end2end_tests PROPERTIES COMPILE_PDB_NAME "end2end_tests"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/end2end_tests.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(end2end_tests target_include_directories(end2end_tests
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@ -3563,6 +3895,17 @@ add_library(end2end_nosec_tests
test/core/end2end/tests/write_buffering_at_end.c test/core/end2end/tests/write_buffering_at_end.c
) )
if(WIN32 AND MSVC)
set_target_properties(end2end_nosec_tests PROPERTIES COMPILE_PDB_NAME "end2end_nosec_tests"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
if (gRPC_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/end2end_nosec_tests.pdb
DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL
)
endif()
endif()
target_include_directories(end2end_nosec_tests target_include_directories(end2end_nosec_tests
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}

@ -3960,6 +3960,8 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_generic.h \
include/grpc/impl/codegen/sync_posix.h \ include/grpc/impl/codegen/sync_posix.h \
include/grpc/impl/codegen/sync_windows.h \ include/grpc/impl/codegen/sync_windows.h \
include/grpc++/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/config_protobuf.h \
LIBGRPC++_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_SRC)))) LIBGRPC++_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_SRC))))

@ -1088,6 +1088,7 @@ libs:
filegroups: filegroups:
- grpc++_base - grpc++_base
- grpc++_codegen_base - grpc++_codegen_base
- grpc++_codegen_proto
- grpc++_codegen_base_src - grpc++_codegen_base_src
secure: check secure: check
vs_project_guid: '{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}' vs_project_guid: '{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}'

@ -222,6 +222,8 @@ typedef struct {
/** If non-zero, a pointer to a buffer pool (use grpc_resource_quota_arg_vtable /** If non-zero, a pointer to a buffer pool (use grpc_resource_quota_arg_vtable
to fetch an appropriate pointer arg vtable) */ to fetch an appropriate pointer arg vtable) */
#define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota" #define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota"
/** If non-zero, expand wildcard addresses to a list of local addresses. */
#define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs"
/** Service config data in JSON form. Not intended for use outside of tests. */ /** Service config data in JSON form. Not intended for use outside of tests. */
#define GRPC_ARG_SERVICE_CONFIG "grpc.service_config" #define GRPC_ARG_SERVICE_CONFIG "grpc.service_config"
/** LB policy name. */ /** LB policy name. */

@ -87,6 +87,12 @@ static bool proxy_mapper_map_name(grpc_exec_ctx* exec_ctx,
if (uri != NULL) grpc_uri_destroy(uri); if (uri != NULL) grpc_uri_destroy(uri);
return false; return false;
} }
if (strcmp(uri->scheme, "unix") == 0) {
gpr_log(GPR_INFO, "not using proxy for Unix domain socket '%s'",
server_uri);
grpc_uri_destroy(uri);
return false;
}
grpc_arg new_arg; grpc_arg new_arg;
new_arg.key = GRPC_ARG_HTTP_CONNECT_SERVER; new_arg.key = GRPC_ARG_HTTP_CONNECT_SERVER;
new_arg.type = GRPC_ARG_STRING; new_arg.type = GRPC_ARG_STRING;

@ -168,7 +168,7 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx,
grpc_chttp2_stream_map_destroy(&t->stream_map); grpc_chttp2_stream_map_destroy(&t->stream_map);
grpc_connectivity_state_destroy(exec_ctx, &t->channel_callback.state_tracker); grpc_connectivity_state_destroy(exec_ctx, &t->channel_callback.state_tracker);
grpc_combiner_destroy(exec_ctx, t->combiner); GRPC_COMBINER_UNREF(exec_ctx, t->combiner, "chttp2_transport");
cancel_pings(exec_ctx, t, GRPC_ERROR_CREATE("Transport destroyed")); cancel_pings(exec_ctx, t, GRPC_ERROR_CREATE("Transport destroyed"));

@ -72,6 +72,7 @@ struct grpc_combiner {
bool final_list_covered_by_poller; bool final_list_covered_by_poller;
grpc_closure_list final_list; grpc_closure_list final_list;
grpc_closure offload; grpc_closure offload;
gpr_refcount refs;
}; };
static void combiner_exec_uncovered(grpc_exec_ctx *exec_ctx, static void combiner_exec_uncovered(grpc_exec_ctx *exec_ctx,
@ -126,6 +127,7 @@ static bool is_covered_by_poller(grpc_combiner *lock) {
grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue) { grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue) {
grpc_combiner *lock = gpr_malloc(sizeof(*lock)); grpc_combiner *lock = gpr_malloc(sizeof(*lock));
gpr_ref_init(&lock->refs, 1);
lock->next_combiner_on_this_exec_ctx = NULL; lock->next_combiner_on_this_exec_ctx = NULL;
lock->time_to_execute_final_list = false; lock->time_to_execute_final_list = false;
lock->optional_workqueue = optional_workqueue; lock->optional_workqueue = optional_workqueue;
@ -152,7 +154,7 @@ static void really_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
gpr_free(lock); gpr_free(lock);
} }
void grpc_combiner_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { static void start_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_UNORPHANED); gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -STATE_UNORPHANED);
GRPC_COMBINER_TRACE(gpr_log( GRPC_COMBINER_TRACE(gpr_log(
GPR_DEBUG, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state)); GPR_DEBUG, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state));
@ -161,6 +163,30 @@ void grpc_combiner_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) {
} }
} }
#ifdef GRPC_COMBINER_REFCOUNT_DEBUG
#define GRPC_COMBINER_DEBUG_SPAM(op, delta) \
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, \
"combiner[%p] %s %" PRIdPTR " --> %" PRIdPTR " %s", lock, (op), \
gpr_atm_no_barrier_load(&lock->refs.count), \
gpr_atm_no_barrier_load(&lock->refs.count) + (delta), reason);
#else
#define GRPC_COMBINER_DEBUG_SPAM(op, delta)
#endif
void grpc_combiner_unref(grpc_exec_ctx *exec_ctx,
grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM("UNREF", -1);
if (gpr_unref(&lock->refs)) {
start_destroy(exec_ctx, lock);
}
}
grpc_combiner *grpc_combiner_ref(grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS) {
GRPC_COMBINER_DEBUG_SPAM(" REF", 1);
gpr_ref(&lock->refs);
return lock;
}
static void push_last_on_exec_ctx(grpc_exec_ctx *exec_ctx, static void push_last_on_exec_ctx(grpc_exec_ctx *exec_ctx,
grpc_combiner *lock) { grpc_combiner *lock) {
lock->next_combiner_on_this_exec_ctx = NULL; lock->next_combiner_on_this_exec_ctx = NULL;

@ -48,8 +48,27 @@
// Initialize the lock, with an optional workqueue to shift load to when // Initialize the lock, with an optional workqueue to shift load to when
// necessary // necessary
grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue); grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue);
// Destroy the lock
void grpc_combiner_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock); //#define GRPC_COMBINER_REFCOUNT_DEBUG
#ifdef GRPC_COMBINER_REFCOUNT_DEBUG
#define GRPC_COMBINER_DEBUG_ARGS \
, const char *file, int line, const char *reason
#define GRPC_COMBINER_REF(combiner, reason) \
grpc_combiner_ref((combiner), __FILE__, __LINE__, (reason))
#define GRPC_COMBINER_UNREF(exec_ctx, combiner, reason) \
grpc_combiner_unref((exec_ctx), (combiner), __FILE__, __LINE__, (reason))
#else
#define GRPC_COMBINER_DEBUG_ARGS
#define GRPC_COMBINER_REF(combiner, reason) grpc_combiner_ref((combiner))
#define GRPC_COMBINER_UNREF(exec_ctx, combiner, reason) \
grpc_combiner_unref((exec_ctx), (combiner))
#endif
// Ref/unref the lock, for when we're sharing the lock ownership
// Prefer to use the macros above
grpc_combiner *grpc_combiner_ref(grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS);
void grpc_combiner_unref(grpc_exec_ctx *exec_ctx,
grpc_combiner *lock GRPC_COMBINER_DEBUG_ARGS);
// Fetch a scheduler to schedule closures against // Fetch a scheduler to schedule closures against
grpc_closure_scheduler *grpc_combiner_scheduler(grpc_combiner *lock, grpc_closure_scheduler *grpc_combiner_scheduler(grpc_combiner *lock,
bool covered_by_poller); bool covered_by_poller);

@ -599,7 +599,7 @@ grpc_resource_quota *grpc_resource_quota_create(const char *name) {
void grpc_resource_quota_unref_internal(grpc_exec_ctx *exec_ctx, void grpc_resource_quota_unref_internal(grpc_exec_ctx *exec_ctx,
grpc_resource_quota *resource_quota) { grpc_resource_quota *resource_quota) {
if (gpr_unref(&resource_quota->refs)) { if (gpr_unref(&resource_quota->refs)) {
grpc_combiner_destroy(exec_ctx, resource_quota->combiner); GRPC_COMBINER_UNREF(exec_ctx, resource_quota->combiner, "resource_quota");
gpr_free(resource_quota->name); gpr_free(resource_quota->name);
gpr_free(resource_quota); gpr_free(resource_quota);
} }

@ -44,6 +44,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <ifaddrs.h>
#include <limits.h> #include <limits.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
@ -115,6 +116,8 @@ struct grpc_tcp_server {
bool shutdown; bool shutdown;
/* use SO_REUSEPORT */ /* use SO_REUSEPORT */
bool so_reuseport; bool so_reuseport;
/* expand wildcard addresses to a list of all local addresses */
bool expand_wildcard_addrs;
/* linked list of server ports */ /* linked list of server ports */
grpc_tcp_listener *head; grpc_tcp_listener *head;
@ -161,6 +164,7 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server)); grpc_tcp_server *s = gpr_malloc(sizeof(grpc_tcp_server));
s->so_reuseport = has_so_reuseport; s->so_reuseport = has_so_reuseport;
s->resource_quota = grpc_resource_quota_create(NULL); s->resource_quota = grpc_resource_quota_create(NULL);
s->expand_wildcard_addrs = false;
for (size_t i = 0; i < (args == NULL ? 0 : args->num_args); i++) { for (size_t i = 0; i < (args == NULL ? 0 : args->num_args); i++) {
if (0 == strcmp(GRPC_ARG_ALLOW_REUSEPORT, args->args[i].key)) { if (0 == strcmp(GRPC_ARG_ALLOW_REUSEPORT, args->args[i].key)) {
if (args->args[i].type == GRPC_ARG_INTEGER) { if (args->args[i].type == GRPC_ARG_INTEGER) {
@ -183,6 +187,15 @@ grpc_error *grpc_tcp_server_create(grpc_exec_ctx *exec_ctx,
return GRPC_ERROR_CREATE(GRPC_ARG_RESOURCE_QUOTA return GRPC_ERROR_CREATE(GRPC_ARG_RESOURCE_QUOTA
" must be a pointer to a buffer pool"); " must be a pointer to a buffer pool");
} }
} else if (0 == strcmp(GRPC_ARG_EXPAND_WILDCARD_ADDRS, args->args[i].key)) {
if (args->args[i].type == GRPC_ARG_INTEGER) {
s->expand_wildcard_addrs = (args->args[i].value.integer != 0);
} else {
grpc_resource_quota_unref_internal(exec_ctx, s->resource_quota);
gpr_free(s);
return GRPC_ERROR_CREATE(GRPC_ARG_EXPAND_WILDCARD_ADDRS
" must be an integer");
}
} }
} }
gpr_ref_init(&s->refs, 1); gpr_ref_init(&s->refs, 1);
@ -504,9 +517,224 @@ static grpc_error *add_socket_to_server(grpc_tcp_server *s, int fd,
return err; return err;
} }
/* Insert count new listeners after listener. Every new listener will have the /* If successful, add a listener to s for addr, set *dsmode for the socket, and
same listen address as listener (SO_REUSEPORT must be enabled). Every new return the *listener. */
listener is a sibling of listener. */ static grpc_error *add_addr_to_server(grpc_tcp_server *s,
const grpc_resolved_address *addr,
unsigned port_index, unsigned fd_index,
grpc_dualstack_mode *dsmode,
grpc_tcp_listener **listener) {
grpc_resolved_address addr4_copy;
int fd;
grpc_error *err =
grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, dsmode, &fd);
if (err != GRPC_ERROR_NONE) {
return err;
}
if (*dsmode == GRPC_DSMODE_IPV4 &&
grpc_sockaddr_is_v4mapped(addr, &addr4_copy)) {
addr = &addr4_copy;
}
return add_socket_to_server(s, fd, addr, port_index, fd_index, listener);
}
/* Bind to "::" to get a port number not used by any address. */
static grpc_error *get_unused_port(int *port) {
grpc_resolved_address wild;
grpc_sockaddr_make_wildcard6(0, &wild);
grpc_dualstack_mode dsmode;
int fd;
grpc_error *err =
grpc_create_dualstack_socket(&wild, SOCK_STREAM, 0, &dsmode, &fd);
if (err != GRPC_ERROR_NONE) {
return err;
}
if (dsmode == GRPC_DSMODE_IPV4) {
grpc_sockaddr_make_wildcard4(0, &wild);
}
if (bind(fd, (const struct sockaddr *)wild.addr, (socklen_t)wild.len) != 0) {
err = GRPC_OS_ERROR(errno, "bind");
close(fd);
return err;
}
if (getsockname(fd, (struct sockaddr *)wild.addr, (socklen_t *)&wild.len) !=
0) {
err = GRPC_OS_ERROR(errno, "getsockname");
close(fd);
return err;
}
close(fd);
*port = grpc_sockaddr_get_port(&wild);
return *port <= 0 ? GRPC_ERROR_CREATE("Bad port") : GRPC_ERROR_NONE;
}
/* Return the listener in s with address addr or NULL. */
static grpc_tcp_listener *find_listener_with_addr(grpc_tcp_server *s,
grpc_resolved_address *addr) {
grpc_tcp_listener *l;
gpr_mu_lock(&s->mu);
for (l = s->head; l != NULL; l = l->next) {
if (l->addr.len != addr->len) {
continue;
}
if (memcmp(l->addr.addr, addr->addr, addr->len) == 0) {
break;
}
}
gpr_mu_unlock(&s->mu);
return l;
}
/* Get all addresses assigned to network interfaces on the machine and create a
listener for each. requested_port is the port to use for every listener, or 0
to select one random port that will be used for every listener. Set *out_port
to the port selected. Return GRPC_ERROR_NONE only if all listeners were
added. */
static grpc_error *add_all_local_addrs_to_server(grpc_tcp_server *s,
unsigned port_index,
int requested_port,
int *out_port) {
struct ifaddrs *ifa = NULL;
struct ifaddrs *ifa_it;
unsigned fd_index = 0;
grpc_tcp_listener *sp = NULL;
grpc_error *err = GRPC_ERROR_NONE;
if (requested_port == 0) {
/* Note: There could be a race where some local addrs can listen on the
selected port and some can't. The sane way to handle this would be to
retry by recreating the whole grpc_tcp_server. Backing out individual
listeners and orphaning the FDs looks like too much trouble. */
if ((err = get_unused_port(&requested_port)) != GRPC_ERROR_NONE) {
return err;
} else if (requested_port <= 0) {
return GRPC_ERROR_CREATE("Bad get_unused_port()");
}
gpr_log(GPR_DEBUG, "Picked unused port %d", requested_port);
}
if (getifaddrs(&ifa) != 0 || ifa == NULL) {
return GRPC_OS_ERROR(errno, "getifaddrs");
}
for (ifa_it = ifa; ifa_it != NULL; ifa_it = ifa_it->ifa_next) {
grpc_resolved_address addr;
char *addr_str = NULL;
grpc_dualstack_mode dsmode;
grpc_tcp_listener *new_sp = NULL;
const char *ifa_name = (ifa_it->ifa_name ? ifa_it->ifa_name : "<unknown>");
if (ifa_it->ifa_addr == NULL) {
continue;
} else if (ifa_it->ifa_addr->sa_family == AF_INET) {
addr.len = sizeof(struct sockaddr_in);
} else if (ifa_it->ifa_addr->sa_family == AF_INET6) {
addr.len = sizeof(struct sockaddr_in6);
} else {
continue;
}
memcpy(addr.addr, ifa_it->ifa_addr, addr.len);
if (!grpc_sockaddr_set_port(&addr, requested_port)) {
/* Should never happen, because we check sa_family above. */
err = GRPC_ERROR_CREATE("Failed to set port");
break;
}
if (grpc_sockaddr_to_string(&addr_str, &addr, 0) < 0) {
addr_str = gpr_strdup("<error>");
}
gpr_log(GPR_DEBUG,
"Adding local addr from interface %s flags 0x%x to server: %s",
ifa_name, ifa_it->ifa_flags, addr_str);
/* We could have multiple interfaces with the same address (e.g., bonding),
so look for duplicates. */
if (find_listener_with_addr(s, &addr) != NULL) {
gpr_log(GPR_DEBUG, "Skipping duplicate addr %s on interface %s", addr_str,
ifa_name);
gpr_free(addr_str);
continue;
}
if ((err = add_addr_to_server(s, &addr, port_index, fd_index, &dsmode,
&new_sp)) != GRPC_ERROR_NONE) {
char *err_str = NULL;
grpc_error *root_err;
if (gpr_asprintf(&err_str, "Failed to add listener: %s", addr_str) < 0) {
err_str = gpr_strdup("Failed to add listener");
}
root_err = GRPC_ERROR_CREATE(err_str);
gpr_free(err_str);
gpr_free(addr_str);
err = grpc_error_add_child(root_err, err);
break;
} else {
GPR_ASSERT(requested_port == new_sp->port);
++fd_index;
if (sp != NULL) {
new_sp->is_sibling = 1;
sp->sibling = new_sp;
}
sp = new_sp;
}
gpr_free(addr_str);
}
freeifaddrs(ifa);
if (err != GRPC_ERROR_NONE) {
return err;
} else if (sp == NULL) {
return GRPC_ERROR_CREATE("No local addresses");
} else {
*out_port = sp->port;
return GRPC_ERROR_NONE;
}
}
/* Treat :: or 0.0.0.0 as a family-agnostic wildcard. */
static grpc_error *add_wildcard_addrs_to_server(grpc_tcp_server *s,
unsigned port_index,
int requested_port,
int *out_port) {
grpc_resolved_address wild4;
grpc_resolved_address wild6;
unsigned fd_index = 0;
grpc_dualstack_mode dsmode;
grpc_tcp_listener *sp = NULL;
grpc_tcp_listener *sp2 = NULL;
grpc_error *v6_err = GRPC_ERROR_NONE;
grpc_error *v4_err = GRPC_ERROR_NONE;
*out_port = -1;
if (s->expand_wildcard_addrs) {
return add_all_local_addrs_to_server(s, port_index, requested_port,
out_port);
}
grpc_sockaddr_make_wildcards(requested_port, &wild4, &wild6);
/* Try listening on IPv6 first. */
if ((v6_err = add_addr_to_server(s, &wild6, port_index, fd_index, &dsmode,
&sp)) == GRPC_ERROR_NONE) {
++fd_index;
requested_port = *out_port = sp->port;
if (dsmode == GRPC_DSMODE_DUALSTACK || dsmode == GRPC_DSMODE_IPV4) {
return GRPC_ERROR_NONE;
}
}
/* If we got a v6-only socket or nothing, try adding 0.0.0.0. */
grpc_sockaddr_set_port(&wild4, requested_port);
if ((v4_err = add_addr_to_server(s, &wild4, port_index, fd_index, &dsmode,
&sp2)) == GRPC_ERROR_NONE) {
*out_port = sp2->port;
if (sp != NULL) {
sp2->is_sibling = 1;
sp->sibling = sp2;
}
}
if (*out_port > 0) {
GRPC_LOG_IF_ERROR("Failed to add :: listener", v6_err);
GRPC_LOG_IF_ERROR("Failed to add 0.0.0.0 listener", v4_err);
return GRPC_ERROR_NONE;
} else {
grpc_error *root_err =
GRPC_ERROR_CREATE("Failed to add any wildcard listeners");
GPR_ASSERT(v6_err != GRPC_ERROR_NONE && v4_err != GRPC_ERROR_NONE);
root_err = grpc_error_add_child(root_err, v6_err);
root_err = grpc_error_add_child(root_err, v4_err);
return root_err;
}
}
static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) { static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) {
grpc_tcp_listener *sp = NULL; grpc_tcp_listener *sp = NULL;
char *addr_str; char *addr_str;
@ -559,19 +787,13 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
const grpc_resolved_address *addr, const grpc_resolved_address *addr,
int *out_port) { int *out_port) {
grpc_tcp_listener *sp; grpc_tcp_listener *sp;
grpc_tcp_listener *sp2 = NULL;
int fd;
grpc_dualstack_mode dsmode;
grpc_resolved_address addr6_v4mapped;
grpc_resolved_address wild4;
grpc_resolved_address wild6;
grpc_resolved_address addr4_copy;
grpc_resolved_address *allocated_addr = NULL;
grpc_resolved_address sockname_temp; grpc_resolved_address sockname_temp;
int port; grpc_resolved_address addr6_v4mapped;
int requested_port = grpc_sockaddr_get_port(addr);
unsigned port_index = 0; unsigned port_index = 0;
unsigned fd_index = 0; grpc_dualstack_mode dsmode;
grpc_error *errs[2] = {GRPC_ERROR_NONE, GRPC_ERROR_NONE}; grpc_error *err;
*out_port = -1;
if (s->tail != NULL) { if (s->tail != NULL) {
port_index = s->tail->port_index + 1; port_index = s->tail->port_index + 1;
} }
@ -579,85 +801,34 @@ grpc_error *grpc_tcp_server_add_port(grpc_tcp_server *s,
/* Check if this is a wildcard port, and if so, try to keep the port the same /* Check if this is a wildcard port, and if so, try to keep the port the same
as some previously created listener. */ as some previously created listener. */
if (grpc_sockaddr_get_port(addr) == 0) { if (requested_port == 0) {
for (sp = s->head; sp; sp = sp->next) { for (sp = s->head; sp; sp = sp->next) {
sockname_temp.len = sizeof(struct sockaddr_storage); sockname_temp.len = sizeof(struct sockaddr_storage);
if (0 == getsockname(sp->fd, (struct sockaddr *)sockname_temp.addr, if (0 == getsockname(sp->fd, (struct sockaddr *)&sockname_temp.addr,
(socklen_t *)&sockname_temp.len)) { (socklen_t *)&sockname_temp.len)) {
port = grpc_sockaddr_get_port(&sockname_temp); int used_port = grpc_sockaddr_get_port(&sockname_temp);
if (port > 0) { if (used_port > 0) {
allocated_addr = gpr_malloc(sizeof(grpc_resolved_address)); memcpy(&sockname_temp, addr, sizeof(grpc_resolved_address));
memcpy(allocated_addr, addr, addr->len); grpc_sockaddr_set_port(&sockname_temp, used_port);
grpc_sockaddr_set_port(allocated_addr, port); requested_port = used_port;
addr = allocated_addr; addr = &sockname_temp;
break; break;
} }
} }
} }
} }
if (grpc_sockaddr_is_wildcard(addr, &requested_port)) {
sp = NULL; return add_wildcard_addrs_to_server(s, port_index, requested_port,
out_port);
}
if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) { if (grpc_sockaddr_to_v4mapped(addr, &addr6_v4mapped)) {
addr = &addr6_v4mapped; addr = &addr6_v4mapped;
} }
if ((err = add_addr_to_server(s, addr, port_index, 0, &dsmode, &sp)) ==
/* Treat :: or 0.0.0.0 as a family-agnostic wildcard. */ GRPC_ERROR_NONE) {
if (grpc_sockaddr_is_wildcard(addr, &port)) {
grpc_sockaddr_make_wildcards(port, &wild4, &wild6);
/* Try listening on IPv6 first. */
addr = &wild6;
errs[0] = grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, &dsmode, &fd);
if (errs[0] == GRPC_ERROR_NONE) {
errs[0] = add_socket_to_server(s, fd, addr, port_index, fd_index, &sp);
if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) {
goto done;
}
if (sp != NULL) {
++fd_index;
}
/* If we didn't get a dualstack socket, also listen on 0.0.0.0. */
if (port == 0 && sp != NULL) {
grpc_sockaddr_set_port(&wild4, sp->port);
}
}
addr = &wild4;
}
errs[1] = grpc_create_dualstack_socket(addr, SOCK_STREAM, 0, &dsmode, &fd);
if (errs[1] == GRPC_ERROR_NONE) {
if (dsmode == GRPC_DSMODE_IPV4 &&
grpc_sockaddr_is_v4mapped(addr, &addr4_copy)) {
addr = &addr4_copy;
}
sp2 = sp;
errs[1] = add_socket_to_server(s, fd, addr, port_index, fd_index, &sp);
if (sp2 != NULL && sp != NULL) {
sp2->sibling = sp;
sp->is_sibling = 1;
}
}
done:
gpr_free(allocated_addr);
if (sp != NULL) {
*out_port = sp->port; *out_port = sp->port;
GRPC_ERROR_UNREF(errs[0]);
GRPC_ERROR_UNREF(errs[1]);
return GRPC_ERROR_NONE;
} else {
*out_port = -1;
char *addr_str = grpc_sockaddr_to_uri(addr);
grpc_error *err = grpc_error_set_str(
GRPC_ERROR_CREATE_REFERENCING("Failed to add port to server", errs,
GPR_ARRAY_SIZE(errs)),
GRPC_ERROR_STR_TARGET_ADDRESS, addr_str);
GRPC_ERROR_UNREF(errs[0]);
GRPC_ERROR_UNREF(errs[1]);
gpr_free(addr_str);
return err;
} }
return err;
} }
/* Return listener at port_index or NULL. Should only be called with s->mu /* Return listener at port_index or NULL. Should only be called with s->mu

@ -13,8 +13,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -31,8 +31,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Content Include="..\..\..\vsprojects\$(NativeDependenciesConfiguration)\grpc_csharp_ext.dll"> <Content Include="..\..\..\cmake\build\Win32\$(NativeDependenciesConfiguration)\grpc_csharp_ext.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>grpc_csharp_ext.x86.dll</Link> <Link>grpc_csharp_ext.x86.dll</Link>
</Content> </Content>

@ -13,8 +13,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -31,8 +31,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -13,8 +13,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -31,8 +31,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -13,8 +13,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -31,8 +31,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -13,8 +13,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -31,8 +31,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -16,8 +16,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -37,8 +37,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -16,8 +16,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -37,8 +37,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -16,8 +16,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -37,8 +37,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -16,8 +16,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -37,8 +37,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -16,8 +16,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -37,8 +37,8 @@
"data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem", "data/ca.pem": "../Grpc.IntegrationTesting/data/ca.pem",
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -13,8 +13,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -31,8 +31,8 @@
}, },
"copyToOutput": { "copyToOutput": {
"mappings": { "mappings": {
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -37,23 +37,15 @@ BUILD FROM SOURCE
You only need to go through these steps if you are planning to develop gRPC C#. You only need to go through these steps if you are planning to develop gRPC C#.
If you are a user of gRPC C#, go to Usage section above. If you are a user of gRPC C#, go to Usage section above.
**Windows** **Windows, Linux or Mac OS X**
- The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution. Open the - The easiest way to build is using the `run_tests.py` script that will take care of building the `grpc_csharp_ext` native library:
solution `vsprojects/grpc_csharp_ext.sln` in Visual Studio and build it. ```
- Open `src\csharp\Grpc.sln` (path is relative to gRPC repository root)
using Visual Studio
**Linux and Mac OS X**
- The grpc_csharp_ext native library needs to be built so you can build the gRPC C# solution:
```sh
# from the gRPC repository root # from the gRPC repository root
$ tools/run_tests/run_tests.py -c dbg -l csharp --build_only $ python tools/run_tests/run_tests.py -c dbg -l csharp --build_only
``` ```
- Use MonoDevelop / Xamarin Studio to open the solution Grpc.sln - Use Visual Studio / MonoDevelop / Xamarin Studio to open the solution Grpc.sln
RUNNING TESTS RUNNING TESTS
------------- -------------

@ -1,59 +0,0 @@
@rem Copyright 2016, Google Inc.
@rem All rights reserved.
@rem
@rem Redistribution and use in source and binary forms, with or without
@rem modification, are permitted provided that the following conditions are
@rem met:
@rem
@rem * Redistributions of source code must retain the above copyright
@rem notice, this list of conditions and the following disclaimer.
@rem * Redistributions in binary form must reproduce the above
@rem copyright notice, this list of conditions and the following disclaimer
@rem in the documentation and/or other materials provided with the
@rem distribution.
@rem * Neither the name of Google Inc. nor the names of its
@rem contributors may be used to endorse or promote products derived from
@rem this software without specific prior written permission.
@rem
@rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
@rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
@rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
@rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
@rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@rem Convenience script to build gRPC C# from command line
setlocal
@rem enter this directory
cd /d %~dp0
@rem Set VS variables (uses Visual Studio 2013)
@call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" x86
@rem Fetch all dependencies
nuget restore ..\..\vsprojects\grpc.sln || goto :error
nuget restore ..\..\vsprojects\grpc_csharp_ext.sln || goto :error
nuget restore ..\..\vsprojects\grpc_protoc_plugins.sln || goto :error
nuget restore Grpc.sln || goto :error
@rem Build the C# native extension
msbuild ..\..\vsprojects\grpc_csharp_ext.sln /p:Configuration=Debug /p:PlatformToolset=v120 || goto :error
msbuild ..\..\vsprojects\grpc_csharp_ext.sln /p:Configuration=Release /p:PlatformToolset=v120 || goto :error
msbuild Grpc.sln /p:Configuration=Debug || goto :error
msbuild Grpc.sln /p:Configuration=Release || goto :error
endlocal
goto :EOF
:error
echo Failed!
exit /b %errorlevel%

@ -48,6 +48,8 @@ from grpc_tools import protoc
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
_MESSAGES_IMPORT = b'import "messages.proto";' _MESSAGES_IMPORT = b'import "messages.proto";'
_SPLIT_NAMESPACE = b'package grpc_protoc_plugin.invocation_testing.split;'
_COMMON_NAMESPACE = b'package grpc_protoc_plugin.invocation_testing;'
@contextlib.contextmanager @contextlib.contextmanager
@ -163,7 +165,10 @@ class SameSeparateTest(unittest.TestCase, SeparateTestMixin):
os.makedirs(self.grpc_python_out_directory) os.makedirs(self.grpc_python_out_directory)
same_proto_file = os.path.join(self.proto_directory, same_proto_file = os.path.join(self.proto_directory,
'same_separate.proto') 'same_separate.proto')
open(same_proto_file, 'wb').write(same_proto_contents) open(same_proto_file, 'wb').write(
same_proto_contents.replace(
_COMMON_NAMESPACE,
b'package grpc_protoc_plugin.invocation_testing.same_separate;'))
protoc_result = protoc.main([ protoc_result = protoc.main([
'', '',
'--proto_path={}'.format(self.proto_directory), '--proto_path={}'.format(self.proto_directory),
@ -199,7 +204,11 @@ class SameCommonTest(unittest.TestCase, CommonTestMixin):
os.makedirs(self.python_out_directory) os.makedirs(self.python_out_directory)
same_proto_file = os.path.join(self.proto_directory, same_proto_file = os.path.join(self.proto_directory,
'same_common.proto') 'same_common.proto')
open(same_proto_file, 'wb').write(same_proto_contents) open(same_proto_file, 'wb').write(
same_proto_contents.replace(
_COMMON_NAMESPACE,
b'package grpc_protoc_plugin.invocation_testing.same_common;'))
protoc_result = protoc.main([ protoc_result = protoc.main([
'', '',
'--proto_path={}'.format(self.proto_directory), '--proto_path={}'.format(self.proto_directory),
@ -240,8 +249,14 @@ class SplitCommonTest(unittest.TestCase, CommonTestMixin):
'split_common_messages.proto') 'split_common_messages.proto')
open(services_proto_file, 'wb').write( open(services_proto_file, 'wb').write(
services_proto_contents.replace( services_proto_contents.replace(
_MESSAGES_IMPORT, b'import "split_common_messages.proto";')) _MESSAGES_IMPORT, b'import "split_common_messages.proto";')
open(messages_proto_file, 'wb').write(messages_proto_contents) .replace(
_SPLIT_NAMESPACE,
b'package grpc_protoc_plugin.invocation_testing.split_common;'))
open(messages_proto_file, 'wb').write(
messages_proto_contents.replace(
_SPLIT_NAMESPACE,
b'package grpc_protoc_plugin.invocation_testing.split_common;'))
protoc_result = protoc.main([ protoc_result = protoc.main([
'', '',
'--proto_path={}'.format(self.proto_directory), '--proto_path={}'.format(self.proto_directory),
@ -285,8 +300,16 @@ class SplitSeparateTest(unittest.TestCase, SeparateTestMixin):
'split_separate_messages.proto') 'split_separate_messages.proto')
open(services_proto_file, 'wb').write( open(services_proto_file, 'wb').write(
services_proto_contents.replace( services_proto_contents.replace(
_MESSAGES_IMPORT, b'import "split_separate_messages.proto";')) _MESSAGES_IMPORT, b'import "split_separate_messages.proto";')
open(messages_proto_file, 'wb').write(messages_proto_contents) .replace(
_SPLIT_NAMESPACE,
b'package grpc_protoc_plugin.invocation_testing.split_separate;'
))
open(messages_proto_file, 'wb').write(
messages_proto_contents.replace(
_SPLIT_NAMESPACE,
b'package grpc_protoc_plugin.invocation_testing.split_separate;'
))
protoc_result = protoc.main([ protoc_result = protoc.main([
'', '',
'--proto_path={}'.format(self.proto_directory), '--proto_path={}'.format(self.proto_directory),

@ -442,7 +442,18 @@
% endif % endif
% endfor % endfor
) )
if(WIN32 AND MSVC)
set_target_properties(${lib.name} PROPERTIES COMPILE_PDB_NAME "${lib.name}"
COMPILE_PDB_OUTPUT_DIRECTORY <%text>"${CMAKE_BINARY_DIR}</%text>"
)
if (gRPC_INSTALL)
install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>${lib.name}.pdb
DESTINATION <%text>${CMAKE_INSTALL_LIBDIR}</%text> OPTIONAL
)
endif()
endif()
% for src in lib.src: % for src in lib.src:
% if proto_re.match(src): % if proto_re.match(src):
protobuf_generate_grpc_cpp( protobuf_generate_grpc_cpp(

@ -21,8 +21,8 @@
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
% endif % endif
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Debug/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Debug/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Debug/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/dbg/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/dbg/libgrpc_csharp_ext.dylib"
} }
@ -44,8 +44,8 @@
"data/server1.key": "../Grpc.IntegrationTesting/data/server1.key", "data/server1.key": "../Grpc.IntegrationTesting/data/server1.key",
"data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem", "data/server1.pem": "../Grpc.IntegrationTesting/data/server1.pem",
% endif % endif
"grpc_csharp_ext.x64.dll": "../../../vsprojects/x64/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x64.dll": "../../../cmake/build/x64/Release/grpc_csharp_ext.dll",
"grpc_csharp_ext.x86.dll": "../../../vsprojects/Release/grpc_csharp_ext.dll", "grpc_csharp_ext.x86.dll": "../../../cmake/build/Win32/Release/grpc_csharp_ext.dll",
"libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so", "libgrpc_csharp_ext.x64.so": "../../../libs/opt/libgrpc_csharp_ext.so",
"libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib" "libgrpc_csharp_ext.x64.dylib": "../../../libs/opt/libgrpc_csharp_ext.dylib"
} }

@ -59,13 +59,17 @@ typedef struct {
char *alpn_preferred; char *alpn_preferred;
} server_args; } server_args;
// From https://wiki.openssl.org/index.php/Simple_TLS_Server. // Based on https://wiki.openssl.org/index.php/Simple_TLS_Server.
static int create_socket(int port) { // Pick an arbitrary unused port and return it in *out_port. Return
// an fd>=0 on success.
static int create_socket(int *out_port) {
int s; int s;
struct sockaddr_in addr; struct sockaddr_in addr;
socklen_t addr_len;
*out_port = -1;
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons((uint16_t)port); addr.sin_port = 0;
addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_addr.s_addr = htonl(INADDR_ANY);
s = socket(AF_INET, SOCK_STREAM, 0); s = socket(AF_INET, SOCK_STREAM, 0);
@ -76,7 +80,7 @@ static int create_socket(int port) {
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("Unable to bind"); perror("Unable to bind");
gpr_log(GPR_ERROR, "Unable to bind to %d", port); gpr_log(GPR_ERROR, "%s", "Unable to bind to any port");
close(s); close(s);
return -1; return -1;
} }
@ -87,6 +91,16 @@ static int create_socket(int port) {
return -1; return -1;
} }
addr_len = sizeof(addr);
if (getsockname(s, (struct sockaddr *)&addr, &addr_len) != 0 ||
addr_len > sizeof(addr)) {
perror("getsockname");
gpr_log(GPR_ERROR, "%s", "Unable to get socket local address");
close(s);
return -1;
}
*out_port = ntohs(addr.sin_port);
return s; return s;
} }
@ -215,13 +229,12 @@ static bool client_ssl_test(char *server_alpn_preferred) {
int server_socket = -1; int server_socket = -1;
int socket_retries = 30; int socket_retries = 30;
while (server_socket == -1 && socket_retries-- > 0) { while (server_socket == -1 && socket_retries-- > 0) {
port = grpc_pick_unused_port_or_die(); server_socket = create_socket(&port);
server_socket = create_socket(port);
if (server_socket == -1) { if (server_socket == -1) {
sleep(1); sleep(1);
} }
} }
GPR_ASSERT(server_socket > 0); GPR_ASSERT(server_socket > 0 && port > 0);
// Launch the TLS server thread. // Launch the TLS server thread.
gpr_thd_options thdopt = gpr_thd_options_default(); gpr_thd_options thdopt = gpr_thd_options_default();

@ -44,7 +44,7 @@
static void test_no_op(void) { static void test_no_op(void) {
gpr_log(GPR_DEBUG, "test_no_op"); gpr_log(GPR_DEBUG, "test_no_op");
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_combiner_destroy(&exec_ctx, grpc_combiner_create(NULL)); GRPC_COMBINER_UNREF(&exec_ctx, grpc_combiner_create(NULL), "test_no_op");
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
} }
@ -65,7 +65,7 @@ static void test_execute_one(void) {
GRPC_ERROR_NONE); GRPC_ERROR_NONE);
grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(done); GPR_ASSERT(done);
grpc_combiner_destroy(&exec_ctx, lock); GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_one");
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
} }
@ -125,7 +125,7 @@ static void test_execute_many(void) {
gpr_thd_join(thds[i]); gpr_thd_join(thds[i]);
} }
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_combiner_destroy(&exec_ctx, lock); GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_many");
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
} }
@ -153,7 +153,7 @@ static void test_execute_finally(void) {
GRPC_ERROR_NONE); GRPC_ERROR_NONE);
grpc_exec_ctx_flush(&exec_ctx); grpc_exec_ctx_flush(&exec_ctx);
GPR_ASSERT(got_in_finally); GPR_ASSERT(got_in_finally);
grpc_combiner_destroy(&exec_ctx, lock); GRPC_COMBINER_UNREF(&exec_ctx, lock, "test_execute_finally");
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
} }

@ -39,9 +39,12 @@
#include "src/core/lib/iomgr/tcp_server.h" #include "src/core/lib/iomgr/tcp_server.h"
#include <errno.h> #include <errno.h>
#include <ifaddrs.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
@ -50,6 +53,7 @@
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/sockaddr_utils.h"
@ -62,7 +66,7 @@ static gpr_mu *g_mu;
static grpc_pollset *g_pollset; static grpc_pollset *g_pollset;
static int g_nconnects = 0; static int g_nconnects = 0;
typedef struct on_connect_result { typedef struct {
/* Owns a ref to server. */ /* Owns a ref to server. */
grpc_tcp_server *server; grpc_tcp_server *server;
unsigned port_index; unsigned port_index;
@ -70,15 +74,41 @@ typedef struct on_connect_result {
int server_fd; int server_fd;
} on_connect_result; } on_connect_result;
typedef struct server_weak_ref { typedef struct {
grpc_tcp_server *server; grpc_tcp_server *server;
/* arg is this server_weak_ref. */ /* arg is this server_weak_ref. */
grpc_closure server_shutdown; grpc_closure server_shutdown;
} server_weak_ref; } server_weak_ref;
#define MAX_URI 1024
typedef struct {
grpc_resolved_address addr;
char str[MAX_URI];
} test_addr;
#define MAX_ADDRS 100
typedef struct {
size_t naddrs;
test_addr addrs[MAX_ADDRS];
} test_addrs;
static on_connect_result g_result = {NULL, 0, 0, -1}; static on_connect_result g_result = {NULL, 0, 0, -1};
static char family_name_buf[1024];
static const char *sock_family_name(int family) {
if (family == AF_INET) {
return "AF_INET";
} else if (family == AF_INET6) {
return "AF_INET6";
} else if (family == AF_UNSPEC) {
return "AF_UNSPEC";
} else {
sprintf(family_name_buf, "%d", family);
return family_name_buf;
}
}
static void on_connect_result_init(on_connect_result *result) { static void on_connect_result_init(on_connect_result *result) {
result->server = NULL; result->server = NULL;
result->port_index = 0; result->port_index = 0;
@ -118,6 +148,18 @@ static void server_weak_ref_set(server_weak_ref *weak_ref,
weak_ref->server = server; weak_ref->server = server;
} }
static void test_addr_init_str(test_addr *addr) {
char *str = NULL;
if (grpc_sockaddr_to_string(&str, &addr->addr, 0) != -1) {
size_t str_len;
memcpy(addr->str, str, (str_len = strnlen(str, sizeof(addr->str) - 1)));
addr->str[str_len] = '\0';
gpr_free(str);
} else {
addr->str[0] = '\0';
}
}
static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
grpc_pollset *pollset, grpc_pollset *pollset,
grpc_tcp_server_acceptor *acceptor) { grpc_tcp_server_acceptor *acceptor) {
@ -168,7 +210,7 @@ static void test_no_op_with_port(void) {
memset(&resolved_addr, 0, sizeof(resolved_addr)); memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_in); resolved_addr.len = sizeof(struct sockaddr_in);
addr->sin_family = AF_INET; addr->sin_family = AF_INET;
int port; int port = -1;
GPR_ASSERT(grpc_tcp_server_add_port(s, &resolved_addr, &port) == GPR_ASSERT(grpc_tcp_server_add_port(s, &resolved_addr, &port) ==
GRPC_ERROR_NONE && GRPC_ERROR_NONE &&
port > 0); port > 0);
@ -185,7 +227,7 @@ static void test_no_op_with_port_and_start(void) {
GPR_ASSERT(GRPC_ERROR_NONE == GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s));
LOG_TEST("test_no_op_with_port_and_start"); LOG_TEST("test_no_op_with_port_and_start");
int port; int port = -1;
memset(&resolved_addr, 0, sizeof(resolved_addr)); memset(&resolved_addr, 0, sizeof(resolved_addr));
resolved_addr.len = sizeof(struct sockaddr_in); resolved_addr.len = sizeof(struct sockaddr_in);
@ -200,74 +242,115 @@ static void test_no_op_with_port_and_start(void) {
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
} }
static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote,
socklen_t remote_len, on_connect_result *result) { on_connect_result *result) {
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
int clifd = socket(remote->sa_family, SOCK_STREAM, 0); int clifd;
int nconnects_before; int nconnects_before;
const struct sockaddr *remote_addr =
(const struct sockaddr *)remote->addr.addr;
gpr_log(GPR_INFO, "Connecting to %s", remote->str);
gpr_mu_lock(g_mu); gpr_mu_lock(g_mu);
nconnects_before = g_nconnects; nconnects_before = g_nconnects;
on_connect_result_init(&g_result); on_connect_result_init(&g_result);
GPR_ASSERT(clifd >= 0); clifd = socket(remote_addr->sa_family, SOCK_STREAM, 0);
gpr_log(GPR_DEBUG, "start connect"); if (clifd < 0) {
GPR_ASSERT(connect(clifd, remote, remote_len) == 0); gpr_mu_unlock(g_mu);
return GRPC_OS_ERROR(errno, "Failed to create socket");
}
gpr_log(GPR_DEBUG, "start connect to %s", remote->str);
if (connect(clifd, remote_addr, (socklen_t)remote->addr.len) != 0) {
gpr_mu_unlock(g_mu);
close(clifd);
return GRPC_OS_ERROR(errno, "connect");
}
gpr_log(GPR_DEBUG, "wait"); gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before && while (g_nconnects == nconnects_before &&
gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) { gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
grpc_pollset_worker *worker = NULL; grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR( grpc_error *err;
"pollset_work", if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker,
grpc_pollset_work(exec_ctx, g_pollset, &worker, gpr_now(GPR_CLOCK_MONOTONIC), deadline)) !=
gpr_now(GPR_CLOCK_MONOTONIC), deadline))); GRPC_ERROR_NONE) {
gpr_mu_unlock(g_mu);
close(clifd);
return err;
}
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_log(GPR_DEBUG, "wait done"); gpr_log(GPR_DEBUG, "wait done");
GPR_ASSERT(g_nconnects == nconnects_before + 1); if (g_nconnects != nconnects_before + 1) {
gpr_mu_unlock(g_mu);
close(clifd);
return GRPC_ERROR_CREATE("Didn't connect");
}
close(clifd); close(clifd);
*result = g_result; *result = g_result;
gpr_mu_unlock(g_mu); gpr_mu_unlock(g_mu);
gpr_log(GPR_INFO, "Result (%d, %d) fd %d", result->port_index,
result->fd_index, result->server_fd);
grpc_tcp_server_unref(exec_ctx, result->server);
return GRPC_ERROR_NONE;
} }
/* Tests a tcp server with multiple ports. TODO(daniel-j-born): Multiple fds for /* Tests a tcp server on "::" listeners with multiple ports. If channel_args is
the same port should be tested. */ non-NULL, pass them to the server. If dst_addrs is non-NULL, use valid addrs
static void test_connect(unsigned n) { as destination addrs (port is not set). If dst_addrs is NULL, use listener
addrs as destination addrs. If test_dst_addrs is true, test connectivity with
each destination address, set grpc_resolved_address::len=0 for failures, but
don't fail the overall unitest. */
static void test_connect(size_t num_connects,
const grpc_channel_args *channel_args,
test_addrs *dst_addrs, bool test_dst_addrs) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_resolved_address resolved_addr; grpc_resolved_address resolved_addr;
grpc_resolved_address resolved_addr1; grpc_resolved_address resolved_addr1;
struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr; struct sockaddr_storage *const addr =
struct sockaddr_storage *addr1 = (struct sockaddr_storage *)resolved_addr.addr;
struct sockaddr_storage *const addr1 =
(struct sockaddr_storage *)resolved_addr1.addr; (struct sockaddr_storage *)resolved_addr1.addr;
unsigned svr_fd_count; unsigned svr_fd_count;
int port;
int svr_port; int svr_port;
unsigned svr1_fd_count; unsigned svr1_fd_count;
int svr1_port; int svr1_port;
grpc_tcp_server *s; grpc_tcp_server *s;
const unsigned num_ports = 2;
GPR_ASSERT(GRPC_ERROR_NONE == GPR_ASSERT(GRPC_ERROR_NONE ==
grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); grpc_tcp_server_create(&exec_ctx, NULL, channel_args, &s));
unsigned i; unsigned port_num;
server_weak_ref weak_ref; server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref); server_weak_ref_init(&weak_ref);
server_weak_ref_set(&weak_ref, s);
LOG_TEST("test_connect"); LOG_TEST("test_connect");
gpr_log(GPR_INFO, "clients=%d", n); gpr_log(GPR_INFO,
"clients=%lu, num chan args=%lu, remote IP=%s, test_dst_addrs=%d",
(unsigned long)num_connects,
(unsigned long)(channel_args != NULL ? channel_args->num_args : 0),
dst_addrs != NULL ? "<specific>" : "::", test_dst_addrs);
memset(&resolved_addr, 0, sizeof(resolved_addr)); memset(&resolved_addr, 0, sizeof(resolved_addr));
memset(&resolved_addr1, 0, sizeof(resolved_addr1)); memset(&resolved_addr1, 0, sizeof(resolved_addr1));
resolved_addr.len = sizeof(struct sockaddr_storage); resolved_addr.len = sizeof(struct sockaddr_storage);
resolved_addr1.len = sizeof(struct sockaddr_storage); resolved_addr1.len = sizeof(struct sockaddr_storage);
addr->ss_family = addr1->ss_family = AF_INET; addr->ss_family = addr1->ss_family = AF_INET;
GPR_ASSERT(GRPC_ERROR_NONE == GPR_ASSERT(GRPC_LOG_IF_ERROR(
grpc_tcp_server_add_port(s, &resolved_addr, &svr_port)); "grpc_tcp_server_add_port",
grpc_tcp_server_add_port(s, &resolved_addr, &svr_port)));
gpr_log(GPR_INFO, "Allocated port %d", svr_port);
GPR_ASSERT(svr_port > 0); GPR_ASSERT(svr_port > 0);
/* Cannot use wildcard (port==0), because add_port() will try to reuse the /* Cannot use wildcard (port==0), because add_port() will try to reuse the
same port as a previous add_port(). */ same port as a previous add_port(). */
svr1_port = grpc_pick_unused_port_or_die(); svr1_port = grpc_pick_unused_port_or_die();
GPR_ASSERT(svr1_port > 0);
gpr_log(GPR_INFO, "Picked unused port %d", svr1_port);
grpc_sockaddr_set_port(&resolved_addr1, svr1_port); grpc_sockaddr_set_port(&resolved_addr1, svr1_port);
GPR_ASSERT(grpc_tcp_server_add_port(s, &resolved_addr1, &svr_port) == GPR_ASSERT(grpc_tcp_server_add_port(s, &resolved_addr1, &port) ==
GRPC_ERROR_NONE && GRPC_ERROR_NONE &&
svr_port == svr1_port); port == svr1_port);
/* Bad port_index. */ /* Bad port_index. */
GPR_ASSERT(grpc_tcp_server_port_fd_count(s, 2) == 0); GPR_ASSERT(grpc_tcp_server_port_fd_count(s, 2) == 0);
@ -283,58 +366,70 @@ static void test_connect(unsigned n) {
svr1_fd_count = grpc_tcp_server_port_fd_count(s, 1); svr1_fd_count = grpc_tcp_server_port_fd_count(s, 1);
GPR_ASSERT(svr1_fd_count >= 1); GPR_ASSERT(svr1_fd_count >= 1);
for (i = 0; i < svr_fd_count; ++i) {
int fd = grpc_tcp_server_port_fd(s, 0, i);
GPR_ASSERT(fd >= 0);
if (i == 0) {
GPR_ASSERT(getsockname(fd, (struct sockaddr *)addr,
(socklen_t *)&resolved_addr.len) == 0);
GPR_ASSERT(resolved_addr.len <= sizeof(*addr));
}
}
for (i = 0; i < svr1_fd_count; ++i) {
int fd = grpc_tcp_server_port_fd(s, 1, i);
GPR_ASSERT(fd >= 0);
if (i == 0) {
GPR_ASSERT(getsockname(fd, (struct sockaddr *)addr1,
(socklen_t *)&resolved_addr1.len) == 0);
GPR_ASSERT(resolved_addr1.len <= sizeof(*addr1));
}
}
grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, NULL); grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, NULL);
for (i = 0; i < n; i++) { if (dst_addrs != NULL) {
on_connect_result result; int ports[] = {svr_port, svr1_port};
int svr_fd; for (port_num = 0; port_num < num_ports; ++port_num) {
on_connect_result_init(&result); size_t dst_idx;
tcp_connect(&exec_ctx, (struct sockaddr *)addr, size_t num_tested = 0;
(socklen_t)resolved_addr.len, &result); for (dst_idx = 0; dst_idx < dst_addrs->naddrs; ++dst_idx) {
GPR_ASSERT(result.server_fd >= 0); test_addr dst = dst_addrs->addrs[dst_idx];
svr_fd = result.server_fd; on_connect_result result;
GPR_ASSERT(grpc_tcp_server_port_fd(s, result.port_index, result.fd_index) == grpc_error *err;
result.server_fd); if (dst.addr.len == 0) {
GPR_ASSERT(result.port_index == 0); gpr_log(GPR_DEBUG, "Skipping test of non-functional local IP %s",
GPR_ASSERT(result.fd_index < svr_fd_count); dst.str);
GPR_ASSERT(result.server == s); continue;
if (weak_ref.server == NULL) { }
server_weak_ref_set(&weak_ref, result.server); GPR_ASSERT(grpc_sockaddr_set_port(&dst.addr, ports[port_num]));
test_addr_init_str(&dst);
++num_tested;
on_connect_result_init(&result);
if ((err = tcp_connect(&exec_ctx, &dst, &result)) == GRPC_ERROR_NONE &&
result.server_fd >= 0 && result.server == s) {
continue;
}
gpr_log(GPR_ERROR, "Failed to connect to %s: %s", dst.str,
grpc_error_string(err));
GPR_ASSERT(test_dst_addrs);
dst_addrs->addrs[dst_idx].addr.len = 0;
GRPC_ERROR_UNREF(err);
}
GPR_ASSERT(num_tested > 0);
}
} else {
for (port_num = 0; port_num < num_ports; ++port_num) {
const unsigned num_fds = grpc_tcp_server_port_fd_count(s, port_num);
unsigned fd_num;
for (fd_num = 0; fd_num < num_fds; ++fd_num) {
int fd = grpc_tcp_server_port_fd(s, port_num, fd_num);
size_t connect_num;
test_addr dst;
GPR_ASSERT(fd >= 0);
dst.addr.len = sizeof(dst.addr.addr);
GPR_ASSERT(getsockname(fd, (struct sockaddr *)dst.addr.addr,
(socklen_t *)&dst.addr.len) == 0);
GPR_ASSERT(dst.addr.len <= sizeof(dst.addr.addr));
test_addr_init_str(&dst);
gpr_log(GPR_INFO, "(%d, %d) fd %d family %s listening on %s", port_num,
fd_num, fd, sock_family_name(addr->ss_family), dst.str);
for (connect_num = 0; connect_num < num_connects; ++connect_num) {
on_connect_result result;
on_connect_result_init(&result);
GPR_ASSERT(GRPC_LOG_IF_ERROR("tcp_connect",
tcp_connect(&exec_ctx, &dst, &result)));
GPR_ASSERT(result.server_fd == fd);
GPR_ASSERT(result.port_index == port_num);
GPR_ASSERT(result.fd_index == fd_num);
GPR_ASSERT(result.server == s);
GPR_ASSERT(
grpc_tcp_server_port_fd(s, result.port_index, result.fd_index) ==
result.server_fd);
}
}
} }
grpc_tcp_server_unref(&exec_ctx, result.server);
on_connect_result_init(&result);
tcp_connect(&exec_ctx, (struct sockaddr *)addr1,
(socklen_t)resolved_addr1.len, &result);
GPR_ASSERT(result.server_fd >= 0);
GPR_ASSERT(result.server_fd != svr_fd);
GPR_ASSERT(grpc_tcp_server_port_fd(s, result.port_index, result.fd_index) ==
result.server_fd);
GPR_ASSERT(result.port_index == 1);
GPR_ASSERT(result.fd_index < svr_fd_count);
GPR_ASSERT(result.server == s);
grpc_tcp_server_unref(&exec_ctx, result.server);
} }
/* Weak ref to server valid until final unref. */ /* Weak ref to server valid until final unref. */
GPR_ASSERT(weak_ref.server != NULL); GPR_ASSERT(weak_ref.server != NULL);
GPR_ASSERT(grpc_tcp_server_port_fd(s, 0, 0) >= 0); GPR_ASSERT(grpc_tcp_server_port_fd(s, 0, 0) >= 0);
@ -354,6 +449,12 @@ static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
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;
grpc_arg chan_args[] = {
{GRPC_ARG_INTEGER, GRPC_ARG_EXPAND_WILDCARD_ADDRS, {.integer = 1}}};
const grpc_channel_args channel_args = {1, chan_args};
struct ifaddrs *ifa = NULL;
struct ifaddrs *ifa_it;
test_addrs dst_addrs;
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());
@ -363,8 +464,45 @@ int main(int argc, char **argv) {
test_no_op_with_start(); test_no_op_with_start();
test_no_op_with_port(); test_no_op_with_port();
test_no_op_with_port_and_start(); test_no_op_with_port_and_start();
test_connect(1);
test_connect(10); if (getifaddrs(&ifa) != 0 || ifa == NULL) {
gpr_log(GPR_ERROR, "getifaddrs: %s", strerror(errno));
return EXIT_FAILURE;
}
dst_addrs.naddrs = 0;
for (ifa_it = ifa; ifa_it != NULL && dst_addrs.naddrs < MAX_ADDRS;
ifa_it = ifa_it->ifa_next) {
if (ifa_it->ifa_addr == NULL) {
continue;
} else if (ifa_it->ifa_addr->sa_family == AF_INET) {
dst_addrs.addrs[dst_addrs.naddrs].addr.len = sizeof(struct sockaddr_in);
} else if (ifa_it->ifa_addr->sa_family == AF_INET6) {
dst_addrs.addrs[dst_addrs.naddrs].addr.len = sizeof(struct sockaddr_in6);
} else {
continue;
}
memcpy(dst_addrs.addrs[dst_addrs.naddrs].addr.addr, ifa_it->ifa_addr,
dst_addrs.addrs[dst_addrs.naddrs].addr.len);
GPR_ASSERT(
grpc_sockaddr_set_port(&dst_addrs.addrs[dst_addrs.naddrs].addr, 0));
test_addr_init_str(&dst_addrs.addrs[dst_addrs.naddrs]);
++dst_addrs.naddrs;
}
freeifaddrs(ifa);
ifa = NULL;
/* Connect to same addresses as listeners. */
test_connect(1, NULL, NULL, false);
test_connect(10, NULL, NULL, false);
/* Set dst_addrs.addrs[i].len=0 for dst_addrs that are unreachable with a "::"
listener. */
test_connect(1, NULL, &dst_addrs, true);
/* Test connect(2) with dst_addrs. */
test_connect(1, &channel_args, &dst_addrs, false);
/* Test connect(2) with dst_addrs. */
test_connect(10, &channel_args, &dst_addrs, false);
grpc_closure_init(&destroyed, destroy_pollset, g_pollset, grpc_closure_init(&destroyed, destroy_pollset, g_pollset,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
@ -372,7 +510,7 @@ int main(int argc, char **argv) {
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
grpc_shutdown(); grpc_shutdown();
gpr_free(g_pollset); gpr_free(g_pollset);
return 0; return EXIT_SUCCESS;
} }
#else /* GRPC_POSIX_SOCKET */ #else /* GRPC_POSIX_SOCKET */

@ -810,12 +810,14 @@ include/grpc++/impl/codegen/client_unary_call.h \
include/grpc++/impl/codegen/completion_queue.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/config.h \ include/grpc++/impl/codegen/config.h \
include/grpc++/impl/codegen/config_protobuf.h \
include/grpc++/impl/codegen/core_codegen.h \ include/grpc++/impl/codegen/core_codegen.h \
include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/core_codegen_interface.h \
include/grpc++/impl/codegen/create_auth_context.h \ include/grpc++/impl/codegen/create_auth_context.h \
include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/grpc_library.h \
include/grpc++/impl/codegen/metadata_map.h \ include/grpc++/impl/codegen/metadata_map.h \
include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/method_handler_impl.h \
include/grpc++/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/rpc_method.h \ include/grpc++/impl/codegen/rpc_method.h \
include/grpc++/impl/codegen/rpc_service_method.h \ include/grpc++/impl/codegen/rpc_service_method.h \
include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/security/auth_context.h \

@ -810,6 +810,7 @@ include/grpc++/impl/codegen/client_unary_call.h \
include/grpc++/impl/codegen/completion_queue.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/config.h \ include/grpc++/impl/codegen/config.h \
include/grpc++/impl/codegen/config_protobuf.h \
include/grpc++/impl/codegen/core_codegen.h \ include/grpc++/impl/codegen/core_codegen.h \
include/grpc++/impl/codegen/core_codegen.h \ include/grpc++/impl/codegen/core_codegen.h \
include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/core_codegen_interface.h \
@ -817,6 +818,7 @@ include/grpc++/impl/codegen/create_auth_context.h \
include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/grpc_library.h \
include/grpc++/impl/codegen/metadata_map.h \ include/grpc++/impl/codegen/metadata_map.h \
include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/method_handler_impl.h \
include/grpc++/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/rpc_method.h \ include/grpc++/impl/codegen/rpc_method.h \
include/grpc++/impl/codegen/rpc_service_method.h \ include/grpc++/impl/codegen/rpc_service_method.h \
include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/security/auth_context.h \

@ -183,24 +183,14 @@ class CSharpExtArtifact:
self.labels = ['artifact', 'csharp', platform, arch] self.labels = ['artifact', 'csharp', platform, arch]
def pre_build_jobspecs(self): def pre_build_jobspecs(self):
if self.platform == 'windows': return []
return [create_jobspec('prebuild_%s' % self.name,
['tools\\run_tests\\helper_scripts\\pre_build_c.bat'],
shell=True,
flake_retries=5,
timeout_retries=2)]
else:
return []
def build_jobspec(self): def build_jobspec(self):
if self.platform == 'windows': if self.platform == 'windows':
msbuild_platform = 'Win32' if self.arch == 'x86' else self.arch cmake_arch_option = 'Win32' if self.arch == 'x86' else self.arch
return create_jobspec(self.name, return create_jobspec(self.name,
['tools\\run_tests\\artifacts\\build_artifact_csharp.bat', ['tools\\run_tests\\artifacts\\build_artifact_csharp.bat',
'vsprojects\\grpc_csharp_ext.sln', cmake_arch_option],
'/p:Configuration=Release',
'/p:PlatformToolset=v120',
'/p:Platform=%s' % msbuild_platform],
shell=True) shell=True)
else: else:
environ = {'CONFIG': 'opt', environ = {'CONFIG': 'opt',

@ -29,10 +29,16 @@
@rem Builds C# artifacts on Windows @rem Builds C# artifacts on Windows
@call vsprojects\build_vs2013.bat %* || goto :error set ARCHITECTURE=%1
@call tools\run_tests\helper_scripts\pre_build_csharp.bat %ARCHITECTURE% || goto :error
cd cmake\build\%ARCHITECTURE%
cmake --build . --target grpc_csharp_ext --config Release
cd ..\..\..
mkdir artifacts mkdir artifacts
copy /Y vsprojects\Release\grpc_csharp_ext.dll artifacts || copy /Y vsprojects\x64\Release\grpc_csharp_ext.dll artifacts || goto :error copy /Y cmake\build\Win32\Release\grpc_csharp_ext.dll artifacts || copy /Y cmake\build\x64\Release\grpc_csharp_ext.dll artifacts || goto :error
goto :EOF goto :EOF

@ -5380,7 +5380,8 @@
"grpc", "grpc",
"grpc++_base", "grpc++_base",
"grpc++_codegen_base", "grpc++_codegen_base",
"grpc++_codegen_base_src" "grpc++_codegen_base_src",
"grpc++_codegen_proto"
], ],
"headers": [ "headers": [
"include/grpc++/impl/codegen/core_codegen.h", "include/grpc++/impl/codegen/core_codegen.h",

@ -31,9 +31,21 @@
setlocal setlocal
set ARCHITECTURE=%1
@rem enter repo root @rem enter repo root
cd /d %~dp0\..\..\.. cd /d %~dp0\..\..\..
mkdir cmake
cd cmake
mkdir build
cd build
mkdir %ARCHITECTURE%
cd %ARCHITECTURE%
@rem TODO(jtattermusch): Stop hardcoding path to yasm once Jenkins workers can locate yasm correctly
cmake -G "Visual Studio 14 2015" -A %ARCHITECTURE% -DgRPC_BUILD_TESTS=OFF -DCMAKE_ASM_NASM_COMPILER="C:/Program Files (x86)/yasm/yasm.exe" ../../.. || goto :error
cd ..\..\..
@rem Location of nuget.exe @rem Location of nuget.exe
set NUGET=C:\nuget\nuget.exe set NUGET=C:\nuget\nuget.exe
@ -42,7 +54,6 @@ if exist %NUGET% (
@rem Restore Grpc packages by packages since Nuget client 3.4.4 doesnt support restore @rem Restore Grpc packages by packages since Nuget client 3.4.4 doesnt support restore
@rem by solution @rem by solution
@rem Moving into each directory to let the restores work based on per-project packages.config files @rem Moving into each directory to let the restores work based on per-project packages.config files
%NUGET% restore vsprojects/grpc_csharp_ext.sln || goto :error
cd src/csharp cd src/csharp

@ -126,15 +126,15 @@ for bm_name in sys.argv[1:]:
'bins/mutrace/%s' % bm_name, 'bins/mutrace/%s' % bm_name,
'--benchmark_filter=^%s$' % line, '--benchmark_filter=^%s$' % line,
'--benchmark_min_time=20']) '--benchmark_min_time=20'])
with open('/tmp/bm.perf', 'w') as f: with open('bm.perf', 'w') as f:
f.write(subprocess.check_output(['sudo', 'perf', 'script'])) f.write(subprocess.check_output(['sudo', 'perf', 'script']))
with open('/tmp/bm.folded', 'w') as f: with open('bm.folded', 'w') as f:
f.write(subprocess.check_output([ f.write(subprocess.check_output([
'%s/stackcollapse-perf.pl' % flamegraph_dir, '/tmp/bm.perf'])) '%s/stackcollapse-perf.pl' % flamegraph_dir, 'bm.perf']))
link(line, '%s.svg' % fnize(line)) link(line, '%s.svg' % fnize(line))
with open('reports/%s.svg' % fnize(line), 'w') as f: with open('reports/%s.svg' % fnize(line), 'w') as f:
f.write(subprocess.check_output([ f.write(subprocess.check_output([
'%s/flamegraph.pl' % flamegraph_dir, '/tmp/bm.folded'])) '%s/flamegraph.pl' % flamegraph_dir, 'bm.folded']))
index_html += "</body>\n</html>\n" index_html += "</body>\n</html>\n"
with open('reports/index.html', 'w') as f: with open('reports/index.html', 'w') as f:

@ -722,12 +722,10 @@ class CSharpLanguage(object):
self.config = config self.config = config
self.args = args self.args = args
if self.platform == 'windows': if self.platform == 'windows':
# Explicitly choosing between x86 and x64 arch doesn't work yet _check_compiler(self.args.compiler, ['coreclr', 'default'])
_check_arch(self.args.arch, ['default']) _check_arch(self.args.arch, ['default'])
# CoreCLR use 64bit runtime by default. self._cmake_arch_option = 'x64' if self.args.compiler == 'coreclr' else 'Win32'
arch_option = 'x64' if self.args.compiler == 'coreclr' else self.args.arch self._make_options = []
self._make_options = [_windows_toolset_option(self.args.compiler),
_windows_arch_option(arch_option)]
else: else:
_check_compiler(self.args.compiler, ['default', 'coreclr']) _check_compiler(self.args.compiler, ['default', 'coreclr'])
if self.platform == 'linux' and self.args.compiler == 'coreclr': if self.platform == 'linux' and self.args.compiler == 'coreclr':
@ -799,7 +797,7 @@ class CSharpLanguage(object):
def pre_build_steps(self): def pre_build_steps(self):
if self.platform == 'windows': if self.platform == 'windows':
return [['tools\\run_tests\\helper_scripts\\pre_build_csharp.bat']] return [['tools\\run_tests\\helper_scripts\\pre_build_csharp.bat', self._cmake_arch_option]]
else: else:
return [['tools/run_tests/helper_scripts/pre_build_csharp.sh']] return [['tools/run_tests/helper_scripts/pre_build_csharp.sh']]
@ -817,7 +815,7 @@ class CSharpLanguage(object):
return [['tools/run_tests/helper_scripts/build_csharp_coreclr.sh']] return [['tools/run_tests/helper_scripts/build_csharp_coreclr.sh']]
else: else:
if self.platform == 'windows': if self.platform == 'windows':
return [[_windows_build_bat(self.args.compiler), return [['vsprojects\\build_vs2015.bat',
'src/csharp/Grpc.sln', 'src/csharp/Grpc.sln',
'/p:Configuration=%s' % _MSBUILD_CONFIG[self.config.build_config]]] '/p:Configuration=%s' % _MSBUILD_CONFIG[self.config.build_config]]]
else: else:
@ -830,7 +828,10 @@ class CSharpLanguage(object):
return [['tools/run_tests/helper_scripts/post_tests_csharp.sh']] return [['tools/run_tests/helper_scripts/post_tests_csharp.sh']]
def makefile_name(self): def makefile_name(self):
return 'Makefile' if self.platform == 'windows':
return 'cmake/build/%s/Makefile' % self._cmake_arch_option
else:
return 'Makefile'
def dockerfile_dir(self): def dockerfile_dir(self):
return 'tools/dockerfile/test/csharp_%s_%s' % (self._docker_distro, return 'tools/dockerfile/test/csharp_%s_%s' % (self._docker_distro,
@ -1038,12 +1039,10 @@ def _check_arch_option(arch):
def _windows_build_bat(compiler): def _windows_build_bat(compiler):
"""Returns name of build.bat for selected compiler.""" """Returns name of build.bat for selected compiler."""
# For CoreCLR, fall back to the default compiler for C core # For CoreCLR, fall back to the default compiler for C core
if compiler == 'default' or compiler == 'vs2013' or compiler == 'coreclr': if compiler == 'default' or compiler == 'vs2013':
return 'vsprojects\\build_vs2013.bat' return 'vsprojects\\build_vs2013.bat'
elif compiler == 'vs2015': elif compiler == 'vs2015':
return 'vsprojects\\build_vs2015.bat' return 'vsprojects\\build_vs2015.bat'
elif compiler == 'vs2010':
return 'vsprojects\\build_vs2010.bat'
else: else:
print('Compiler %s not supported.' % compiler) print('Compiler %s not supported.' % compiler)
sys.exit(1) sys.exit(1)
@ -1056,8 +1055,6 @@ def _windows_toolset_option(compiler):
return '/p:PlatformToolset=v120' return '/p:PlatformToolset=v120'
elif compiler == 'vs2015': elif compiler == 'vs2015':
return '/p:PlatformToolset=v140' return '/p:PlatformToolset=v140'
elif compiler == 'vs2010':
return '/p:PlatformToolset=v100'
else: else:
print('Compiler %s not supported.' % compiler) print('Compiler %s not supported.' % compiler)
sys.exit(1) sys.exit(1)
@ -1147,7 +1144,7 @@ argp.add_argument('--compiler',
choices=['default', choices=['default',
'gcc4.4', 'gcc4.6', 'gcc4.8', 'gcc4.9', 'gcc5.3', 'gcc4.4', 'gcc4.6', 'gcc4.8', 'gcc4.9', 'gcc5.3',
'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7', 'clang3.4', 'clang3.5', 'clang3.6', 'clang3.7',
'vs2010', 'vs2013', 'vs2015', 'vs2013', 'vs2015',
'python2.7', 'python3.4', 'python3.5', 'python3.6', 'pypy', 'pypy3', 'python2.7', 'python3.4', 'python3.5', 'python3.6', 'pypy', 'pypy3',
'node0.12', 'node4', 'node5', 'node6', 'node7', 'node0.12', 'node4', 'node5', 'node6', 'node7',
'electron1.3', 'electron1.3',
@ -1292,7 +1289,7 @@ def make_jobspec(cfg, targets, makefile='Makefile'):
return [jobset.JobSpec(['cmake', '--build', '.', return [jobset.JobSpec(['cmake', '--build', '.',
'--target', '%s' % target, '--target', '%s' % target,
'--config', _MSBUILD_CONFIG[cfg]], '--config', _MSBUILD_CONFIG[cfg]],
cwd='cmake/build', cwd=os.path.dirname(makefile),
timeout_seconds=None) for target in targets] timeout_seconds=None) for target in targets]
extra_args = [] extra_args = []
# better do parallel compilation # better do parallel compilation

@ -349,6 +349,8 @@
<ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_generic.h" /> <ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_generic.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_posix.h" /> <ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_posix.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_windows.h" /> <ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_windows.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\proto_utils.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\config_protobuf.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\core_codegen.h" /> <ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\core_codegen.h" />

@ -387,6 +387,12 @@
<ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_windows.h"> <ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_windows.h">
<Filter>include\grpc\impl\codegen</Filter> <Filter>include\grpc\impl\codegen</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\proto_utils.h">
<Filter>include\grpc++\impl\codegen</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\config_protobuf.h">
<Filter>include\grpc++\impl\codegen</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\core_codegen.h"> <ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\core_codegen.h">

Loading…
Cancel
Save