Compiling again

pull/11888/head
Craig Tiller 8 years ago
parent 565d4c1e88
commit c0df1c0f9a
  1. 4
      BUILD
  2. 64
      CMakeLists.txt
  3. 74
      Makefile
  4. 2
      binding.gyp
  5. 22
      build.yaml
  6. 3
      config.m4
  7. 3
      config.w32
  8. 10
      gRPC-Core.podspec
  9. 4
      grpc.gemspec
  10. 4
      package.xml
  11. 3
      src/core/ext/filters/client_channel/channel_connectivity.c
  12. 56
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
  13. 11
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
  14. 3
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
  15. 30
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c
  16. 30
      src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c
  17. 22
      src/core/ext/filters/client_channel/subchannel.c
  18. 7
      src/core/ext/filters/deadline/deadline_filter.c
  19. 62
      src/core/ext/filters/max_age/max_age_filter.c
  20. 26
      src/core/lib/backoff/backoff.c
  21. 19
      src/core/lib/backoff/backoff.h
  22. 8
      src/core/lib/iomgr/exec_ctx.c
  23. 6
      src/core/lib/iomgr/exec_ctx.h
  24. 2
      src/core/lib/iomgr/timer_manager.c
  25. 3
      src/core/lib/surface/alarm.c
  26. 14
      src/core/lib/surface/completion_queue.c
  27. 2
      src/python/grpcio/grpc_core_dependencies.py
  28. 34
      test/core/backoff/BUILD
  29. 147
      test/core/backoff/backoff_test.c
  30. 2
      test/core/client_channel/resolvers/dns_resolver_connectivity_test.c
  31. 18
      test/core/end2end/fuzzers/api_fuzzer.c
  32. 10
      test/core/http/httpcli_test.c
  33. 10
      test/core/http/httpscli_test.c
  34. 4
      test/core/iomgr/endpoint_tests.c
  35. 24
      test/core/iomgr/fd_posix_test.c
  36. 27
      test/core/iomgr/resolve_address_posix_test.c
  37. 27
      test/core/iomgr/resolve_address_test.c
  38. 23
      test/core/iomgr/tcp_client_posix_test.c
  39. 31
      test/core/iomgr/tcp_posix_test.c
  40. 8
      test/core/iomgr/tcp_server_posix_test.c
  41. 83
      test/core/iomgr/timer_list_test.c
  42. 11
      test/core/iomgr/udp_server_test.c
  43. 33
      test/core/security/credentials_test.c
  44. 14
      test/core/security/jwt_verifier_test.c
  45. 3
      test/core/security/ssl_server_fuzzer.c
  46. 10
      test/core/support/BUILD
  47. 143
      test/core/support/backoff_test.c
  48. 10
      test/core/surface/concurrent_connectivity_test.c
  49. 4
      test/core/util/test_tcp_server.c
  50. 4
      tools/doxygen/Doxyfile.core.internal
  51. 38
      tools/run_tests/generated/sources_and_headers.json
  52. 44
      tools/run_tests/generated/tests.json
  53. 52
      vsprojects/buildtests_c.sln
  54. 6
      vsprojects/vcxproj/gpr/gpr.vcxproj
  55. 15
      vsprojects/vcxproj/gpr/gpr.vcxproj.filters
  56. 14
      vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj
  57. 12
      vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj.filters

@ -465,7 +465,7 @@ grpc_cc_library(
"src/core/lib/support/arena.c",
"src/core/lib/support/atm.c",
"src/core/lib/support/avl.c",
"src/core/lib/support/backoff.c",
"src/core/lib/backoff/backoff.c",
"src/core/lib/support/cmdline.c",
"src/core/lib/support/cpu_iphone.c",
"src/core/lib/support/cpu_linux.c",
@ -512,7 +512,7 @@ grpc_cc_library(
"src/core/lib/support/atomic.h",
"src/core/lib/support/atomic_with_atm.h",
"src/core/lib/support/atomic_with_std.h",
"src/core/lib/support/backoff.h",
"src/core/lib/backoff/backoff.h",
"src/core/lib/support/block_annotate.h",
"src/core/lib/support/env.h",
"src/core/lib/support/memory.h",

@ -390,6 +390,7 @@ add_dependencies(buildtests_c algorithm_test)
add_dependencies(buildtests_c alloc_test)
add_dependencies(buildtests_c alpn_test)
add_dependencies(buildtests_c arena_test)
add_dependencies(buildtests_c backoff_test)
add_dependencies(buildtests_c bad_server_response_test)
add_dependencies(buildtests_c bdp_estimator_test)
add_dependencies(buildtests_c bin_decoder_test)
@ -435,7 +436,6 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c goaway_server_test)
endif()
add_dependencies(buildtests_c gpr_avl_test)
add_dependencies(buildtests_c gpr_backoff_test)
add_dependencies(buildtests_c gpr_cmdline_test)
add_dependencies(buildtests_c gpr_cpu_test)
add_dependencies(buildtests_c gpr_env_test)
@ -769,13 +769,13 @@ endif (gRPC_BUILD_TESTS)
add_library(gpr
src/core/lib/backoff/backoff.c
src/core/lib/profiling/basic_timers.c
src/core/lib/profiling/stap_timers.c
src/core/lib/support/alloc.c
src/core/lib/support/arena.c
src/core/lib/support/atm.c
src/core/lib/support/avl.c
src/core/lib/support/backoff.c
src/core/lib/support/cmdline.c
src/core/lib/support/cpu_iphone.c
src/core/lib/support/cpu_linux.c
@ -4659,6 +4659,37 @@ target_link_libraries(arena_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(backoff_test
test/core/backoff/backoff_test.c
)
target_include_directories(backoff_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${BORINGSSL_ROOT_DIR}/include
PRIVATE ${PROTOBUF_ROOT_DIR}/src
PRIVATE ${BENCHMARK_ROOT_DIR}/include
PRIVATE ${ZLIB_ROOT_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
PRIVATE ${CARES_BUILD_INCLUDE_DIR}
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CARES_PLATFORM_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
)
target_link_libraries(backoff_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(bad_server_response_test
test/core/end2end/bad_server_response_test.c
)
@ -5769,35 +5800,6 @@ target_link_libraries(gpr_avl_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_backoff_test
test/core/support/backoff_test.c
)
target_include_directories(gpr_backoff_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${BORINGSSL_ROOT_DIR}/include
PRIVATE ${PROTOBUF_ROOT_DIR}/src
PRIVATE ${BENCHMARK_ROOT_DIR}/include
PRIVATE ${ZLIB_ROOT_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib
PRIVATE ${CARES_BUILD_INCLUDE_DIR}
PRIVATE ${CARES_INCLUDE_DIR}
PRIVATE ${CARES_PLATFORM_INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include
)
target_link_libraries(gpr_backoff_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_cmdline_test
test/core/support/cmdline_test.c
)

@ -950,6 +950,7 @@ alloc_test: $(BINDIR)/$(CONFIG)/alloc_test
alpn_test: $(BINDIR)/$(CONFIG)/alpn_test
api_fuzzer: $(BINDIR)/$(CONFIG)/api_fuzzer
arena_test: $(BINDIR)/$(CONFIG)/arena_test
backoff_test: $(BINDIR)/$(CONFIG)/backoff_test
bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test
bdp_estimator_test: $(BINDIR)/$(CONFIG)/bdp_estimator_test
bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test
@ -986,7 +987,6 @@ gen_legal_metadata_characters: $(BINDIR)/$(CONFIG)/gen_legal_metadata_characters
gen_percent_encoding_tables: $(BINDIR)/$(CONFIG)/gen_percent_encoding_tables
goaway_server_test: $(BINDIR)/$(CONFIG)/goaway_server_test
gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test
gpr_backoff_test: $(BINDIR)/$(CONFIG)/gpr_backoff_test
gpr_cmdline_test: $(BINDIR)/$(CONFIG)/gpr_cmdline_test
gpr_cpu_test: $(BINDIR)/$(CONFIG)/gpr_cpu_test
gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test
@ -1340,6 +1340,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/alloc_test \
$(BINDIR)/$(CONFIG)/alpn_test \
$(BINDIR)/$(CONFIG)/arena_test \
$(BINDIR)/$(CONFIG)/backoff_test \
$(BINDIR)/$(CONFIG)/bad_server_response_test \
$(BINDIR)/$(CONFIG)/bdp_estimator_test \
$(BINDIR)/$(CONFIG)/bin_decoder_test \
@ -1371,7 +1372,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/fling_test \
$(BINDIR)/$(CONFIG)/goaway_server_test \
$(BINDIR)/$(CONFIG)/gpr_avl_test \
$(BINDIR)/$(CONFIG)/gpr_backoff_test \
$(BINDIR)/$(CONFIG)/gpr_cmdline_test \
$(BINDIR)/$(CONFIG)/gpr_cpu_test \
$(BINDIR)/$(CONFIG)/gpr_env_test \
@ -1735,6 +1735,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/alpn_test || ( echo test alpn_test failed ; exit 1 )
$(E) "[RUN] Testing arena_test"
$(Q) $(BINDIR)/$(CONFIG)/arena_test || ( echo test arena_test failed ; exit 1 )
$(E) "[RUN] Testing backoff_test"
$(Q) $(BINDIR)/$(CONFIG)/backoff_test || ( echo test backoff_test failed ; exit 1 )
$(E) "[RUN] Testing bad_server_response_test"
$(Q) $(BINDIR)/$(CONFIG)/bad_server_response_test || ( echo test bad_server_response_test failed ; exit 1 )
$(E) "[RUN] Testing bdp_estimator_test"
@ -1793,8 +1795,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/goaway_server_test || ( echo test goaway_server_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_avl_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_avl_test || ( echo test gpr_avl_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_backoff_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_backoff_test || ( echo test gpr_backoff_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_cmdline_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_cmdline_test || ( echo test gpr_cmdline_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_cpu_test"
@ -2736,13 +2736,13 @@ clean:
LIBGPR_SRC = \
src/core/lib/backoff/backoff.c \
src/core/lib/profiling/basic_timers.c \
src/core/lib/profiling/stap_timers.c \
src/core/lib/support/alloc.c \
src/core/lib/support/arena.c \
src/core/lib/support/atm.c \
src/core/lib/support/avl.c \
src/core/lib/support/backoff.c \
src/core/lib/support/cmdline.c \
src/core/lib/support/cpu_iphone.c \
src/core/lib/support/cpu_linux.c \
@ -8274,6 +8274,38 @@ endif
endif
BACKOFF_TEST_SRC = \
test/core/backoff/backoff_test.c \
BACKOFF_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BACKOFF_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/backoff_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/backoff_test: $(BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/backoff_test
endif
$(OBJDIR)/$(CONFIG)/test/core/backoff/backoff_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_backoff_test: $(BACKOFF_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(BACKOFF_TEST_OBJS:.o=.dep)
endif
endif
BAD_SERVER_RESPONSE_TEST_SRC = \
test/core/end2end/bad_server_response_test.c \
@ -9426,38 +9458,6 @@ endif
endif
GPR_BACKOFF_TEST_SRC = \
test/core/support/backoff_test.c \
GPR_BACKOFF_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_BACKOFF_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/gpr_backoff_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/gpr_backoff_test: $(GPR_BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(GPR_BACKOFF_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_backoff_test
endif
$(OBJDIR)/$(CONFIG)/test/core/support/backoff_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_backoff_test: $(GPR_BACKOFF_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(GPR_BACKOFF_TEST_OBJS:.o=.dep)
endif
endif
GPR_CMDLINE_TEST_SRC = \
test/core/support/cmdline_test.c \

@ -579,13 +579,13 @@
'dependencies': [
],
'sources': [
'src/core/lib/backoff/backoff.c',
'src/core/lib/profiling/basic_timers.c',
'src/core/lib/profiling/stap_timers.c',
'src/core/lib/support/alloc.c',
'src/core/lib/support/arena.c',
'src/core/lib/support/atm.c',
'src/core/lib/support/avl.c',
'src/core/lib/support/backoff.c',
'src/core/lib/support/cmdline.c',
'src/core/lib/support/cpu_iphone.c',
'src/core/lib/support/cpu_linux.c',

@ -87,12 +87,12 @@ filegroups:
- include/grpc/support/tls_pthread.h
- include/grpc/support/useful.h
headers:
- src/core/lib/backoff/backoff.h
- src/core/lib/profiling/timers.h
- src/core/lib/support/arena.h
- src/core/lib/support/atomic.h
- src/core/lib/support/atomic_with_atm.h
- src/core/lib/support/atomic_with_std.h
- src/core/lib/support/backoff.h
- src/core/lib/support/block_annotate.h
- src/core/lib/support/env.h
- src/core/lib/support/memory.h
@ -106,13 +106,13 @@ filegroups:
- src/core/lib/support/time_precise.h
- src/core/lib/support/tmpfile.h
src:
- src/core/lib/backoff/backoff.c
- src/core/lib/profiling/basic_timers.c
- src/core/lib/profiling/stap_timers.c
- src/core/lib/support/alloc.c
- src/core/lib/support/arena.c
- src/core/lib/support/atm.c
- src/core/lib/support/avl.c
- src/core/lib/support/backoff.c
- src/core/lib/support/cmdline.c
- src/core/lib/support/cpu_iphone.c
- src/core/lib/support/cpu_linux.c
@ -1658,6 +1658,16 @@ targets:
deps:
- gpr_test_util
- gpr
- name: backoff_test
build: test
language: c
src:
- test/core/backoff/backoff_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: bad_server_response_test
build: test
language: c
@ -2061,14 +2071,6 @@ targets:
deps:
- gpr_test_util
- gpr
- name: gpr_backoff_test
build: test
language: c
src:
- test/core/support/backoff_test.c
deps:
- gpr_test_util
- gpr
- name: gpr_cmdline_test
build: test
language: c

@ -39,13 +39,13 @@ if test "$PHP_GRPC" != "no"; then
src/php/ext/grpc/server.c \
src/php/ext/grpc/server_credentials.c \
src/php/ext/grpc/timeval.c \
src/core/lib/backoff/backoff.c \
src/core/lib/profiling/basic_timers.c \
src/core/lib/profiling/stap_timers.c \
src/core/lib/support/alloc.c \
src/core/lib/support/arena.c \
src/core/lib/support/atm.c \
src/core/lib/support/avl.c \
src/core/lib/support/backoff.c \
src/core/lib/support/cmdline.c \
src/core/lib/support/cpu_iphone.c \
src/core/lib/support/cpu_linux.c \
@ -677,6 +677,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/compression)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/debug)

@ -16,13 +16,13 @@ if (PHP_GRPC != "no") {
"src\\php\\ext\\grpc\\server.c " +
"src\\php\\ext\\grpc\\server_credentials.c " +
"src\\php\\ext\\grpc\\timeval.c " +
"src\\core\\lib\\backoff\\backoff.c " +
"src\\core\\lib\\profiling\\basic_timers.c " +
"src\\core\\lib\\profiling\\stap_timers.c " +
"src\\core\\lib\\support\\alloc.c " +
"src\\core\\lib\\support\\arena.c " +
"src\\core\\lib\\support\\atm.c " +
"src\\core\\lib\\support\\avl.c " +
"src\\core\\lib\\support\\backoff.c " +
"src\\core\\lib\\support\\cmdline.c " +
"src\\core\\lib\\support\\cpu_iphone.c " +
"src\\core\\lib\\support\\cpu_linux.c " +
@ -690,6 +690,7 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\channel");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\compression");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\debug");

@ -180,12 +180,12 @@ Pod::Spec.new do |s|
ss.dependency 'nanopb', '~> 0.3'
# To save you from scrolling, this is the last part of the podspec.
ss.source_files = 'src/core/lib/profiling/timers.h',
ss.source_files = 'src/core/lib/backoff/backoff.h',
'src/core/lib/profiling/timers.h',
'src/core/lib/support/arena.h',
'src/core/lib/support/atomic.h',
'src/core/lib/support/atomic_with_atm.h',
'src/core/lib/support/atomic_with_std.h',
'src/core/lib/support/backoff.h',
'src/core/lib/support/block_annotate.h',
'src/core/lib/support/env.h',
'src/core/lib/support/memory.h',
@ -198,13 +198,13 @@ Pod::Spec.new do |s|
'src/core/lib/support/thd_internal.h',
'src/core/lib/support/time_precise.h',
'src/core/lib/support/tmpfile.h',
'src/core/lib/backoff/backoff.c',
'src/core/lib/profiling/basic_timers.c',
'src/core/lib/profiling/stap_timers.c',
'src/core/lib/support/alloc.c',
'src/core/lib/support/arena.c',
'src/core/lib/support/atm.c',
'src/core/lib/support/avl.c',
'src/core/lib/support/backoff.c',
'src/core/lib/support/cmdline.c',
'src/core/lib/support/cpu_iphone.c',
'src/core/lib/support/cpu_linux.c',
@ -708,12 +708,12 @@ Pod::Spec.new do |s|
'src/core/ext/filters/workarounds/workaround_utils.c',
'src/core/plugin_registry/grpc_plugin_registry.c'
ss.private_header_files = 'src/core/lib/profiling/timers.h',
ss.private_header_files = 'src/core/lib/backoff/backoff.h',
'src/core/lib/profiling/timers.h',
'src/core/lib/support/arena.h',
'src/core/lib/support/atomic.h',
'src/core/lib/support/atomic_with_atm.h',
'src/core/lib/support/atomic_with_std.h',
'src/core/lib/support/backoff.h',
'src/core/lib/support/block_annotate.h',
'src/core/lib/support/env.h',
'src/core/lib/support/memory.h',

@ -80,12 +80,12 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/sync_generic.h )
s.files += %w( include/grpc/impl/codegen/sync_posix.h )
s.files += %w( include/grpc/impl/codegen/sync_windows.h )
s.files += %w( src/core/lib/backoff/backoff.h )
s.files += %w( src/core/lib/profiling/timers.h )
s.files += %w( src/core/lib/support/arena.h )
s.files += %w( src/core/lib/support/atomic.h )
s.files += %w( src/core/lib/support/atomic_with_atm.h )
s.files += %w( src/core/lib/support/atomic_with_std.h )
s.files += %w( src/core/lib/support/backoff.h )
s.files += %w( src/core/lib/support/block_annotate.h )
s.files += %w( src/core/lib/support/env.h )
s.files += %w( src/core/lib/support/memory.h )
@ -98,13 +98,13 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/support/thd_internal.h )
s.files += %w( src/core/lib/support/time_precise.h )
s.files += %w( src/core/lib/support/tmpfile.h )
s.files += %w( src/core/lib/backoff/backoff.c )
s.files += %w( src/core/lib/profiling/basic_timers.c )
s.files += %w( src/core/lib/profiling/stap_timers.c )
s.files += %w( src/core/lib/support/alloc.c )
s.files += %w( src/core/lib/support/arena.c )
s.files += %w( src/core/lib/support/atm.c )
s.files += %w( src/core/lib/support/avl.c )
s.files += %w( src/core/lib/support/backoff.c )
s.files += %w( src/core/lib/support/cmdline.c )
s.files += %w( src/core/lib/support/cpu_iphone.c )
s.files += %w( src/core/lib/support/cpu_linux.c )

@ -94,12 +94,12 @@
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_generic.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_posix.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_windows.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/backoff/backoff.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/arena.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/atomic.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/atomic_with_atm.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/atomic_with_std.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/backoff.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/block_annotate.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/env.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/memory.h" role="src" />
@ -112,13 +112,13 @@
<file baseinstalldir="/" name="src/core/lib/support/thd_internal.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/time_precise.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/tmpfile.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/backoff/backoff.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/profiling/basic_timers.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/profiling/stap_timers.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/alloc.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/arena.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/atm.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/avl.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/backoff.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/cmdline.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/cpu_iphone.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/cpu_linux.c" role="src" />

@ -186,8 +186,7 @@ static void watcher_timer_init(grpc_exec_ctx *exec_ctx, void *arg,
watcher_timer_init_arg *wa = (watcher_timer_init_arg *)arg;
grpc_timer_init(exec_ctx, &wa->w->alarm,
grpc_timespec_to_millis(exec_ctx, wa->deadline),
&wa->w->on_timeout);
grpc_timespec_to_millis(wa->deadline), &wa->w->on_timeout);
gpr_free(wa);
}

@ -101,6 +101,7 @@
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/ext/filters/client_channel/parse_address.h"
#include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
#include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/iomgr/combiner.h"
@ -110,7 +111,6 @@
#include "src/core/lib/slice/slice_hash_table.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/slice/slice_string_helpers.h"
#include "src/core/lib/support/backoff.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h"
@ -384,7 +384,7 @@ typedef struct glb_lb_policy {
grpc_slice lb_call_status_details;
/** LB call retry backoff state */
gpr_backoff lb_call_backoff_state;
grpc_backoff lb_call_backoff_state;
/** LB call retry timer */
grpc_timer lb_call_retry_timer;
@ -396,7 +396,7 @@ typedef struct glb_lb_policy {
* recreated whenever lb_call is replaced. */
grpc_grpclb_client_stats *client_stats;
/* Interval and timer for next client load report. */
gpr_timespec client_stats_report_interval;
grpc_millis client_stats_report_interval;
grpc_timer client_load_report_timer;
bool client_load_report_timer_pending;
bool last_client_load_report_counters_were_zero;
@ -1140,7 +1140,7 @@ static void query_for_backends_locked(grpc_exec_ctx *exec_ctx,
static void start_picking_locked(grpc_exec_ctx *exec_ctx,
glb_lb_policy *glb_policy) {
glb_policy->started_picking = true;
gpr_backoff_reset(&glb_policy->lb_call_backoff_state);
grpc_backoff_reset(&glb_policy->lb_call_backoff_state);
query_for_backends_locked(exec_ctx, glb_policy);
}
@ -1245,15 +1245,14 @@ static void send_client_load_report_locked(grpc_exec_ctx *exec_ctx, void *arg,
static void schedule_next_client_load_report(grpc_exec_ctx *exec_ctx,
glb_lb_policy *glb_policy) {
const gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
const gpr_timespec next_client_load_report_time =
gpr_time_add(now, glb_policy->client_stats_report_interval);
const grpc_millis next_client_load_report_time =
grpc_exec_ctx_now(exec_ctx) + glb_policy->client_stats_report_interval;
GRPC_CLOSURE_INIT(&glb_policy->client_load_report_closure,
send_client_load_report_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner));
grpc_timer_init(exec_ctx, &glb_policy->client_load_report_timer,
next_client_load_report_time,
&glb_policy->client_load_report_closure, now);
&glb_policy->client_load_report_closure);
}
static void client_load_report_done_locked(grpc_exec_ctx *exec_ctx, void *arg,
@ -1392,12 +1391,12 @@ static void lb_call_init_locked(grpc_exec_ctx *exec_ctx,
lb_on_response_received_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner));
gpr_backoff_init(&glb_policy->lb_call_backoff_state,
GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS,
GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER,
GRPC_GRPCLB_RECONNECT_JITTER,
GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
grpc_backoff_init(&glb_policy->lb_call_backoff_state,
GRPC_GRPCLB_INITIAL_CONNECT_BACKOFF_SECONDS,
GRPC_GRPCLB_RECONNECT_BACKOFF_MULTIPLIER,
GRPC_GRPCLB_RECONNECT_JITTER,
GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
glb_policy->initial_request_sent = false;
glb_policy->seen_initial_response = false;
@ -1522,7 +1521,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg,
memset(ops, 0, sizeof(ops));
grpc_op *op = ops;
if (glb_policy->lb_response_payload != NULL) {
gpr_backoff_reset(&glb_policy->lb_call_backoff_state);
grpc_backoff_reset(&glb_policy->lb_call_backoff_state);
/* Received data from the LB server. Look inside
* glb_policy->lb_response_payload, for a serverlist. */
grpc_byte_buffer_reader bbr;
@ -1535,16 +1534,14 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg,
(response = grpc_grpclb_initial_response_parse(response_slice)) !=
NULL) {
if (response->has_client_stats_report_interval) {
glb_policy->client_stats_report_interval =
gpr_time_max(gpr_time_from_seconds(1, GPR_TIMESPAN),
grpc_grpclb_duration_to_timespec(
&response->client_stats_report_interval));
glb_policy->client_stats_report_interval = GPR_MAX(
GPR_MS_PER_SEC, grpc_grpclb_duration_to_millis(
&response->client_stats_report_interval));
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_INFO,
"received initial LB response message; "
"client load reporting interval = %" PRId64 ".%09d sec",
glb_policy->client_stats_report_interval.tv_sec,
glb_policy->client_stats_report_interval.tv_nsec);
"client load reporting interval = %" PRIdPTR " milliseconds",
glb_policy->client_stats_report_interval);
}
/* take a weak ref (won't prevent calling of \a glb_shutdown() if the
* strong ref count goes to zero) to be unref'd in
@ -1675,17 +1672,16 @@ static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx,
glb_policy->updating_lb_call = false;
} else if (!glb_policy->shutting_down) {
/* if we aren't shutting down, restart the LB client call after some time */
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try =
gpr_backoff_step(&glb_policy->lb_call_backoff_state, now);
grpc_millis next_try =
grpc_backoff_step(exec_ctx, &glb_policy->lb_call_backoff_state);
if (GRPC_TRACER_ON(grpc_lb_glb_trace)) {
gpr_log(GPR_DEBUG, "Connection to LB server lost (grpclb: %p)...",
(void *)glb_policy);
gpr_timespec timeout = gpr_time_sub(next_try, now);
if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx);
if (timeout > 0) {
gpr_log(GPR_DEBUG,
"... retry_timer_active in %" PRId64 ".%09d seconds.",
timeout.tv_sec, timeout.tv_nsec);
"... retry_timer_active in %" PRIdPTR " milliseconds.",
timeout);
} else {
gpr_log(GPR_DEBUG, "... retry_timer_active immediately.");
}
@ -1696,7 +1692,7 @@ static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx,
grpc_combiner_scheduler(glb_policy->base.combiner));
glb_policy->retry_timer_active = true;
grpc_timer_init(exec_ctx, &glb_policy->lb_call_retry_timer, next_try,
&glb_policy->lb_on_call_retry, now);
&glb_policy->lb_on_call_retry);
}
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"lb_on_server_status_received");

@ -258,13 +258,10 @@ int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
return 0;
}
gpr_timespec grpc_grpclb_duration_to_timespec(
grpc_grpclb_duration *duration_pb) {
gpr_timespec duration;
duration.tv_sec = duration_pb->has_seconds ? duration_pb->seconds : 0;
duration.tv_nsec = duration_pb->has_nanos ? duration_pb->nanos : 0;
duration.clock_type = GPR_TIMESPAN;
return duration;
grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration *duration_pb) {
return (duration_pb->has_seconds ? duration_pb->seconds : 0) *
GPR_MS_PER_SEC +
(duration_pb->has_nanos ? duration_pb->nanos : 0) / GPR_NS_PER_MS;
}
void grpc_grpclb_initial_response_destroy(

@ -81,8 +81,7 @@ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist);
int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
const grpc_grpclb_duration *rhs);
gpr_timespec grpc_grpclb_duration_to_timespec(
grpc_grpclb_duration *duration_pb);
grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration *duration_pb);
/** Destroy \a initial_response */
void grpc_grpclb_initial_response_destroy(

@ -29,11 +29,11 @@
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/ext/filters/client_channel/resolver_registry.h"
#include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/support/backoff.h"
#include "src/core/lib/support/env.h"
#include "src/core/lib/support/string.h"
@ -81,7 +81,7 @@ typedef struct {
bool have_retry_timer;
grpc_timer retry_timer;
/** retry backoff state */
gpr_backoff backoff_state;
grpc_backoff backoff_state;
/** currently resolving addresses */
grpc_lb_addresses *lb_addresses;
@ -127,7 +127,7 @@ static void dns_ares_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
grpc_resolver *resolver) {
ares_dns_resolver *r = (ares_dns_resolver *)resolver;
if (!r->resolving) {
gpr_backoff_reset(&r->backoff_state);
grpc_backoff_reset(&r->backoff_state);
dns_ares_start_resolving_locked(exec_ctx, r);
}
}
@ -158,22 +158,20 @@ static void dns_ares_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg,
} else {
const char *msg = grpc_error_string(error);
gpr_log(GPR_DEBUG, "dns resolution failed: %s", msg);
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
gpr_timespec timeout = gpr_time_sub(next_try, now);
grpc_millis next_try = grpc_backoff_step(exec_ctx, &r->backoff_state);
grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx);
gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
grpc_error_string(error));
GPR_ASSERT(!r->have_retry_timer);
r->have_retry_timer = true;
GRPC_RESOLVER_REF(&r->base, "retry-timer");
if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec,
timeout.tv_nsec);
if (timeout > 0) {
gpr_log(GPR_DEBUG, "retrying in %" PRIdPTR " milliseconds", timeout);
} else {
gpr_log(GPR_DEBUG, "retrying immediately");
}
grpc_timer_init(exec_ctx, &r->retry_timer, next_try,
&r->dns_ares_on_retry_timer_locked, now);
&r->dns_ares_on_retry_timer_locked);
}
if (r->resolved_result != NULL) {
grpc_channel_args_destroy(exec_ctx, r->resolved_result);
@ -194,7 +192,7 @@ static void dns_ares_next_locked(grpc_exec_ctx *exec_ctx,
r->next_completion = on_complete;
r->target_result = target_result;
if (r->resolved_version == 0 && !r->resolving) {
gpr_backoff_reset(&r->backoff_state);
grpc_backoff_reset(&r->backoff_state);
dns_ares_start_resolving_locked(exec_ctx, r);
} else {
dns_ares_maybe_finish_next_locked(exec_ctx, r);
@ -261,11 +259,11 @@ static grpc_resolver *dns_ares_create(grpc_exec_ctx *exec_ctx,
grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
args->pollset_set);
}
gpr_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS,
GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER,
GRPC_DNS_RECONNECT_JITTER,
GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
grpc_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS,
GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER,
GRPC_DNS_RECONNECT_JITTER,
GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
GRPC_CLOSURE_INIT(&r->dns_ares_on_retry_timer_locked,
dns_ares_on_retry_timer_locked, r,
grpc_combiner_scheduler(r->base.combiner));

@ -24,11 +24,11 @@
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/ext/filters/client_channel/resolver_registry.h"
#include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/support/backoff.h"
#include "src/core/lib/support/env.h"
#include "src/core/lib/support/string.h"
@ -67,7 +67,7 @@ typedef struct {
grpc_timer retry_timer;
grpc_closure on_retry;
/** retry backoff state */
gpr_backoff backoff_state;
grpc_backoff backoff_state;
/** currently resolving addresses */
grpc_resolved_addresses *addresses;
@ -110,7 +110,7 @@ static void dns_channel_saw_error_locked(grpc_exec_ctx *exec_ctx,
grpc_resolver *resolver) {
dns_resolver *r = (dns_resolver *)resolver;
if (!r->resolving) {
gpr_backoff_reset(&r->backoff_state);
grpc_backoff_reset(&r->backoff_state);
dns_start_resolving_locked(exec_ctx, r);
}
}
@ -123,7 +123,7 @@ static void dns_next_locked(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
r->next_completion = on_complete;
r->target_result = target_result;
if (r->resolved_version == 0 && !r->resolving) {
gpr_backoff_reset(&r->backoff_state);
grpc_backoff_reset(&r->backoff_state);
dns_start_resolving_locked(exec_ctx, r);
} else {
dns_maybe_finish_next_locked(exec_ctx, r);
@ -164,23 +164,21 @@ static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_resolved_addresses_destroy(r->addresses);
grpc_lb_addresses_destroy(exec_ctx, addresses);
} else {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
gpr_timespec timeout = gpr_time_sub(next_try, now);
grpc_millis next_try = grpc_backoff_step(exec_ctx, &r->backoff_state);
grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx);
gpr_log(GPR_INFO, "dns resolution failed (will retry): %s",
grpc_error_string(error));
GPR_ASSERT(!r->have_retry_timer);
r->have_retry_timer = true;
GRPC_RESOLVER_REF(&r->base, "retry-timer");
if (gpr_time_cmp(timeout, gpr_time_0(timeout.clock_type)) > 0) {
gpr_log(GPR_DEBUG, "retrying in %" PRId64 ".%09d seconds", timeout.tv_sec,
timeout.tv_nsec);
if (timeout > 0) {
gpr_log(GPR_DEBUG, "retrying in %" PRIdPTR " milliseconds", timeout);
} else {
gpr_log(GPR_DEBUG, "retrying immediately");
}
GRPC_CLOSURE_INIT(&r->on_retry, dns_on_retry_timer_locked, r,
grpc_combiner_scheduler(r->base.combiner));
grpc_timer_init(exec_ctx, &r->retry_timer, next_try, &r->on_retry, now);
grpc_timer_init(exec_ctx, &r->retry_timer, next_try, &r->on_retry);
}
if (r->resolved_result != NULL) {
grpc_channel_args_destroy(exec_ctx, r->resolved_result);
@ -251,11 +249,11 @@ static grpc_resolver *dns_create(grpc_exec_ctx *exec_ctx,
grpc_pollset_set_add_pollset_set(exec_ctx, r->interested_parties,
args->pollset_set);
}
gpr_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS,
GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER,
GRPC_DNS_RECONNECT_JITTER,
GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
grpc_backoff_init(&r->backoff_state, GRPC_DNS_INITIAL_CONNECT_BACKOFF_SECONDS,
GRPC_DNS_RECONNECT_BACKOFF_MULTIPLIER,
GRPC_DNS_RECONNECT_JITTER,
GRPC_DNS_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
GRPC_DNS_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
return &r->base;
}

@ -30,13 +30,13 @@
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
#include "src/core/ext/filters/client_channel/subchannel_index.h"
#include "src/core/ext/filters/client_channel/uri_parser.h"
#include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/iomgr/sockaddr_utils.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/support/backoff.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/connectivity_state.h"
@ -118,7 +118,7 @@ struct grpc_subchannel {
/** next connect attempt time */
grpc_millis next_attempt;
/** backoff state */
gpr_backoff backoff_state;
grpc_backoff backoff_state;
/** do we have an active alarm? */
bool have_alarm;
/** have we started the backoff loop */
@ -363,7 +363,7 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx,
}
}
}
gpr_backoff_init(
grpc_backoff_init(
&c->backoff_state, initial_backoff_ms,
fixed_reconnect_backoff ? 1.0
: GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER,
@ -427,8 +427,7 @@ static void on_alarm(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
}
if (error == GRPC_ERROR_NONE) {
gpr_log(GPR_INFO, "Failed to connect to channel, retrying");
c->next_attempt =
gpr_backoff_step(&c->backoff_state, gpr_now(GPR_CLOCK_MONOTONIC));
c->next_attempt = grpc_backoff_step(exec_ctx, &c->backoff_state);
continue_connect_locked(exec_ctx, c);
gpr_mu_unlock(&c->mu);
} else {
@ -465,21 +464,20 @@ static void maybe_start_connecting_locked(grpc_exec_ctx *exec_ctx,
if (!c->backoff_begun) {
c->backoff_begun = true;
c->next_attempt = gpr_backoff_begin(&c->backoff_state, now);
c->next_attempt = grpc_backoff_begin(exec_ctx, &c->backoff_state);
continue_connect_locked(exec_ctx, c);
} else {
GPR_ASSERT(!c->have_alarm);
c->have_alarm = true;
gpr_timespec time_til_next = gpr_time_sub(c->next_attempt, now);
if (gpr_time_cmp(time_til_next, gpr_time_0(time_til_next.clock_type)) <=
0) {
const grpc_millis time_til_next =
c->next_attempt - grpc_exec_ctx_now(exec_ctx);
if (time_til_next <= 0) {
gpr_log(GPR_INFO, "Retry immediately");
} else {
gpr_log(GPR_INFO, "Retry in %" PRId64 ".%09d seconds",
time_til_next.tv_sec, time_til_next.tv_nsec);
gpr_log(GPR_INFO, "Retry in %" PRIdPTR " milliseconds", time_til_next);
}
GRPC_CLOSURE_INIT(&c->on_alarm, on_alarm, c, grpc_schedule_on_exec_ctx);
grpc_timer_init(exec_ctx, &c->alarm, c->next_attempt, &c->on_alarm, now);
grpc_timer_init(exec_ctx, &c->alarm, c->next_attempt, &c->on_alarm);
}
}

@ -53,8 +53,8 @@ static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg,
static void start_timer_if_needed(grpc_exec_ctx* exec_ctx,
grpc_call_element* elem,
gpr_timespec deadline) {
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) == 0) {
grpc_millis deadline_millis = grpc_timespec_to_millis(deadline);
if (deadline_millis == GRPC_MILLIS_INF_FUTURE) {
return;
}
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
@ -94,8 +94,7 @@ retry:
}
GPR_ASSERT(closure);
GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer");
grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, closure,
gpr_now(GPR_CLOCK_MONOTONIC));
grpc_timer_init(exec_ctx, &deadline_state->timer, deadline_millis, closure);
}
// Cancels the deadline timer.

@ -56,11 +56,11 @@ typedef struct channel_data {
max_connection_idle */
grpc_timer max_idle_timer;
/* Allowed max time a channel may have no outstanding rpcs */
gpr_timespec max_connection_idle;
grpc_millis max_connection_idle;
/* Allowed max time a channel may exist */
gpr_timespec max_connection_age;
grpc_millis max_connection_age;
/* Allowed grace period after the channel reaches its max age */
gpr_timespec max_connection_age_grace;
grpc_millis max_connection_age_grace;
/* Closure to run when the channel's idle duration reaches max_connection_idle
and should be closed gracefully */
grpc_closure close_max_idle_channel;
@ -99,10 +99,9 @@ static void increase_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) {
static void decrease_call_count(grpc_exec_ctx* exec_ctx, channel_data* chand) {
if (gpr_atm_full_fetch_add(&chand->call_count, -1) == 1) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_idle_timer");
grpc_timer_init(
exec_ctx, &chand->max_idle_timer,
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), chand->max_connection_idle),
&chand->close_max_idle_channel, gpr_now(GPR_CLOCK_MONOTONIC));
grpc_timer_init(exec_ctx, &chand->max_idle_timer,
grpc_exec_ctx_now(exec_ctx) + chand->max_connection_idle,
&chand->close_max_idle_channel);
}
}
@ -123,10 +122,9 @@ static void start_max_age_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg,
gpr_mu_lock(&chand->max_age_timer_mu);
chand->max_age_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_timer");
grpc_timer_init(
exec_ctx, &chand->max_age_timer,
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), chand->max_connection_age),
&chand->close_max_age_channel, gpr_now(GPR_CLOCK_MONOTONIC));
grpc_timer_init(exec_ctx, &chand->max_age_timer,
grpc_exec_ctx_now(exec_ctx) + chand->max_connection_age,
&chand->close_max_age_channel);
gpr_mu_unlock(&chand->max_age_timer_mu);
grpc_transport_op* op = grpc_make_transport_op(NULL);
op->on_connectivity_state_change = &chand->channel_connectivity_changed,
@ -145,10 +143,8 @@ static void start_max_age_grace_timer_after_goaway_op(grpc_exec_ctx* exec_ctx,
chand->max_age_grace_timer_pending = true;
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_grace_timer");
grpc_timer_init(exec_ctx, &chand->max_age_grace_timer,
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
chand->max_connection_age_grace),
&chand->force_close_max_age_channel,
gpr_now(GPR_CLOCK_MONOTONIC));
grpc_exec_ctx_now(exec_ctx) + chand->max_connection_age_grace,
&chand->force_close_max_age_channel);
gpr_mu_unlock(&chand->max_age_timer_mu);
GRPC_CHANNEL_STACK_UNREF(exec_ctx, chand->channel_stack,
"max_age start_max_age_grace_timer_after_goaway_op");
@ -288,29 +284,23 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
chand->channel_stack = args->channel_stack;
chand->max_connection_age =
DEFAULT_MAX_CONNECTION_AGE_MS == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(add_random_max_connection_age_jitter(
DEFAULT_MAX_CONNECTION_AGE_MS),
GPR_TIMESPAN);
? GRPC_MILLIS_INF_FUTURE
: add_random_max_connection_age_jitter(DEFAULT_MAX_CONNECTION_AGE_MS);
chand->max_connection_age_grace =
DEFAULT_MAX_CONNECTION_AGE_GRACE_MS == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(DEFAULT_MAX_CONNECTION_AGE_GRACE_MS,
GPR_TIMESPAN);
chand->max_connection_idle =
DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(DEFAULT_MAX_CONNECTION_IDLE_MS, GPR_TIMESPAN);
? GRPC_MILLIS_INF_FUTURE
: DEFAULT_MAX_CONNECTION_AGE_GRACE_MS;
chand->max_connection_idle = DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX
? GRPC_MILLIS_INF_FUTURE
: DEFAULT_MAX_CONNECTION_IDLE_MS;
for (size_t i = 0; i < args->channel_args->num_args; ++i) {
if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_AGE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i], MAX_CONNECTION_AGE_INTEGER_OPTIONS);
chand->max_connection_age =
value == INT_MAX
? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(
add_random_max_connection_age_jitter(value), GPR_TIMESPAN);
value == INT_MAX ? GRPC_MILLIS_INF_FUTURE
: add_random_max_connection_age_jitter(value);
} else if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS)) {
const int value = grpc_channel_arg_get_integer(
@ -318,15 +308,13 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
(grpc_integer_options){DEFAULT_MAX_CONNECTION_AGE_GRACE_MS, 0,
INT_MAX});
chand->max_connection_age_grace =
value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(value, GPR_TIMESPAN);
value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
} else if (0 == strcmp(args->channel_args->args[i].key,
GRPC_ARG_MAX_CONNECTION_IDLE_MS)) {
const int value = grpc_channel_arg_get_integer(
&args->channel_args->args[i], MAX_CONNECTION_IDLE_INTEGER_OPTIONS);
chand->max_connection_idle =
value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN)
: gpr_time_from_millis(value, GPR_TIMESPAN);
value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
}
}
GRPC_CLOSURE_INIT(&chand->close_max_idle_channel, close_max_idle_channel,
@ -349,8 +337,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
channel_connectivity_changed, chand,
grpc_schedule_on_exec_ctx);
if (gpr_time_cmp(chand->max_connection_age, gpr_inf_future(GPR_TIMESPAN)) !=
0) {
if (chand->max_connection_age != GRPC_MILLIS_INF_FUTURE) {
/* When the channel reaches its max age, we send down an op with
goaway_error set. However, we can't send down any ops until after the
channel stack is fully initialized. If we start the timer here, we have
@ -367,8 +354,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
/* Initialize the number of calls as 1, so that the max_idle_timer will not
start until start_max_idle_timer_after_init is invoked. */
gpr_atm_rel_store(&chand->call_count, 1);
if (gpr_time_cmp(chand->max_connection_idle, gpr_inf_future(GPR_TIMESPAN)) !=
0) {
if (chand->max_connection_idle != GRPC_MILLIS_INF_FUTURE) {
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
"max_age start_max_idle_timer_after_init");
GRPC_CLOSURE_SCHED(exec_ctx, &chand->start_max_idle_timer_after_init,

@ -16,13 +16,13 @@
*
*/
#include "src/core/lib/support/backoff.h"
#include "src/core/lib/backoff/backoff.h"
#include <grpc/support/useful.h>
void gpr_backoff_init(gpr_backoff *backoff, int64_t initial_connect_timeout,
double multiplier, double jitter,
int64_t min_timeout_millis, int64_t max_timeout_millis) {
void grpc_backoff_init(grpc_backoff *backoff, int64_t initial_connect_timeout,
double multiplier, double jitter,
int64_t min_timeout_millis, int64_t max_timeout_millis) {
backoff->initial_connect_timeout = initial_connect_timeout;
backoff->multiplier = multiplier;
backoff->jitter = jitter;
@ -31,11 +31,11 @@ void gpr_backoff_init(gpr_backoff *backoff, int64_t initial_connect_timeout,
backoff->rng_state = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec;
}
gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now) {
grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff) {
backoff->current_timeout_millis = backoff->initial_connect_timeout;
const int64_t first_timeout =
GPR_MAX(backoff->current_timeout_millis, backoff->min_timeout_millis);
return gpr_time_add(now, gpr_time_from_millis(first_timeout, GPR_TIMESPAN));
return grpc_exec_ctx_now(exec_ctx) + first_timeout;
}
/* Generate a random number between 0 and 1. */
@ -44,7 +44,7 @@ static double generate_uniform_random_number(uint32_t *rng_state) {
return *rng_state / (double)((uint32_t)1 << 31);
}
gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now) {
grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff) {
const double new_timeout_millis =
backoff->multiplier * (double)backoff->current_timeout_millis;
backoff->current_timeout_millis =
@ -58,15 +58,15 @@ gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now) {
backoff->current_timeout_millis =
(int64_t)((double)(backoff->current_timeout_millis) + jitter);
const gpr_timespec current_deadline = gpr_time_add(
now, gpr_time_from_millis(backoff->current_timeout_millis, GPR_TIMESPAN));
const grpc_millis current_deadline =
grpc_exec_ctx_now(exec_ctx) + backoff->current_timeout_millis;
const gpr_timespec min_deadline = gpr_time_add(
now, gpr_time_from_millis(backoff->min_timeout_millis, GPR_TIMESPAN));
const grpc_millis min_deadline =
grpc_exec_ctx_now(exec_ctx) + backoff->min_timeout_millis;
return gpr_time_max(current_deadline, min_deadline);
return GPR_MAX(current_deadline, min_deadline);
}
void gpr_backoff_reset(gpr_backoff *backoff) {
void grpc_backoff_reset(grpc_backoff *backoff) {
backoff->current_timeout_millis = backoff->initial_connect_timeout;
}

@ -19,7 +19,7 @@
#ifndef GRPC_CORE_LIB_SUPPORT_BACKOFF_H
#define GRPC_CORE_LIB_SUPPORT_BACKOFF_H
#include <grpc/support/time.h>
#include "src/core/lib/iomgr/exec_ctx.h"
typedef struct {
/// const: how long to wait after the first failure before retrying
@ -38,19 +38,20 @@ typedef struct {
/// current retry timeout in milliseconds
int64_t current_timeout_millis;
} gpr_backoff;
} grpc_backoff;
/// Initialize backoff machinery - does not need to be destroyed
void gpr_backoff_init(gpr_backoff *backoff, int64_t initial_connect_timeout,
double multiplier, double jitter,
int64_t min_timeout_millis, int64_t max_timeout_millis);
void grpc_backoff_init(grpc_backoff *backoff, int64_t initial_connect_timeout,
double multiplier, double jitter,
int64_t min_timeout_millis, int64_t max_timeout_millis);
/// Begin retry loop: returns a timespec for the NEXT retry
gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now);
grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff);
/// Step a retry loop: returns a timespec for the NEXT retry
gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now);
/// Reset the backoff, so the next gpr_backoff_step will be a gpr_backoff_begin
grpc_millis grpc_backoff_step(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff);
/// Reset the backoff, so the next grpc_backoff_step will be a
/// grpc_backoff_begin
/// instead
void gpr_backoff_reset(gpr_backoff *backoff);
void grpc_backoff_reset(grpc_backoff *backoff);
#endif /* GRPC_CORE_LIB_SUPPORT_BACKOFF_H */

@ -137,13 +137,17 @@ void grpc_exec_ctx_invalidate_now(grpc_exec_ctx *exec_ctx) {
exec_ctx->now_is_valid = false;
}
gpr_timespec grpc_millis_to_timespec(grpc_exec_ctx *exec_ctx,
grpc_millis millis,
gpr_timespec grpc_millis_to_timespec(grpc_millis millis,
gpr_clock_type clock_type) {
return gpr_time_add(gpr_convert_clock_type(g_start_time, clock_type),
gpr_time_from_millis(millis, GPR_TIMESPAN));
}
grpc_millis grpc_timespec_to_millis(gpr_timespec ts) {
return timespec_to_atm_round_down(
gpr_convert_clock_type(ts, g_start_time.clock_type));
}
static const grpc_closure_scheduler_vtable exec_ctx_scheduler_vtable = {
exec_ctx_run, exec_ctx_sched, "exec_ctx"};
static grpc_closure_scheduler exec_ctx_scheduler = {&exec_ctx_scheduler_vtable};

@ -113,9 +113,7 @@ void grpc_exec_ctx_global_shutdown(void);
grpc_millis grpc_exec_ctx_now(grpc_exec_ctx *exec_ctx);
void grpc_exec_ctx_invalidate_now(grpc_exec_ctx *exec_ctx);
gpr_timespec grpc_millis_to_timespec(grpc_exec_ctx *exec_ctx,
grpc_millis millis, gpr_clock_type clock);
grpc_millis grpc_timespec_to_millis(grpc_exec_ctx *exec_ctx,
gpr_timespec timespec);
gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock);
grpc_millis grpc_timespec_to_millis(gpr_timespec timespec);
#endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */

@ -188,7 +188,7 @@ static bool wait_until(grpc_exec_ctx *exec_ctx, grpc_millis next) {
}
gpr_cv_wait(&g_cv_wait, &g_mu,
grpc_millis_to_timespec(exec_ctx, next, GPR_CLOCK_REALTIME));
grpc_millis_to_timespec(next, GPR_CLOCK_REALTIME));
if (GRPC_TRACER_ON(grpc_timer_check_trace)) {
gpr_log(GPR_DEBUG, "wait ended: was_timed:%d kicked:%d",

@ -52,8 +52,7 @@ grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline,
grpc_cq_begin_op(cq, tag);
GRPC_CLOSURE_INIT(&alarm->on_alarm, alarm_cb, alarm,
grpc_schedule_on_exec_ctx);
grpc_timer_init(&exec_ctx, &alarm->alarm,
grpc_timespec_to_millis(&exec_ctx, deadline),
grpc_timer_init(&exec_ctx, &alarm->alarm, grpc_timespec_to_millis(deadline),
&alarm->on_alarm);
grpc_exec_ctx_finish(&exec_ctx);
return alarm;

@ -110,7 +110,7 @@ static grpc_error *non_polling_poller_work(grpc_exec_ctx *exec_ctx,
}
w.kicked = false;
gpr_timespec deadline_ts =
grpc_millis_to_timespec(exec_ctx, deadline, GPR_CLOCK_REALTIME);
grpc_millis_to_timespec(deadline, GPR_CLOCK_REALTIME);
while (!npp->shutdown && !w.kicked &&
!gpr_cv_wait(&w.cv, &npp->mu, deadline_ts))
;
@ -815,18 +815,17 @@ static grpc_event cq_next(grpc_completion_queue *cq, gpr_timespec deadline,
GRPC_CQ_INTERNAL_REF(cq, "next");
grpc_millis deadline_millis = grpc_timespec_to_millis(deadline);
cq_is_finished_arg is_finished_arg = {
.last_seen_things_queued_ever =
gpr_atm_no_barrier_load(&cqd->things_queued_ever),
.cq = cq,
.deadline = 0,
.deadline = deadline_millis,
.stolen_completion = NULL,
.tag = NULL,
.first_loop = true};
grpc_exec_ctx exec_ctx =
GRPC_EXEC_CTX_INITIALIZER(0, cq_is_next_finished, &is_finished_arg);
grpc_millis deadline_millis = is_finished_arg.deadline =
grpc_timespec_to_millis(&exec_ctx, deadline);
for (;;) {
grpc_millis iteration_deadline = deadline_millis;
@ -1047,22 +1046,19 @@ static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag,
dump_pending_tags(cq);
deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC);
GRPC_CQ_INTERNAL_REF(cq, "pluck");
gpr_mu_lock(cq->mu);
grpc_millis deadline_millis = grpc_timespec_to_millis(deadline);
cq_is_finished_arg is_finished_arg = {
.last_seen_things_queued_ever =
gpr_atm_no_barrier_load(&cqd->things_queued_ever),
.cq = cq,
.deadline = 0,
.deadline = deadline_millis,
.stolen_completion = NULL,
.tag = tag,
.first_loop = true};
grpc_exec_ctx exec_ctx =
GRPC_EXEC_CTX_INITIALIZER(0, cq_is_pluck_finished, &is_finished_arg);
grpc_millis deadline_millis = is_finished_arg.deadline =
grpc_timespec_to_millis(&exec_ctx, deadline);
for (;;) {
if (is_finished_arg.stolen_completion != NULL) {
gpr_mu_unlock(cq->mu);

@ -15,13 +15,13 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!!
CORE_SOURCE_FILES = [
'src/core/lib/backoff/backoff.c',
'src/core/lib/profiling/basic_timers.c',
'src/core/lib/profiling/stap_timers.c',
'src/core/lib/support/alloc.c',
'src/core/lib/support/arena.c',
'src/core/lib/support/atm.c',
'src/core/lib/support/avl.c',
'src/core/lib/support/backoff.c',
'src/core/lib/support/cmdline.c',
'src/core/lib/support/cpu_iphone.c',
'src/core/lib/support/cpu_linux.c',

@ -0,0 +1,34 @@
# Copyright 2016 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary")
licenses(["notice"]) # Apache v2
package(
features = [
"-layering_check",
"-parse_headers",
],
)
grpc_cc_test(
name = "backoff_test",
srcs = ["backoff_test.c"],
language = "C",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
],
)

@ -0,0 +1,147 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "src/core/lib/backoff/backoff.h"
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
static void test_constant_backoff(void) {
grpc_backoff backoff;
grpc_backoff_init(&backoff, 200 /* initial timeout */, 1.0 /* multiplier */,
0.0 /* jitter */, 100 /* min timeout */,
1000 /* max timeout */);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200);
for (int i = 0; i < 10000; i++) {
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200);
exec_ctx.now = next;
}
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_min_connect(void) {
grpc_backoff backoff;
grpc_backoff_init(&backoff, 100 /* initial timeout */, 1.0 /* multiplier */,
0.0 /* jitter */, 200 /* min timeout */,
1000 /* max timeout */);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 200);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_no_jitter_backoff(void) {
grpc_backoff backoff;
grpc_backoff_init(&backoff, 2 /* initial timeout */, 2.0 /* multiplier */,
0.0 /* jitter */, 1 /* min timeout */,
513 /* max timeout */);
// x_1 = 2
// x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 6);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 14);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 30);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 62);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 126);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 254);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 510);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 1022);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
// Hit the maximum timeout. From this point onwards, retries will increase
// only by max timeout.
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 1535);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2048);
exec_ctx.now = next;
next = grpc_backoff_step(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 2561);
grpc_exec_ctx_finish(&exec_ctx);
}
static void test_jitter_backoff(void) {
const int64_t initial_timeout = 500;
const double jitter = 0.1;
grpc_backoff backoff;
grpc_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter,
100 /* min timeout */, 1000 /* max timeout */);
backoff.rng_state = 0; // force consistent PRNG
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis next = grpc_backoff_begin(&exec_ctx, &backoff);
GPR_ASSERT(next - grpc_exec_ctx_now(&exec_ctx) == 500);
int64_t expected_next_lower_bound =
(int64_t)((double)initial_timeout * (1 - jitter));
int64_t expected_next_upper_bound =
(int64_t)((double)initial_timeout * (1 + jitter));
for (int i = 0; i < 10000; i++) {
next = grpc_backoff_step(&exec_ctx, &backoff);
// next-now must be within (jitter*100)% of the previous timeout.
const int64_t timeout_millis = next - grpc_exec_ctx_now(&exec_ctx);
GPR_ASSERT(timeout_millis >= expected_next_lower_bound);
GPR_ASSERT(timeout_millis <= expected_next_upper_bound);
expected_next_lower_bound =
(int64_t)((double)timeout_millis * (1 - jitter));
expected_next_upper_bound =
(int64_t)((double)timeout_millis * (1 + jitter));
exec_ctx.now = next;
}
grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
gpr_time_init();
test_constant_backoff();
test_min_connect();
test_no_jitter_backoff();
test_jitter_backoff();
return 0;
}

@ -105,7 +105,7 @@ static bool wait_loop(int deadline_seconds, gpr_event *ev) {
deadline_seconds--;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_timer_check(&exec_ctx, gpr_now(GPR_CLOCK_MONOTONIC), NULL);
grpc_timer_check(&exec_ctx, NULL);
grpc_exec_ctx_finish(&exec_ctx);
}
return false;

@ -406,10 +406,8 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr,
r->addrs = addresses;
r->lb_addrs = NULL;
grpc_timer_init(
exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(1, GPR_TIMESPAN)),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx),
gpr_now(GPR_CLOCK_MONOTONIC));
exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
}
grpc_ares_request *my_dns_lookup_ares(
@ -422,10 +420,8 @@ grpc_ares_request *my_dns_lookup_ares(
r->addrs = NULL;
r->lb_addrs = lb_addrs;
grpc_timer_init(
exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(1, GPR_TIMESPAN)),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx),
gpr_now(GPR_CLOCK_MONOTONIC));
exec_ctx, &r->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
GRPC_CLOSURE_CREATE(finish_resolve, r, grpc_schedule_on_exec_ctx));
return NULL;
}
@ -485,10 +481,8 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
fc->ep = ep;
fc->deadline = deadline;
grpc_timer_init(
exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_millis(1, GPR_TIMESPAN)),
GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx),
gpr_now(GPR_CLOCK_MONOTONIC));
exec_ctx, &fc->timer, GPR_MS_PER_SEC + grpc_exec_ctx_now(exec_ctx),
GRPC_CLOSURE_CREATE(do_connect, fc, grpc_schedule_on_exec_ctx));
}
static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx,

@ -35,8 +35,8 @@ static grpc_httpcli_context g_context;
static gpr_mu *g_mu;
static grpc_polling_entity g_pops;
static gpr_timespec n_seconds_time(int seconds) {
return grpc_timeout_seconds_to_deadline(seconds);
static grpc_millis n_seconds_time(int seconds) {
return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds));
}
static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
@ -86,8 +86,7 @@ static void test_get(int port) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&worker, gpr_now(GPR_CLOCK_MONOTONIC),
n_seconds_time(1))));
&worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@ -128,8 +127,7 @@ static void test_post(int port) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&worker, gpr_now(GPR_CLOCK_MONOTONIC),
n_seconds_time(1))));
&worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);

@ -35,8 +35,8 @@ static grpc_httpcli_context g_context;
static gpr_mu *g_mu;
static grpc_polling_entity g_pops;
static gpr_timespec n_seconds_time(int seconds) {
return grpc_timeout_seconds_to_deadline(seconds);
static grpc_millis n_seconds_time(int seconds) {
return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds));
}
static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
@ -87,8 +87,7 @@ static void test_get(int port) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&worker, gpr_now(GPR_CLOCK_MONOTONIC),
n_seconds_time(1))));
&worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@ -130,8 +129,7 @@ static void test_post(int port) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&g_pops),
&worker, gpr_now(GPR_CLOCK_MONOTONIC),
n_seconds_time(1))));
&worker, n_seconds_time(1))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);

@ -176,7 +176,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
begin_test(config, "read_and_write_test", slice_size);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis deadline =
grpc_timespec_to_millis(&exec_ctx, grpc_timeout_seconds_to_deadline(20));
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20));
gpr_log(GPR_DEBUG, "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR
" slice_size=%" PRIuPTR " shutdown=%d",
num_bytes, write_size, slice_size, shutdown);
@ -261,7 +261,7 @@ static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count,
grpc_exec_ctx_flush(exec_ctx);
gpr_mu_lock(g_mu);
grpc_millis deadline =
grpc_timespec_to_millis(exec_ctx, grpc_timeout_seconds_to_deadline(10));
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10));
while (grpc_exec_ctx_now(exec_ctx) < deadline &&
*fail_count < want_fail_count) {
grpc_pollset_worker *worker = NULL;

@ -249,10 +249,8 @@ static void server_wait_and_shutdown(server *sv) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC))));
"pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@ -367,10 +365,8 @@ static void client_wait_and_shutdown(client *cl) {
grpc_pollset_worker *worker = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC))));
"pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@ -473,10 +469,8 @@ static void test_grpc_fd_change(void) {
while (a.cb_that_ran == NULL) {
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC))));
"pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@ -499,10 +493,8 @@ static void test_grpc_fd_change(void) {
while (b.cb_that_ran == NULL) {
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
gpr_inf_future(GPR_CLOCK_MONOTONIC))));
"pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
GRPC_MILLIS_INF_FUTURE)));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);

@ -70,35 +70,32 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) {
gpr_free(args->pollset);
}
static gpr_timespec n_sec_deadline(int seconds) {
return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(seconds, GPR_TIMESPAN));
static grpc_millis n_sec_deadline(int seconds) {
return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds));
}
static void actually_poll(void *argsp) {
args_struct *args = argsp;
gpr_timespec deadline = n_sec_deadline(10);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis deadline = n_sec_deadline(10);
while (true) {
bool done = gpr_atm_acq_load(&args->done_atm) != 0;
if (done) {
break;
}
gpr_timespec time_left =
gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME));
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done,
time_left.tv_sec, time_left.tv_nsec);
GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0);
grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx);
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker *worker = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker,
gpr_now(GPR_CLOCK_REALTIME), n_sec_deadline(1)));
GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker,
n_sec_deadline(1)));
gpr_mu_unlock(args->mu);
grpc_exec_ctx_finish(&exec_ctx);
grpc_exec_ctx_flush(&exec_ctx);
}
gpr_event_set(&args->ev, (void *)1);
grpc_exec_ctx_finish(&exec_ctx);
}
static void poll_pollset_until_request_done(args_struct *args) {

@ -67,34 +67,31 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) {
gpr_free(args->pollset);
}
static gpr_timespec n_sec_deadline(int seconds) {
return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(seconds, GPR_TIMESPAN));
static grpc_millis n_sec_deadline(int seconds) {
return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds));
}
static void poll_pollset_until_request_done(args_struct *args) {
gpr_timespec deadline = n_sec_deadline(10);
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis deadline = n_sec_deadline(10);
while (true) {
bool done = gpr_atm_acq_load(&args->done_atm) != 0;
if (done) {
break;
}
gpr_timespec time_left =
gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME));
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done,
time_left.tv_sec, time_left.tv_nsec);
GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0);
grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx);
gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left);
GPR_ASSERT(time_left >= 0);
grpc_pollset_worker *worker = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_mu_lock(args->mu);
GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker,
gpr_now(GPR_CLOCK_REALTIME), n_sec_deadline(1)));
GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker,
n_sec_deadline(1)));
gpr_mu_unlock(args->mu);
grpc_exec_ctx_finish(&exec_ctx);
grpc_exec_ctx_flush(&exec_ctx);
}
gpr_event_set(&args->ev, (void *)1);
grpc_exec_ctx_finish(&exec_ctx);
}
static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp,

@ -46,8 +46,8 @@ static grpc_pollset *g_pollset;
static int g_connections_complete = 0;
static grpc_endpoint *g_connecting = NULL;
static gpr_timespec test_deadline(void) {
return grpc_timeout_seconds_to_deadline(10);
static grpc_millis test_deadline(void) {
return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10));
}
static void finish_connection() {
@ -107,7 +107,7 @@ void test_succeeds(void) {
(socklen_t *)&resolved_addr.len) == 0);
GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx);
grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL,
&resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME));
&resolved_addr, GRPC_MILLIS_INF_FUTURE);
/* await the connection */
do {
@ -124,9 +124,9 @@ void test_succeeds(void) {
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
grpc_timeout_seconds_to_deadline(5))));
grpc_pollset_work(
&exec_ctx, g_pollset, &worker,
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(5)))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(g_mu);
@ -157,25 +157,24 @@ void test_fails(void) {
/* connect to a broken address */
GRPC_CLOSURE_INIT(&done, must_fail, NULL, grpc_schedule_on_exec_ctx);
grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL,
&resolved_addr, gpr_inf_future(GPR_CLOCK_REALTIME));
&resolved_addr, GRPC_MILLIS_INF_FUTURE);
gpr_mu_lock(g_mu);
/* wait for the connection callback to finish */
while (g_connections_complete == connections_complete_before) {
grpc_pollset_worker *worker = NULL;
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec polling_deadline = test_deadline();
switch (grpc_timer_check(&exec_ctx, now, &polling_deadline)) {
grpc_millis polling_deadline = test_deadline();
switch (grpc_timer_check(&exec_ctx, &polling_deadline)) {
case GRPC_TIMERS_FIRED:
break;
case GRPC_TIMERS_NOT_CHECKED:
polling_deadline = now;
polling_deadline = 0;
/* fall through */
case GRPC_TIMERS_CHECKED_AND_EMPTY:
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker,
now, polling_deadline)));
polling_deadline)));
break;
}
gpr_mu_unlock(g_mu);

@ -161,7 +161,8 @@ static void read_test(size_t num_bytes, size_t slice_size) {
grpc_endpoint *ep;
struct read_socket_state state;
size_t written_bytes;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
grpc_millis deadline =
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_INFO, "Read test of size %" PRIuPTR ", slice size %" PRIuPTR,
@ -193,8 +194,7 @@ static void read_test(size_t num_bytes, size_t slice_size) {
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@ -214,7 +214,8 @@ static void large_read_test(size_t slice_size) {
grpc_endpoint *ep;
struct read_socket_state state;
ssize_t written_bytes;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
grpc_millis deadline =
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_INFO, "Start large read test, slice size %" PRIuPTR, slice_size);
@ -245,8 +246,7 @@ static void large_read_test(size_t slice_size) {
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@ -318,8 +318,8 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC),
grpc_timeout_milliseconds_to_deadline(10))));
grpc_timespec_to_millis(
grpc_timeout_milliseconds_to_deadline(10)))));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
do {
@ -352,7 +352,8 @@ static void write_test(size_t num_bytes, size_t slice_size) {
uint8_t current_data = 0;
grpc_slice_buffer outgoing;
grpc_closure write_done_closure;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
grpc_millis deadline =
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_INFO,
@ -389,8 +390,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
}
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(g_mu);
@ -418,7 +418,8 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
struct read_socket_state state;
size_t written_bytes;
int fd;
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(20);
grpc_millis deadline =
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20));
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_closure fd_released_cb;
int fd_released_done = 0;
@ -456,8 +457,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
gpr_log(GPR_DEBUG, "wakeup: read=%" PRIdPTR " target=%" PRIdPTR,
state.read_bytes, state.target_read_bytes);
gpr_mu_unlock(g_mu);
@ -475,8 +475,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
gpr_log(GPR_DEBUG, "wakeup: fd_released_done=%d", fd_released_done);
}
gpr_mu_unlock(g_mu);

@ -230,7 +230,8 @@ static void test_no_op_with_port_and_start(void) {
static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote,
on_connect_result *result) {
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10);
grpc_millis deadline =
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10));
int clifd;
int nconnects_before;
const struct sockaddr *remote_addr =
@ -253,11 +254,10 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote,
}
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before &&
gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
deadline > grpc_exec_ctx_now(exec_ctx)) {
grpc_pollset_worker *worker = NULL;
grpc_error *err;
if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline)) !=
if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)) !=
GRPC_ERROR_NONE) {
gpr_mu_unlock(g_mu);
close(clifd);

@ -41,51 +41,45 @@ static void cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
}
static void add_test(void) {
gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
int i;
grpc_timer timers[20];
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
gpr_log(GPR_INFO, "add_test");
grpc_timer_list_init(start);
grpc_timer_list_init(&exec_ctx);
grpc_timer_trace.value = 1;
grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
grpc_millis start = grpc_exec_ctx_now(&exec_ctx);
/* 10 ms timers. will expire in the current epoch */
for (i = 0; i < 10; i++) {
grpc_timer_init(
&exec_ctx, &timers[i],
gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)),
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx),
start);
grpc_timer_init(&exec_ctx, &timers[i], start + 10,
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i,
grpc_schedule_on_exec_ctx));
}
/* 1010 ms timers. will expire in the next epoch */
for (i = 10; i < 20; i++) {
grpc_timer_init(
&exec_ctx, &timers[i],
gpr_time_add(start, gpr_time_from_millis(1010, GPR_TIMESPAN)),
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, grpc_schedule_on_exec_ctx),
start);
grpc_timer_init(&exec_ctx, &timers[i], start + 1010,
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i,
grpc_schedule_on_exec_ctx));
}
/* collect timers. Only the first batch should be ready. */
GPR_ASSERT(grpc_timer_check(
&exec_ctx,
gpr_time_add(start, gpr_time_from_millis(500, GPR_TIMESPAN)),
NULL) == GRPC_TIMERS_FIRED);
exec_ctx.now = start + 500;
GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED);
grpc_exec_ctx_finish(&exec_ctx);
for (i = 0; i < 20; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
GPR_ASSERT(cb_called[i][0] == 0);
}
GPR_ASSERT(grpc_timer_check(
&exec_ctx,
gpr_time_add(start, gpr_time_from_millis(600, GPR_TIMESPAN)),
NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY);
exec_ctx.now = start + 600;
GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) ==
GRPC_TIMERS_CHECKED_AND_EMPTY);
grpc_exec_ctx_finish(&exec_ctx);
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 10));
@ -93,20 +87,17 @@ static void add_test(void) {
}
/* collect the rest of the timers */
GPR_ASSERT(grpc_timer_check(
&exec_ctx,
gpr_time_add(start, gpr_time_from_millis(1500, GPR_TIMESPAN)),
NULL) == GRPC_TIMERS_FIRED);
exec_ctx.now = start + 1500;
GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED);
grpc_exec_ctx_finish(&exec_ctx);
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
GPR_ASSERT(cb_called[i][0] == 0);
}
GPR_ASSERT(grpc_timer_check(
&exec_ctx,
gpr_time_add(start, gpr_time_from_millis(1600, GPR_TIMESPAN)),
NULL) == GRPC_TIMERS_CHECKED_AND_EMPTY);
exec_ctx.now = start + 1600;
GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) ==
GRPC_TIMERS_CHECKED_AND_EMPTY);
for (i = 0; i < 30; i++) {
GPR_ASSERT(cb_called[i][1] == (i < 20));
GPR_ASSERT(cb_called[i][0] == 0);
@ -116,10 +107,6 @@ static void add_test(void) {
grpc_exec_ctx_finish(&exec_ctx);
}
static gpr_timespec tfm(int m) {
return gpr_time_from_millis(m, GPR_CLOCK_REALTIME);
}
/* Cleaning up a list with pending timers. */
void destruction_test(void) {
grpc_timer timers[5];
@ -127,32 +114,30 @@ void destruction_test(void) {
gpr_log(GPR_INFO, "destruction_test");
grpc_timer_list_init(gpr_time_0(GPR_CLOCK_REALTIME));
exec_ctx.now_is_valid = true;
exec_ctx.now = 0;
grpc_timer_list_init(&exec_ctx);
grpc_timer_trace.value = 1;
grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
grpc_timer_init(
&exec_ctx, &timers[0], tfm(100),
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx),
gpr_time_0(GPR_CLOCK_REALTIME));
&exec_ctx, &timers[0], 100,
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx));
grpc_timer_init(
&exec_ctx, &timers[1], tfm(3),
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx),
gpr_time_0(GPR_CLOCK_REALTIME));
&exec_ctx, &timers[1], 3,
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx));
grpc_timer_init(
&exec_ctx, &timers[2], tfm(100),
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx),
gpr_time_0(GPR_CLOCK_REALTIME));
&exec_ctx, &timers[2], 100,
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx));
grpc_timer_init(
&exec_ctx, &timers[3], tfm(3),
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx),
gpr_time_0(GPR_CLOCK_REALTIME));
&exec_ctx, &timers[3], 3,
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx));
grpc_timer_init(
&exec_ctx, &timers[4], tfm(1),
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx),
gpr_time_0(GPR_CLOCK_REALTIME));
GPR_ASSERT(grpc_timer_check(&exec_ctx, tfm(2), NULL) == GRPC_TIMERS_FIRED);
&exec_ctx, &timers[4], 1,
GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx));
exec_ctx.now = 2;
GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED);
grpc_exec_ctx_finish(&exec_ctx);
GPR_ASSERT(1 == cb_called[4][1]);
grpc_timer_cancel(&exec_ctx, &timers[0]);

@ -226,7 +226,7 @@ static void test_receive(int number_of_clients) {
grpc_udp_server *s = grpc_udp_server_create(NULL);
int i;
int number_of_reads_before;
gpr_timespec deadline;
grpc_millis deadline;
grpc_pollset *pollsets[1];
LOG_TEST("test_receive");
gpr_log(GPR_INFO, "clients=%d", number_of_clients);
@ -252,7 +252,7 @@ static void test_receive(int number_of_clients) {
gpr_mu_lock(g_mu);
for (i = 0; i < number_of_clients; i++) {
deadline = grpc_timeout_seconds_to_deadline(10);
deadline = grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10));
number_of_reads_before = g_number_of_reads;
/* Create a socket, send a packet to the UDP server. */
@ -262,14 +262,13 @@ static void test_receive(int number_of_clients) {
(socklen_t)resolved_addr.len) == 0);
GPR_ASSERT(5 == write(clifd, "hello", 5));
while (g_number_of_reads == number_of_reads_before &&
gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
deadline > grpc_exec_ctx_now(&exec_ctx)) {
grpc_pollset_worker *worker = NULL;
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, g_pollset, &worker,
gpr_now(GPR_CLOCK_MONOTONIC), deadline)));
grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline)));
gpr_mu_unlock(g_mu);
grpc_exec_ctx_finish(&exec_ctx);
grpc_exec_ctx_flush(&exec_ctx);
gpr_mu_lock(g_mu);
}
GPR_ASSERT(g_number_of_reads == number_of_reads_before + 1);

@ -233,14 +233,13 @@ static void test_add_abunch_to_md_store(void) {
static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
&exec_ctx, &response, &token_md, &token_lifetime) ==
GRPC_CREDENTIALS_OK);
GPR_ASSERT(token_lifetime.tv_sec == 3599);
GPR_ASSERT(token_lifetime.tv_nsec == 0);
GPR_ASSERT(token_lifetime == 3599 * GPR_MS_PER_SEC);
GPR_ASSERT(token_md->num_entries == 1);
GPR_ASSERT(grpc_slice_str_cmp(token_md->entries[0].key, "authorization") ==
0);
@ -255,7 +254,7 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) {
static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(401, valid_oauth2_json_response);
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
@ -268,7 +267,7 @@ static void test_oauth2_token_fetcher_creds_parsing_bad_http_status(void) {
static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_millis token_lifetime;
grpc_httpcli_response response = http_response(200, "");
GPR_ASSERT(grpc_oauth2_token_fetcher_credentials_parse_server_response(
&exec_ctx, &response, &token_md, &token_lifetime) ==
@ -280,7 +279,7 @@ static void test_oauth2_token_fetcher_creds_parsing_empty_http_body(void) {
static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200,
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
@ -296,7 +295,7 @@ static void test_oauth2_token_fetcher_creds_parsing_invalid_json(void) {
static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_millis token_lifetime;
grpc_httpcli_response response = http_response(200,
"{"
" \"expires_in\":3599, "
@ -311,7 +310,7 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token(void) {
static void test_oauth2_token_fetcher_creds_parsing_missing_token_type(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200,
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
@ -328,7 +327,7 @@ static void test_oauth2_token_fetcher_creds_parsing_missing_token_lifetime(
void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_credentials_md_store *token_md = NULL;
gpr_timespec token_lifetime;
grpc_millis token_lifetime;
grpc_httpcli_response response =
http_response(200,
"{\"access_token\":\"ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_\","
@ -579,7 +578,7 @@ static void validate_compute_engine_http_request(
static int compute_engine_httpcli_get_success_override(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
gpr_timespec deadline, grpc_closure *on_done,
grpc_millis deadline, grpc_closure *on_done,
grpc_httpcli_response *response) {
validate_compute_engine_http_request(request);
*response = http_response(200, valid_oauth2_json_response);
@ -589,7 +588,7 @@ static int compute_engine_httpcli_get_success_override(
static int compute_engine_httpcli_get_failure_override(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
gpr_timespec deadline, grpc_closure *on_done,
grpc_millis deadline, grpc_closure *on_done,
grpc_httpcli_response *response) {
validate_compute_engine_http_request(request);
*response = http_response(403, "Not Authorized.");
@ -599,7 +598,7 @@ static int compute_engine_httpcli_get_failure_override(
static int httpcli_post_should_not_be_called(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
const char *body_bytes, size_t body_size, gpr_timespec deadline,
const char *body_bytes, size_t body_size, grpc_millis deadline,
grpc_closure *on_done, grpc_httpcli_response *response) {
GPR_ASSERT("HTTP POST should not be called" == NULL);
return 1;
@ -607,7 +606,7 @@ static int httpcli_post_should_not_be_called(
static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx,
const grpc_httpcli_request *request,
gpr_timespec deadline,
grpc_millis deadline,
grpc_closure *on_done,
grpc_httpcli_response *response) {
GPR_ASSERT("HTTP GET should not be called" == NULL);
@ -682,7 +681,7 @@ static void validate_refresh_token_http_request(
static int refresh_token_httpcli_post_success(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
const char *body, size_t body_size, gpr_timespec deadline,
const char *body, size_t body_size, grpc_millis deadline,
grpc_closure *on_done, grpc_httpcli_response *response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(200, valid_oauth2_json_response);
@ -692,7 +691,7 @@ static int refresh_token_httpcli_post_success(
static int refresh_token_httpcli_post_failure(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
const char *body, size_t body_size, gpr_timespec deadline,
const char *body, size_t body_size, grpc_millis deadline,
grpc_closure *on_done, grpc_httpcli_response *response) {
validate_refresh_token_http_request(request, body, body_size);
*response = http_response(403, "Not Authorized.");
@ -968,7 +967,7 @@ static void test_google_default_creds_refresh_token(void) {
static int default_creds_gce_detection_httpcli_get_success_override(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
gpr_timespec deadline, grpc_closure *on_done,
grpc_millis deadline, grpc_closure *on_done,
grpc_httpcli_response *response) {
*response = http_response(200, "");
grpc_http_header *headers = gpr_malloc(sizeof(*headers) * 1);
@ -1030,7 +1029,7 @@ static void test_google_default_creds_gce(void) {
static int default_creds_gce_detection_httpcli_get_failure_override(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
gpr_timespec deadline, grpc_closure *on_done,
grpc_millis deadline, grpc_closure *on_done,
grpc_httpcli_response *response) {
/* No magic header. */
GPR_ASSERT(strcmp(request->http.path, "/") == 0);

@ -324,7 +324,7 @@ static grpc_httpcli_response http_response(int status, char *body) {
static int httpcli_post_should_not_be_called(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
const char *body_bytes, size_t body_size, gpr_timespec deadline,
const char *body_bytes, size_t body_size, grpc_millis deadline,
grpc_closure *on_done, grpc_httpcli_response *response) {
GPR_ASSERT("HTTP POST should not be called" == NULL);
return 1;
@ -332,7 +332,7 @@ static int httpcli_post_should_not_be_called(
static int httpcli_get_google_keys_for_email(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
gpr_timespec deadline, grpc_closure *on_done,
grpc_millis deadline, grpc_closure *on_done,
grpc_httpcli_response *response) {
*response = http_response(200, good_google_email_keys());
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
@ -379,7 +379,7 @@ static void test_jwt_verifier_google_email_issuer_success(void) {
static int httpcli_get_custom_keys_for_email(
grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request,
gpr_timespec deadline, grpc_closure *on_done,
grpc_millis deadline, grpc_closure *on_done,
grpc_httpcli_response *response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
@ -413,7 +413,7 @@ static void test_jwt_verifier_custom_email_issuer_success(void) {
static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx,
const grpc_httpcli_request *request,
gpr_timespec deadline, grpc_closure *on_done,
grpc_millis deadline, grpc_closure *on_done,
grpc_httpcli_response *response) {
*response = http_response(200, gpr_strdup(good_jwk_set));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
@ -425,7 +425,7 @@ static int httpcli_get_jwk_set(grpc_exec_ctx *exec_ctx,
static int httpcli_get_openid_config(grpc_exec_ctx *exec_ctx,
const grpc_httpcli_request *request,
gpr_timespec deadline,
grpc_millis deadline,
grpc_closure *on_done,
grpc_httpcli_response *response) {
*response = http_response(200, gpr_strdup(good_openid_config));
@ -471,7 +471,7 @@ static void on_verification_key_retrieval_error(grpc_exec_ctx *exec_ctx,
static int httpcli_get_bad_json(grpc_exec_ctx *exec_ctx,
const grpc_httpcli_request *request,
gpr_timespec deadline, grpc_closure *on_done,
grpc_millis deadline, grpc_closure *on_done,
grpc_httpcli_response *response) {
*response = http_response(200, gpr_strdup("{\"bad\": \"stuff\"}"));
GPR_ASSERT(request->handshaker == &grpc_httpcli_ssl);
@ -581,7 +581,7 @@ static void test_jwt_verifier_bad_signature(void) {
static int httpcli_get_should_not_be_called(grpc_exec_ctx *exec_ctx,
const grpc_httpcli_request *request,
gpr_timespec deadline,
grpc_millis deadline,
grpc_closure *on_done,
grpc_httpcli_response *response) {
GPR_ASSERT(0);

@ -84,8 +84,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_security_status status =
grpc_server_credentials_create_security_connector(&exec_ctx, creds, &sc);
GPR_ASSERT(status == GRPC_SECURITY_OK);
gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_seconds(1, GPR_TIMESPAN));
grpc_millis deadline = GPR_MS_PER_SEC + grpc_exec_ctx_now(&exec_ctx);
struct handshake_state state;
state.done_callback_called = false;

@ -43,16 +43,6 @@ grpc_cc_test(
],
)
grpc_cc_test(
name = "backoff_test",
srcs = ["backoff_test.c"],
language = "C",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
],
)
grpc_cc_test(
name = "cmdline_test",
srcs = ["cmdline_test.c"],

@ -1,143 +0,0 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "src/core/lib/support/backoff.h"
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
static void test_constant_backoff(void) {
gpr_backoff backoff;
gpr_backoff_init(&backoff, 200 /* initial timeout */, 1.0 /* multiplier */,
0.0 /* jitter */, 100 /* min timeout */,
1000 /* max timeout */);
gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
gpr_timespec next = gpr_backoff_begin(&backoff, now);
GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
for (int i = 0; i < 10000; i++) {
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
now = next;
}
}
static void test_min_connect(void) {
gpr_backoff backoff;
gpr_backoff_init(&backoff, 100 /* initial timeout */, 1.0 /* multiplier */,
0.0 /* jitter */, 200 /* min timeout */,
1000 /* max timeout */);
gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
gpr_timespec next = gpr_backoff_begin(&backoff, now);
GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 200);
}
static void test_no_jitter_backoff(void) {
gpr_backoff backoff;
gpr_backoff_init(&backoff, 2 /* initial timeout */, 2.0 /* multiplier */,
0.0 /* jitter */, 1 /* min timeout */,
513 /* max timeout */);
// x_1 = 2
// x_n = 2**i + x_{i-1} ( = 2**(n+1) - 2 )
gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
gpr_timespec next = gpr_backoff_begin(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(6, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(14, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(30, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(62, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(126, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(254, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(510, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1022, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
// Hit the maximum timeout. From this point onwards, retries will increase
// only by max timeout.
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(1535, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2048, GPR_TIMESPAN), next) == 0);
now = next;
next = gpr_backoff_step(&backoff, now);
GPR_ASSERT(gpr_time_cmp(gpr_time_from_millis(2561, GPR_TIMESPAN), next) == 0);
}
static void test_jitter_backoff(void) {
const int64_t initial_timeout = 500;
const double jitter = 0.1;
gpr_backoff backoff;
gpr_backoff_init(&backoff, initial_timeout, 1.0 /* multiplier */, jitter,
100 /* min timeout */, 1000 /* max timeout */);
backoff.rng_state = 0; // force consistent PRNG
gpr_timespec now = gpr_time_0(GPR_TIMESPAN);
gpr_timespec next = gpr_backoff_begin(&backoff, now);
GPR_ASSERT(gpr_time_to_millis(gpr_time_sub(next, now)) == 500);
int64_t expected_next_lower_bound =
(int64_t)((double)initial_timeout * (1 - jitter));
int64_t expected_next_upper_bound =
(int64_t)((double)initial_timeout * (1 + jitter));
for (int i = 0; i < 10000; i++) {
next = gpr_backoff_step(&backoff, now);
// next-now must be within (jitter*100)% of the previous timeout.
const int64_t timeout_millis = gpr_time_to_millis(gpr_time_sub(next, now));
GPR_ASSERT(timeout_millis >= expected_next_lower_bound);
GPR_ASSERT(timeout_millis <= expected_next_upper_bound);
expected_next_lower_bound =
(int64_t)((double)timeout_millis * (1 - jitter));
expected_next_upper_bound =
(int64_t)((double)timeout_millis * (1 + jitter));
now = next;
}
}
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
gpr_time_init();
test_constant_backoff();
test_min_connect();
test_no_jitter_backoff();
test_jitter_backoff();
return 0;
}

@ -134,14 +134,12 @@ void bad_server_thread(void *vargs) {
gpr_mu_lock(args->mu);
while (gpr_atm_acq_load(&args->stop) == 0) {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec deadline =
gpr_time_add(now, gpr_time_from_millis(100, GPR_TIMESPAN));
grpc_millis deadline = grpc_exec_ctx_now(&exec_ctx) + 100;
grpc_pollset_worker *worker = NULL;
if (!GRPC_LOG_IF_ERROR("pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker,
now, deadline))) {
if (!GRPC_LOG_IF_ERROR(
"pollset_work",
grpc_pollset_work(&exec_ctx, args->pollset, &worker, deadline))) {
gpr_atm_rel_store(&args->stop, 1);
}
gpr_mu_unlock(args->mu);

@ -80,8 +80,8 @@ void test_tcp_server_start(test_tcp_server *server, int port) {
void test_tcp_server_poll(test_tcp_server *server, int seconds) {
grpc_pollset_worker *worker = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_millis deadline = grpc_timespec_to_millis(
&exec_ctx, grpc_timeout_seconds_to_deadline(seconds));
grpc_millis deadline =
grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds));
gpr_mu_lock(server->mu);
GRPC_LOG_IF_ERROR(
"pollset_work",

@ -1051,6 +1051,8 @@ src/core/ext/transport/inproc/inproc_plugin.c \
src/core/ext/transport/inproc/inproc_transport.c \
src/core/ext/transport/inproc/inproc_transport.h \
src/core/lib/README.md \
src/core/lib/backoff/backoff.c \
src/core/lib/backoff/backoff.h \
src/core/lib/channel/README.md \
src/core/lib/channel/channel_args.c \
src/core/lib/channel/channel_args.h \
@ -1284,8 +1286,6 @@ src/core/lib/support/atomic.h \
src/core/lib/support/atomic_with_atm.h \
src/core/lib/support/atomic_with_std.h \
src/core/lib/support/avl.c \
src/core/lib/support/backoff.c \
src/core/lib/support/backoff.h \
src/core/lib/support/block_annotate.h \
src/core/lib/support/cmdline.c \
src/core/lib/support/cpu_iphone.c \

@ -99,6 +99,23 @@
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c",
"name": "backoff_test",
"src": [
"test/core/backoff/backoff_test.c"
],
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
@ -692,21 +709,6 @@
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
"gpr_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c",
"name": "gpr_backoff_test",
"src": [
"test/core/support/backoff_test.c"
],
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
@ -7510,12 +7512,12 @@
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
"src/core/lib/backoff/backoff.h",
"src/core/lib/profiling/timers.h",
"src/core/lib/support/arena.h",
"src/core/lib/support/atomic.h",
"src/core/lib/support/atomic_with_atm.h",
"src/core/lib/support/atomic_with_std.h",
"src/core/lib/support/backoff.h",
"src/core/lib/support/block_annotate.h",
"src/core/lib/support/env.h",
"src/core/lib/support/memory.h",
@ -7559,6 +7561,8 @@
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"include/grpc/support/useful.h",
"src/core/lib/backoff/backoff.c",
"src/core/lib/backoff/backoff.h",
"src/core/lib/profiling/basic_timers.c",
"src/core/lib/profiling/stap_timers.c",
"src/core/lib/profiling/timers.h",
@ -7570,8 +7574,6 @@
"src/core/lib/support/atomic_with_atm.h",
"src/core/lib/support/atomic_with_std.h",
"src/core/lib/support/avl.c",
"src/core/lib/support/backoff.c",
"src/core/lib/support/backoff.h",
"src/core/lib/support/block_annotate.h",
"src/core/lib/support/cmdline.c",
"src/core/lib/support/cpu_iphone.c",

@ -111,6 +111,28 @@
"windows"
]
},
{
"args": [],
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "backoff_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
]
},
{
"args": [],
"ci_platforms": [
@ -749,28 +771,6 @@
"windows"
]
},
{
"args": [],
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "gpr_backoff_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
]
},
{
"args": [],
"ci_platforms": [

@ -54,6 +54,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "arena_test", "vcxproj\test\
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "backoff_test", "vcxproj\test\backoff_test\backoff_test.vcxproj", "{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}"
ProjectSection(myProperties) = preProject
lib = "False"
EndProjectSection
ProjectSection(ProjectDependencies) = postProject
{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}
{29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9}
{EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037}
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bad_client_test", "vcxproj\test/bad_client\bad_client_test\bad_client_test.vcxproj", "{BA67B418-B699-E41A-9CC4-0279C49481A5}"
ProjectSection(myProperties) = preProject
lib = "True"
@ -403,15 +414,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_avl_test", "vcxproj\tes
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_backoff_test", "vcxproj\test\gpr_backoff_test\gpr_backoff_test.vcxproj", "{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}"
ProjectSection(myProperties) = preProject
lib = "False"
EndProjectSection
ProjectSection(ProjectDependencies) = postProject
{EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037}
{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_cmdline_test", "vcxproj\test\gpr_cmdline_test\gpr_cmdline_test.vcxproj", "{10668A5D-65CD-F530-22D0-747B395B4C26}"
ProjectSection(myProperties) = preProject
lib = "False"
@ -1844,6 +1846,22 @@ Global
{D85AC722-A88F-4280-F62E-672F571787FF}.Release-DLL|Win32.Build.0 = Release|Win32
{D85AC722-A88F-4280-F62E-672F571787FF}.Release-DLL|x64.ActiveCfg = Release|x64
{D85AC722-A88F-4280-F62E-672F571787FF}.Release-DLL|x64.Build.0 = Release|x64
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug|Win32.ActiveCfg = Debug|Win32
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug|x64.ActiveCfg = Debug|x64
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release|Win32.ActiveCfg = Release|Win32
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release|x64.ActiveCfg = Release|x64
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug|Win32.Build.0 = Debug|Win32
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug|x64.Build.0 = Debug|x64
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release|Win32.Build.0 = Release|Win32
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release|x64.Build.0 = Release|x64
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug-DLL|Win32.ActiveCfg = Debug|Win32
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug-DLL|Win32.Build.0 = Debug|Win32
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug-DLL|x64.ActiveCfg = Debug|x64
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Debug-DLL|x64.Build.0 = Debug|x64
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release-DLL|Win32.ActiveCfg = Release|Win32
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release-DLL|Win32.Build.0 = Release|Win32
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release-DLL|x64.ActiveCfg = Release|x64
{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}.Release-DLL|x64.Build.0 = Release|x64
{BA67B418-B699-E41A-9CC4-0279C49481A5}.Debug|Win32.ActiveCfg = Debug|Win32
{BA67B418-B699-E41A-9CC4-0279C49481A5}.Debug|x64.ActiveCfg = Debug|x64
{BA67B418-B699-E41A-9CC4-0279C49481A5}.Release|Win32.ActiveCfg = Release|Win32
@ -2388,22 +2406,6 @@ Global
{144D8CFF-2737-A18A-DCFD-01603533D63F}.Release-DLL|Win32.Build.0 = Release|Win32
{144D8CFF-2737-A18A-DCFD-01603533D63F}.Release-DLL|x64.ActiveCfg = Release|x64
{144D8CFF-2737-A18A-DCFD-01603533D63F}.Release-DLL|x64.Build.0 = Release|x64
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug|Win32.ActiveCfg = Debug|Win32
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug|x64.ActiveCfg = Debug|x64
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release|Win32.ActiveCfg = Release|Win32
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release|x64.ActiveCfg = Release|x64
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug|Win32.Build.0 = Debug|Win32
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug|x64.Build.0 = Debug|x64
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release|Win32.Build.0 = Release|Win32
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release|x64.Build.0 = Release|x64
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug-DLL|Win32.ActiveCfg = Debug|Win32
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug-DLL|Win32.Build.0 = Debug|Win32
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug-DLL|x64.ActiveCfg = Debug|x64
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Debug-DLL|x64.Build.0 = Debug|x64
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release-DLL|Win32.ActiveCfg = Release|Win32
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release-DLL|Win32.Build.0 = Release|Win32
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release-DLL|x64.ActiveCfg = Release|x64
{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}.Release-DLL|x64.Build.0 = Release|x64
{10668A5D-65CD-F530-22D0-747B395B4C26}.Debug|Win32.ActiveCfg = Debug|Win32
{10668A5D-65CD-F530-22D0-747B395B4C26}.Debug|x64.ActiveCfg = Debug|x64
{10668A5D-65CD-F530-22D0-747B395B4C26}.Release|Win32.ActiveCfg = Release|Win32

@ -186,12 +186,12 @@
<ClInclude Include="$(SolutionDir)\..\include\grpc\impl\codegen\sync_windows.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\backoff\backoff.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\profiling\timers.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\arena.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\atomic.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\atomic_with_atm.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\atomic_with_std.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\backoff.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\block_annotate.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\env.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\memory.h" />
@ -206,6 +206,8 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\tmpfile.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\backoff\backoff.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\profiling\basic_timers.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\profiling\stap_timers.c">
@ -218,8 +220,6 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\support\avl.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\support\backoff.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\support\cmdline.c">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\support\cpu_iphone.c">

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\backoff\backoff.c">
<Filter>src\core\lib\backoff</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\profiling\basic_timers.c">
<Filter>src\core\lib\profiling</Filter>
</ClCompile>
@ -19,9 +22,6 @@
<ClCompile Include="$(SolutionDir)\..\src\core\lib\support\avl.c">
<Filter>src\core\lib\support</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\support\backoff.c">
<Filter>src\core\lib\support</Filter>
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\lib\support\cmdline.c">
<Filter>src\core\lib\support</Filter>
</ClCompile>
@ -254,6 +254,9 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\backoff\backoff.h">
<Filter>src\core\lib\backoff</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\profiling\timers.h">
<Filter>src\core\lib\profiling</Filter>
</ClInclude>
@ -269,9 +272,6 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\atomic_with_std.h">
<Filter>src\core\lib\support</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\backoff.h">
<Filter>src\core\lib\support</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\support\block_annotate.h">
<Filter>src\core\lib\support</Filter>
</ClInclude>
@ -335,6 +335,9 @@
<Filter Include="src\core\lib">
<UniqueIdentifier>{52037bcb-5719-a548-224d-834fbe569045}</UniqueIdentifier>
</Filter>
<Filter Include="src\core\lib\backoff">
<UniqueIdentifier>{5a917a34-e4b4-01c0-4565-2be560176bec}</UniqueIdentifier>
</Filter>
<Filter Include="src\core\lib\profiling">
<UniqueIdentifier>{ba38d79d-d5de-a89e-9ca2-c5235a03ca7f}</UniqueIdentifier>
</Filter>

@ -20,7 +20,7 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{889F570D-E046-BD52-9E4C-B4CD13DFE2DB}</ProjectGuid>
<ProjectGuid>{F0B4300E-693E-CAD6-E6DD-7DEBD136C202}</ProjectGuid>
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected>
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir>
</PropertyGroup>
@ -60,14 +60,14 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<TargetName>gpr_backoff_test</TargetName>
<TargetName>backoff_test</TargetName>
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib>
<Configuration-grpc_dependencies_zlib>Debug</Configuration-grpc_dependencies_zlib>
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl>
<Configuration-grpc_dependencies_openssl>Debug</Configuration-grpc_dependencies_openssl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<TargetName>gpr_backoff_test</TargetName>
<TargetName>backoff_test</TargetName>
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib>
<Configuration-grpc_dependencies_zlib>Release</Configuration-grpc_dependencies_zlib>
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl>
@ -158,10 +158,16 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="$(SolutionDir)\..\test\core\support\backoff_test.c">
<ClCompile Include="$(SolutionDir)\..\test\core\backoff\backoff_test.c">
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc_test_util\grpc_test_util.vcxproj">
<Project>{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}</Project>
</ProjectReference>
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc\grpc.vcxproj">
<Project>{29D16885-7228-4C31-81ED-5F9187C7F2A9}</Project>
</ProjectReference>
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr_test_util\gpr_test_util.vcxproj">
<Project>{EAB0A629-17A9-44DB-B5FF-E91A721FE037}</Project>
</ProjectReference>

@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="$(SolutionDir)\..\test\core\support\backoff_test.c">
<Filter>test\core\support</Filter>
<ClCompile Include="$(SolutionDir)\..\test\core\backoff\backoff_test.c">
<Filter>test\core\backoff</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="test">
<UniqueIdentifier>{4b7f1d25-d344-0bcb-63d8-2ba959874ea8}</UniqueIdentifier>
<UniqueIdentifier>{05e21e2a-bc8e-8c99-d00c-486e055f3b4a}</UniqueIdentifier>
</Filter>
<Filter Include="test\core">
<UniqueIdentifier>{2bd2fba5-8799-2c78-469f-ec3ba6b01da8}</UniqueIdentifier>
<UniqueIdentifier>{42a371ec-543d-205f-0fbc-7ba3d2b2deca}</UniqueIdentifier>
</Filter>
<Filter Include="test\core\support">
<UniqueIdentifier>{2ef0cfa7-fe3d-2b82-7d0e-f9e293e8f98c}</UniqueIdentifier>
<Filter Include="test\core\backoff">
<UniqueIdentifier>{467ad11c-0245-020b-4558-5b324ac725be}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
Loading…
Cancel
Save