From dc3998e7103a0f5e325787da3ab0a32ec402468e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 12 May 2017 09:55:30 -0700 Subject: Converting code --- src/core/ext/filters/client_channel/channel_connectivity.c | 3 +-- src/core/ext/filters/client_channel/subchannel.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.c index f83670db82..4ccbd5c13d 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.c +++ b/src/core/ext/filters/client_channel/channel_connectivity.c @@ -210,8 +210,7 @@ void grpc_channel_watch_connectivity_state( w->channel = channel; grpc_timer_init(&exec_ctx, &w->alarm, - gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC), - &w->on_timeout, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timespec_to_millis(&exec_ctx, deadline), &w->on_timeout); if (client_channel_elem->filter == &grpc_client_channel_filter) { GRPC_CHANNEL_INTERNAL_REF(channel, "watch_channel_connectivity"); diff --git a/src/core/ext/filters/client_channel/subchannel.c b/src/core/ext/filters/client_channel/subchannel.c index 1af3393a62..ddc24f7c71 100644 --- a/src/core/ext/filters/client_channel/subchannel.c +++ b/src/core/ext/filters/client_channel/subchannel.c @@ -131,7 +131,7 @@ struct grpc_subchannel { external_state_watcher root_external_state_watcher; /** next connect attempt time */ - gpr_timespec next_attempt; + grpc_millis next_attempt; /** backoff state */ gpr_backoff backoff_state; /** do we have an active alarm? */ @@ -486,7 +486,6 @@ static void maybe_start_connecting_locked(grpc_exec_ctx *exec_ctx, c->connecting = true; GRPC_SUBCHANNEL_WEAK_REF(c, "connecting"); - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); if (!c->backoff_begun) { c->backoff_begun = true; c->next_attempt = gpr_backoff_begin(&c->backoff_state, now); -- cgit v1.2.3 From 565d4c1e8863202fcc1d2f0c7bf56cca206e4f88 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 17 Jul 2017 14:23:46 -0700 Subject: Progress --- src/core/ext/filters/client_channel/channel_connectivity.c | 4 ++-- src/core/ext/filters/client_channel/connector.h | 2 +- src/core/ext/transport/chttp2/transport/writing.c | 3 +-- src/core/lib/iomgr/iomgr.c | 8 +------- test/core/util/test_tcp_server.c | 12 ++++++------ 5 files changed, 11 insertions(+), 18 deletions(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.c index c3dca14305..39dd927d70 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.c +++ b/src/core/ext/filters/client_channel/channel_connectivity.c @@ -186,8 +186,8 @@ 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, - gpr_convert_clock_type(wa->deadline, GPR_CLOCK_MONOTONIC), - &wa->w->on_timeout, gpr_now(GPR_CLOCK_MONOTONIC)); + grpc_timespec_to_millis(exec_ctx, wa->deadline), + &wa->w->on_timeout); gpr_free(wa); } diff --git a/src/core/ext/filters/client_channel/connector.h b/src/core/ext/filters/client_channel/connector.h index 7f3d4a1cc0..bf79f261b0 100644 --- a/src/core/ext/filters/client_channel/connector.h +++ b/src/core/ext/filters/client_channel/connector.h @@ -34,7 +34,7 @@ typedef struct { /** set of pollsets interested in this connection */ grpc_pollset_set *interested_parties; /** deadline for connection */ - gpr_timespec deadline; + grpc_millis deadline; /** channel arguments (to be passed to transport) */ const grpc_channel_args *channel_args; } grpc_connect_in_args; diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 3e16fda6dc..69e8c8f062 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -261,8 +261,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.last_ping_recv_time = 0; t->ping_recv_state.ping_strikes = 0; } } else { diff --git a/src/core/lib/iomgr/iomgr.c b/src/core/lib/iomgr/iomgr.c index 5e15b01ffd..55a9604c6b 100644 --- a/src/core/lib/iomgr/iomgr.c +++ b/src/core/lib/iomgr/iomgr.c @@ -47,14 +47,8 @@ void grpc_iomgr_init(grpc_exec_ctx *exec_ctx) { gpr_mu_init(&g_mu); gpr_cv_init(&g_rcv); grpc_exec_ctx_global_init(); -<<<<<<< HEAD - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_timer_list_init(&exec_ctx); - grpc_exec_ctx_finish(&exec_ctx); -======= grpc_executor_init(exec_ctx); - grpc_timer_list_init(gpr_now(GPR_CLOCK_MONOTONIC)); ->>>>>>> 4708a21c8144f9fed3c90ea8fa153aa20302a1d7 + grpc_timer_list_init(exec_ctx); g_root_object.next = g_root_object.prev = &g_root_object; g_root_object.name = "root"; grpc_network_status_init(); diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c index d3a1de8a3b..cf21ec50ae 100644 --- a/test/core/util/test_tcp_server.c +++ b/test/core/util/test_tcp_server.c @@ -31,6 +31,7 @@ #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" #include "test/core/util/port.h" +#include "test/core/util/test_config.h" static void on_server_destroyed(grpc_exec_ctx *exec_ctx, void *data, grpc_error *error) { @@ -78,14 +79,13 @@ 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; - gpr_timespec deadline = - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(seconds, GPR_TIMESPAN)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_millis deadline = grpc_timespec_to_millis( + &exec_ctx, grpc_timeout_seconds_to_deadline(seconds)); gpr_mu_lock(server->mu); - GRPC_LOG_IF_ERROR("pollset_work", - grpc_pollset_work(&exec_ctx, server->pollset, &worker, - gpr_now(GPR_CLOCK_MONOTONIC), deadline)); + GRPC_LOG_IF_ERROR( + "pollset_work", + grpc_pollset_work(&exec_ctx, server->pollset, &worker, deadline)); gpr_mu_unlock(server->mu); grpc_exec_ctx_finish(&exec_ctx); } -- cgit v1.2.3 From c0df1c0f9a04d9b150af5ba710090f7f8c19f7d5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 17 Jul 2017 16:12:33 -0700 Subject: Compiling again --- BUILD | 4 +- CMakeLists.txt | 64 +++---- Makefile | 74 ++++---- binding.gyp | 2 +- build.yaml | 22 +-- config.m4 | 3 +- config.w32 | 3 +- gRPC-Core.podspec | 10 +- grpc.gemspec | 4 +- package.xml | 4 +- .../filters/client_channel/channel_connectivity.c | 3 +- .../client_channel/lb_policy/grpclb/grpclb.c | 56 +++--- .../lb_policy/grpclb/load_balancer_api.c | 11 +- .../lb_policy/grpclb/load_balancer_api.h | 3 +- .../resolver/dns/c_ares/dns_resolver_ares.c | 30 ++-- .../resolver/dns/native/dns_resolver.c | 30 ++-- src/core/ext/filters/client_channel/subchannel.c | 22 ++- src/core/ext/filters/deadline/deadline_filter.c | 7 +- src/core/ext/filters/max_age/max_age_filter.c | 62 +++---- src/core/lib/backoff/backoff.c | 72 ++++++++ src/core/lib/backoff/backoff.h | 57 ++++++ src/core/lib/iomgr/exec_ctx.c | 8 +- src/core/lib/iomgr/exec_ctx.h | 6 +- src/core/lib/iomgr/timer_manager.c | 2 +- src/core/lib/support/backoff.c | 72 -------- src/core/lib/support/backoff.h | 56 ------ src/core/lib/surface/alarm.c | 3 +- src/core/lib/surface/completion_queue.c | 14 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/backoff/BUILD | 34 ++++ test/core/backoff/backoff_test.c | 147 +++++++++++++++ .../resolvers/dns_resolver_connectivity_test.c | 2 +- test/core/end2end/fuzzers/api_fuzzer.c | 18 +- test/core/http/httpcli_test.c | 10 +- test/core/http/httpscli_test.c | 10 +- test/core/iomgr/endpoint_tests.c | 4 +- test/core/iomgr/fd_posix_test.c | 24 +-- test/core/iomgr/resolve_address_posix_test.c | 27 ++- test/core/iomgr/resolve_address_test.c | 27 ++- test/core/iomgr/tcp_client_posix_test.c | 23 ++- test/core/iomgr/tcp_posix_test.c | 31 ++-- test/core/iomgr/tcp_server_posix_test.c | 8 +- test/core/iomgr/timer_list_test.c | 83 ++++----- test/core/iomgr/udp_server_test.c | 11 +- test/core/security/credentials_test.c | 33 ++-- test/core/security/jwt_verifier_test.c | 14 +- test/core/security/ssl_server_fuzzer.c | 3 +- test/core/support/BUILD | 10 -- test/core/support/backoff_test.c | 143 --------------- test/core/surface/concurrent_connectivity_test.c | 10 +- test/core/util/test_tcp_server.c | 4 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 38 ++-- tools/run_tests/generated/tests.json | 44 ++--- vsprojects/buildtests_c.sln | 52 +++--- vsprojects/vcxproj/gpr/gpr.vcxproj | 6 +- vsprojects/vcxproj/gpr/gpr.vcxproj.filters | 15 +- .../vcxproj/test/backoff_test/backoff_test.vcxproj | 199 +++++++++++++++++++++ .../test/backoff_test/backoff_test.vcxproj.filters | 21 +++ .../test/gpr_backoff_test/gpr_backoff_test.vcxproj | 193 -------------------- .../gpr_backoff_test.vcxproj.filters | 21 --- 61 files changed, 972 insertions(+), 1003 deletions(-) create mode 100644 src/core/lib/backoff/backoff.c create mode 100644 src/core/lib/backoff/backoff.h delete mode 100644 src/core/lib/support/backoff.c delete mode 100644 src/core/lib/support/backoff.h create mode 100644 test/core/backoff/BUILD create mode 100644 test/core/backoff/backoff_test.c delete mode 100644 test/core/support/backoff_test.c create mode 100644 vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj create mode 100644 vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj.filters delete mode 100644 vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj delete mode 100644 vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj.filters (limited to 'src/core/ext/filters/client_channel') diff --git a/BUILD b/BUILD index 9f1ab2a538..c69dd5e461 100644 --- a/BUILD +++ b/BUILD @@ -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", diff --git a/CMakeLists.txt b/CMakeLists.txt index 5413bbcc0f..ca68050ff3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/Makefile b/Makefile index 210d676822..76ac2ca374 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/binding.gyp b/binding.gyp index ae78d931f2..9256264823 100644 --- a/binding.gyp +++ b/binding.gyp @@ -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', diff --git a/build.yaml b/build.yaml index 581fa65a23..01c6b42baa 100644 --- a/build.yaml +++ b/build.yaml @@ -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 diff --git a/config.m4 b/config.m4 index e214f9c546..37c641f4ce 100644 --- a/config.m4 +++ b/config.m4 @@ -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) diff --git a/config.w32 b/config.w32 index 6d50712fb5..1d3b7b810a 100644 --- a/config.w32 +++ b/config.w32 @@ -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"); diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index cf3fc3598a..5e1f663bb6 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -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', diff --git a/grpc.gemspec b/grpc.gemspec index a87c113b04..45fed61c27 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -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 ) diff --git a/package.xml b/package.xml index 256a21d017..0d5f49c889 100644 --- a/package.xml +++ b/package.xml @@ -94,12 +94,12 @@ + - @@ -112,13 +112,13 @@ + - diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.c index 39dd927d70..72324d7eb1 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.c +++ b/src/core/ext/filters/client_channel/channel_connectivity.c @@ -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); } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c index cccc3e871a..c55fffee4d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c @@ -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"); diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c index bec7c97a78..6bf93a42c2 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c @@ -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( diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h index ef8d563edc..4f79629f12 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h @@ -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( diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c index 04a7852323..ad91b83c85 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c @@ -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)); diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c index 5ea75f0554..7287a5dabc 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c @@ -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; } diff --git a/src/core/ext/filters/client_channel/subchannel.c b/src/core/ext/filters/client_channel/subchannel.c index bdaf567d6a..22829c39b3 100644 --- a/src/core/ext/filters/client_channel/subchannel.c +++ b/src/core/ext/filters/client_channel/subchannel.c @@ -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); } } diff --git a/src/core/ext/filters/deadline/deadline_filter.c b/src/core/ext/filters/deadline/deadline_filter.c index 6789903c95..035f5abf3e 100644 --- a/src/core/ext/filters/deadline/deadline_filter.c +++ b/src/core/ext/filters/deadline/deadline_filter.c @@ -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. diff --git a/src/core/ext/filters/max_age/max_age_filter.c b/src/core/ext/filters/max_age/max_age_filter.c index 7d748b9c32..14565fd530 100644 --- a/src/core/ext/filters/max_age/max_age_filter.c +++ b/src/core/ext/filters/max_age/max_age_filter.c @@ -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, diff --git a/src/core/lib/backoff/backoff.c b/src/core/lib/backoff/backoff.c new file mode 100644 index 0000000000..141b952134 --- /dev/null +++ b/src/core/lib/backoff/backoff.c @@ -0,0 +1,72 @@ +/* + * + * 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 + +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; + backoff->min_timeout_millis = min_timeout_millis; + backoff->max_timeout_millis = max_timeout_millis; + backoff->rng_state = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec; +} + +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 grpc_exec_ctx_now(exec_ctx) + first_timeout; +} + +/* Generate a random number between 0 and 1. */ +static double generate_uniform_random_number(uint32_t *rng_state) { + *rng_state = (1103515245 * *rng_state + 12345) % ((uint32_t)1 << 31); + return *rng_state / (double)((uint32_t)1 << 31); +} + +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 = + GPR_MIN((int64_t)new_timeout_millis, backoff->max_timeout_millis); + + const double jitter_range_width = backoff->jitter * new_timeout_millis; + const double jitter = + (2 * generate_uniform_random_number(&backoff->rng_state) - 1) * + jitter_range_width; + + backoff->current_timeout_millis = + (int64_t)((double)(backoff->current_timeout_millis) + jitter); + + const grpc_millis current_deadline = + grpc_exec_ctx_now(exec_ctx) + backoff->current_timeout_millis; + + const grpc_millis min_deadline = + grpc_exec_ctx_now(exec_ctx) + backoff->min_timeout_millis; + + return GPR_MAX(current_deadline, min_deadline); +} + +void grpc_backoff_reset(grpc_backoff *backoff) { + backoff->current_timeout_millis = backoff->initial_connect_timeout; +} diff --git a/src/core/lib/backoff/backoff.h b/src/core/lib/backoff/backoff.h new file mode 100644 index 0000000000..f1258bcdc5 --- /dev/null +++ b/src/core/lib/backoff/backoff.h @@ -0,0 +1,57 @@ +/* + * + * 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. + * + */ + +#ifndef GRPC_CORE_LIB_SUPPORT_BACKOFF_H +#define GRPC_CORE_LIB_SUPPORT_BACKOFF_H + +#include "src/core/lib/iomgr/exec_ctx.h" + +typedef struct { + /// const: how long to wait after the first failure before retrying + int64_t initial_connect_timeout; + /// const: factor with which to multiply backoff after a failed retry + double multiplier; + /// const: amount to randomize backoffs + double jitter; + /// const: minimum time between retries in milliseconds + int64_t min_timeout_millis; + /// const: maximum time between retries in milliseconds + int64_t max_timeout_millis; + + /// random number generator + uint32_t rng_state; + + /// current retry timeout in milliseconds + int64_t current_timeout_millis; +} grpc_backoff; + +/// Initialize backoff machinery - does not need to be destroyed +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 +grpc_millis grpc_backoff_begin(grpc_exec_ctx *exec_ctx, grpc_backoff *backoff); +/// Step a retry loop: returns a timespec for the NEXT retry +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 grpc_backoff_reset(grpc_backoff *backoff); + +#endif /* GRPC_CORE_LIB_SUPPORT_BACKOFF_H */ diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c index 5d2fc4af86..80aaaee0cb 100644 --- a/src/core/lib/iomgr/exec_ctx.c +++ b/src/core/lib/iomgr/exec_ctx.c @@ -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}; diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 8e030bf741..87383809f3 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -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 */ diff --git a/src/core/lib/iomgr/timer_manager.c b/src/core/lib/iomgr/timer_manager.c index 751314c23f..cd2a3a8c78 100644 --- a/src/core/lib/iomgr/timer_manager.c +++ b/src/core/lib/iomgr/timer_manager.c @@ -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", diff --git a/src/core/lib/support/backoff.c b/src/core/lib/support/backoff.c deleted file mode 100644 index 6dc0df473b..0000000000 --- a/src/core/lib/support/backoff.c +++ /dev/null @@ -1,72 +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 - -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) { - backoff->initial_connect_timeout = initial_connect_timeout; - backoff->multiplier = multiplier; - backoff->jitter = jitter; - backoff->min_timeout_millis = min_timeout_millis; - backoff->max_timeout_millis = max_timeout_millis; - backoff->rng_state = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec; -} - -gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now) { - 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)); -} - -/* Generate a random number between 0 and 1. */ -static double generate_uniform_random_number(uint32_t *rng_state) { - *rng_state = (1103515245 * *rng_state + 12345) % ((uint32_t)1 << 31); - return *rng_state / (double)((uint32_t)1 << 31); -} - -gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now) { - const double new_timeout_millis = - backoff->multiplier * (double)backoff->current_timeout_millis; - backoff->current_timeout_millis = - GPR_MIN((int64_t)new_timeout_millis, backoff->max_timeout_millis); - - const double jitter_range_width = backoff->jitter * new_timeout_millis; - const double jitter = - (2 * generate_uniform_random_number(&backoff->rng_state) - 1) * - jitter_range_width; - - 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 gpr_timespec min_deadline = gpr_time_add( - now, gpr_time_from_millis(backoff->min_timeout_millis, GPR_TIMESPAN)); - - return gpr_time_max(current_deadline, min_deadline); -} - -void gpr_backoff_reset(gpr_backoff *backoff) { - backoff->current_timeout_millis = backoff->initial_connect_timeout; -} diff --git a/src/core/lib/support/backoff.h b/src/core/lib/support/backoff.h deleted file mode 100644 index 6e0cc3a4b6..0000000000 --- a/src/core/lib/support/backoff.h +++ /dev/null @@ -1,56 +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. - * - */ - -#ifndef GRPC_CORE_LIB_SUPPORT_BACKOFF_H -#define GRPC_CORE_LIB_SUPPORT_BACKOFF_H - -#include - -typedef struct { - /// const: how long to wait after the first failure before retrying - int64_t initial_connect_timeout; - /// const: factor with which to multiply backoff after a failed retry - double multiplier; - /// const: amount to randomize backoffs - double jitter; - /// const: minimum time between retries in milliseconds - int64_t min_timeout_millis; - /// const: maximum time between retries in milliseconds - int64_t max_timeout_millis; - - /// random number generator - uint32_t rng_state; - - /// current retry timeout in milliseconds - int64_t current_timeout_millis; -} gpr_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); - -/// Begin retry loop: returns a timespec for the NEXT retry -gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now); -/// 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 -/// instead -void gpr_backoff_reset(gpr_backoff *backoff); - -#endif /* GRPC_CORE_LIB_SUPPORT_BACKOFF_H */ diff --git a/src/core/lib/surface/alarm.c b/src/core/lib/surface/alarm.c index 911ac010e0..5140780bac 100644 --- a/src/core/lib/surface/alarm.c +++ b/src/core/lib/surface/alarm.c @@ -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; diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index cefa8a2a89..e054741520 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -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); diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index e7f7332b99..56a72d7c8b 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -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', diff --git a/test/core/backoff/BUILD b/test/core/backoff/BUILD new file mode 100644 index 0000000000..6c2ceb499b --- /dev/null +++ b/test/core/backoff/BUILD @@ -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", + ], +) diff --git a/test/core/backoff/backoff_test.c b/test/core/backoff/backoff_test.c new file mode 100644 index 0000000000..302ac7b3a0 --- /dev/null +++ b/test/core/backoff/backoff_test.c @@ -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 + +#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; +} diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c index 6e3d69c265..d6713c5163 100644 --- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c +++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.c @@ -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; diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 281a1af20c..4b1036b382 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -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, diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c index b8b96d673c..ea63cd1df8 100644 --- a/test/core/http/httpcli_test.c +++ b/test/core/http/httpcli_test.c @@ -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); diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c index a9d7abdcff..6d575d683d 100644 --- a/test/core/http/httpscli_test.c +++ b/test/core/http/httpscli_test.c @@ -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); diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index b7cbba63c1..e80dce01cf 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -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; diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c index 02596450d2..206d14424f 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.c @@ -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); diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.c index 9cc09ed5d3..d9d200d2c4 100644 --- a/test/core/iomgr/resolve_address_posix_test.c +++ b/test/core/iomgr/resolve_address_posix_test.c @@ -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) { diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c index cb156ee61e..c6c53be5ca 100644 --- a/test/core/iomgr/resolve_address_test.c +++ b/test/core/iomgr/resolve_address_test.c @@ -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, diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c index 00ea495bbe..69dc82f45e 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.c @@ -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); diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index c45068e7ec..aa55b71725 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -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); diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c index 2371721a60..13ff92cb5b 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.c @@ -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); diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c index 5f8b01fdc4..c3d9f9d88d 100644 --- a/test/core/iomgr/timer_list_test.c +++ b/test/core/iomgr/timer_list_test.c @@ -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]); diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c index aa34857dbd..2f6f503443 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -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); diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index a76cb0499d..bc63221b0c 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -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); diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index 9b17fb516d..a4bfe0130e 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -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); diff --git a/test/core/security/ssl_server_fuzzer.c b/test/core/security/ssl_server_fuzzer.c index 9858b11c7c..f9b754b8f2 100644 --- a/test/core/security/ssl_server_fuzzer.c +++ b/test/core/security/ssl_server_fuzzer.c @@ -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; diff --git a/test/core/support/BUILD b/test/core/support/BUILD index 7e142c1e3f..7420f37ae8 100644 --- a/test/core/support/BUILD +++ b/test/core/support/BUILD @@ -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"], diff --git a/test/core/support/backoff_test.c b/test/core/support/backoff_test.c deleted file mode 100644 index 23e3005af0..0000000000 --- a/test/core/support/backoff_test.c +++ /dev/null @@ -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 - -#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; -} diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c index 08079b6091..1778054e74 100644 --- a/test/core/surface/concurrent_connectivity_test.c +++ b/test/core/surface/concurrent_connectivity_test.c @@ -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); diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c index cf21ec50ae..ce05833aa9 100644 --- a/test/core/util/test_tcp_server.c +++ b/test/core/util/test_tcp_server.c @@ -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", diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 7c1e75a99c..cb625e2a8e 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -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 \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index c7cc9cb694..589cafa29b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -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", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index d24209506a..72a5f3be3f 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -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": [ diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln index 55de734b42..17a1302a89 100644 --- a/vsprojects/buildtests_c.sln +++ b/vsprojects/buildtests_c.sln @@ -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 diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index 7fb81a7fbc..2386fddd02 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -186,12 +186,12 @@ + - @@ -206,6 +206,8 @@ + + @@ -218,8 +220,6 @@ - - diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index 27d9d2f38f..c5fce455f4 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -1,6 +1,9 @@ + + src\core\lib\backoff + src\core\lib\profiling @@ -19,9 +22,6 @@ src\core\lib\support - - src\core\lib\support - src\core\lib\support @@ -254,6 +254,9 @@ + + src\core\lib\backoff + src\core\lib\profiling @@ -269,9 +272,6 @@ src\core\lib\support - - src\core\lib\support - src\core\lib\support @@ -335,6 +335,9 @@ {52037bcb-5719-a548-224d-834fbe569045} + + {5a917a34-e4b4-01c0-4565-2be560176bec} + {ba38d79d-d5de-a89e-9ca2-c5235a03ca7f} diff --git a/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj b/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj new file mode 100644 index 0000000000..22ba2f7d0a --- /dev/null +++ b/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj @@ -0,0 +1,199 @@ + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {F0B4300E-693E-CAD6-E6DD-7DEBD136C202} + true + $(SolutionDir)IntDir\$(MSBuildProjectName)\ + + + + v100 + + + v110 + + + v120 + + + v140 + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + backoff_test + static + Debug + static + Debug + + + backoff_test + static + Release + static + Release + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + + + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {29D16885-7228-4C31-81ED-5F9187C7F2A9} + + + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + diff --git a/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj.filters b/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj.filters new file mode 100644 index 0000000000..c2189ddd96 --- /dev/null +++ b/vsprojects/vcxproj/test/backoff_test/backoff_test.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + test\core\backoff + + + + + + {05e21e2a-bc8e-8c99-d00c-486e055f3b4a} + + + {42a371ec-543d-205f-0fbc-7ba3d2b2deca} + + + {467ad11c-0245-020b-4558-5b324ac725be} + + + + diff --git a/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj b/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj deleted file mode 100644 index 6aa292ef4f..0000000000 --- a/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {889F570D-E046-BD52-9E4C-B4CD13DFE2DB} - true - $(SolutionDir)IntDir\$(MSBuildProjectName)\ - - - - v100 - - - v110 - - - v120 - - - v140 - - - Application - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - gpr_backoff_test - static - Debug - static - Debug - - - gpr_backoff_test - static - Release - static - Release - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - None - false - - - Console - true - false - - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - None - false - - - Console - true - false - - - - - - NotUsing - Level3 - MaxSpeed - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - true - true - MultiThreaded - true - None - false - - - Console - true - false - true - true - - - - - - NotUsing - Level3 - MaxSpeed - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - true - true - MultiThreaded - true - None - false - - - Console - true - false - true - true - - - - - - - - - - {EAB0A629-17A9-44DB-B5FF-E91A721FE037} - - - {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - diff --git a/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj.filters b/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj.filters deleted file mode 100644 index eb3c1bbd8c..0000000000 --- a/vsprojects/vcxproj/test/gpr_backoff_test/gpr_backoff_test.vcxproj.filters +++ /dev/null @@ -1,21 +0,0 @@ - - - - - test\core\support - - - - - - {4b7f1d25-d344-0bcb-63d8-2ba959874ea8} - - - {2bd2fba5-8799-2c78-469f-ec3ba6b01da8} - - - {2ef0cfa7-fe3d-2b82-7d0e-f9e293e8f98c} - - - - -- cgit v1.2.3 From 89c1428a60a6c5423ccad9ede60079c5e4cc79ac Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Jul 2017 15:32:27 -0700 Subject: Propagate grpc_millis further --- .../ext/filters/client_channel/client_channel.c | 36 +++---- .../client_channel/lb_policy/grpclb/grpclb.c | 8 +- src/core/ext/filters/client_channel/subchannel.h | 2 +- src/core/ext/filters/deadline/deadline_filter.c | 16 ++-- src/core/ext/filters/deadline/deadline_filter.h | 4 +- .../transport/chttp2/transport/chttp2_transport.c | 27 +++--- .../ext/transport/chttp2/transport/hpack_encoder.c | 10 +- .../transport/chttp2/transport/incoming_metadata.c | 4 +- .../transport/chttp2/transport/incoming_metadata.h | 2 +- src/core/ext/transport/chttp2/transport/internal.h | 2 +- src/core/ext/transport/chttp2/transport/parsing.c | 11 +-- src/core/ext/transport/inproc/inproc_transport.c | 16 ++-- src/core/lib/channel/channel_stack.h | 2 +- src/core/lib/surface/call.c | 54 +++++------ src/core/lib/surface/call.h | 2 +- src/core/lib/surface/channel.c | 9 +- src/core/lib/surface/channel.h | 2 +- src/core/lib/surface/lame_client.cc | 2 +- src/core/lib/surface/server.c | 16 ++-- src/core/lib/transport/error_utils.c | 9 +- src/core/lib/transport/error_utils.h | 6 +- src/core/lib/transport/metadata_batch.c | 6 +- src/core/lib/transport/metadata_batch.h | 4 +- src/core/lib/transport/status_conversion.c | 7 +- src/core/lib/transport/status_conversion.h | 6 +- src/core/lib/transport/timeout_encoding.c | 73 ++++---------- src/core/lib/transport/timeout_encoding.h | 5 +- src/core/lib/transport/transport_op_string.c | 5 +- test/core/channel/channel_stack_test.c | 2 +- test/core/transport/status_conversion_test.c | 13 ++- test/core/transport/timeout_encoding_test.c | 105 +++++++++++---------- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- test/cpp/microbenchmarks/bm_chttp2_transport.cc | 6 +- test/cpp/microbenchmarks/bm_cq_multiple_threads.cc | 6 +- test/cpp/microbenchmarks/bm_error.cc | 42 +++++---- test/cpp/microbenchmarks/bm_pollset.cc | 9 +- 36 files changed, 254 insertions(+), 277 deletions(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/client_channel.c b/src/core/ext/filters/client_channel/client_channel.c index 58e31d7b45..508c473c6a 100644 --- a/src/core/ext/filters/client_channel/client_channel.c +++ b/src/core/ext/filters/client_channel/client_channel.c @@ -68,7 +68,7 @@ typedef enum { typedef struct { gpr_refcount refs; - gpr_timespec timeout; + grpc_millis timeout; wait_for_ready_value wait_for_ready; } method_parameters; @@ -98,17 +98,18 @@ static bool parse_wait_for_ready(grpc_json *field, return true; } -static bool parse_timeout(grpc_json *field, gpr_timespec *timeout) { +static bool parse_timeout(grpc_json *field, grpc_millis *timeout) { if (field->type != GRPC_JSON_STRING) return false; size_t len = strlen(field->value); if (field->value[len - 1] != 's') return false; char *buf = gpr_strdup(field->value); buf[len - 1] = '\0'; // Remove trailing 's'. char *decimal_point = strchr(buf, '.'); + int nanos = 0; if (decimal_point != NULL) { *decimal_point = '\0'; - timeout->tv_nsec = gpr_parse_nonnegative_int(decimal_point + 1); - if (timeout->tv_nsec == -1) { + nanos = gpr_parse_nonnegative_int(decimal_point + 1); + if (nanos == -1) { gpr_free(buf); return false; } @@ -127,24 +128,25 @@ static bool parse_timeout(grpc_json *field, gpr_timespec *timeout) { gpr_free(buf); return false; } - timeout->tv_nsec *= multiplier; + nanos *= multiplier; } - timeout->tv_sec = gpr_parse_nonnegative_int(buf); + int seconds = gpr_parse_nonnegative_int(buf); gpr_free(buf); - if (timeout->tv_sec == -1) return false; + if (seconds == -1) return false; + *timeout = seconds * GPR_MS_PER_SEC + nanos / GPR_NS_PER_MS; return true; } static void *method_parameters_create_from_json(const grpc_json *json) { wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET; - gpr_timespec timeout = {0, 0, GPR_TIMESPAN}; + grpc_millis timeout = 0; for (grpc_json *field = json->child; field != NULL; field = field->next) { if (field->key == NULL) continue; if (strcmp(field->key, "waitForReady") == 0) { if (wait_for_ready != WAIT_FOR_READY_UNSET) return NULL; // Duplicate. if (!parse_wait_for_ready(field, &wait_for_ready)) return NULL; } else if (strcmp(field->key, "timeout") == 0) { - if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) return NULL; // Duplicate. + if (timeout > 0) return NULL; // Duplicate. if (!parse_timeout(field, &timeout)) return NULL; } } @@ -814,7 +816,7 @@ typedef struct client_channel_call_data { grpc_slice path; // Request path. gpr_timespec call_start_time; - gpr_timespec deadline; + grpc_millis deadline; grpc_server_retry_throttle_data *retry_throttle_data; method_parameters *method_params; @@ -952,11 +954,11 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx *exec_ctx, // If the deadline from the service config is shorter than the one // from the client API, reset the deadline timer. if (chand->deadline_checking_enabled && - gpr_time_cmp(calld->method_params->timeout, - gpr_time_0(GPR_TIMESPAN)) != 0) { - const gpr_timespec per_method_deadline = - gpr_time_add(calld->call_start_time, calld->method_params->timeout); - if (gpr_time_cmp(per_method_deadline, calld->deadline) < 0) { + calld->method_params->timeout != 0) { + const grpc_millis per_method_deadline = + grpc_timespec_to_millis(calld->call_start_time) + + calld->method_params->timeout; + if (per_method_deadline < calld->deadline) { calld->deadline = per_method_deadline; grpc_deadline_state_reset(exec_ctx, elem, calld->deadline); } @@ -1026,7 +1028,7 @@ static void subchannel_ready_locked(grpc_exec_ctx *exec_ctx, "Cancelled before creating subchannel", child_errors, GPR_ARRAY_SIZE(child_errors)); /* if due to deadline, attach the deadline exceeded status to the error */ - if (gpr_time_cmp(calld->deadline, gpr_now(GPR_CLOCK_MONOTONIC)) < 0) { + if (calld->deadline < grpc_exec_ctx_now(exec_ctx)) { cancellation_error = grpc_error_set_int(cancellation_error, GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_DEADLINE_EXCEEDED); @@ -1440,7 +1442,7 @@ static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx, // Initialize data members. calld->path = grpc_slice_ref_internal(args->path); calld->call_start_time = args->start_time; - calld->deadline = gpr_convert_clock_type(args->deadline, GPR_CLOCK_MONOTONIC); + calld->deadline = args->deadline; calld->owning_call = args->call_stack; calld->arena = args->arena; if (chand->deadline_checking_enabled) { diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c index c55fffee4d..38ca829a14 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c @@ -1352,12 +1352,10 @@ static void lb_call_init_locked(grpc_exec_ctx *exec_ctx, * glb_policy->base.interested_parties, which is comprised of the polling * entities from \a client_channel. */ grpc_slice host = grpc_slice_from_copied_string(glb_policy->server_name); - gpr_timespec deadline = + grpc_millis deadline = glb_policy->lb_call_timeout_ms == 0 - ? gpr_inf_future(GPR_CLOCK_MONOTONIC) - : gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_millis(glb_policy->lb_call_timeout_ms, - GPR_TIMESPAN)); + ? GRPC_MILLIS_INF_FUTURE + : grpc_exec_ctx_now(exec_ctx) + glb_policy->lb_call_timeout_ms; glb_policy->lb_call = grpc_channel_create_pollset_set_call( exec_ctx, glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS, glb_policy->base.interested_parties, diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 6d2abb04df..5ffc640573 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -103,7 +103,7 @@ typedef struct { grpc_polling_entity *pollent; grpc_slice path; gpr_timespec start_time; - gpr_timespec deadline; + grpc_millis deadline; gpr_arena *arena; grpc_call_context_element *context; } grpc_connected_subchannel_call_args; diff --git a/src/core/ext/filters/deadline/deadline_filter.c b/src/core/ext/filters/deadline/deadline_filter.c index 035f5abf3e..fcd0d9c3b1 100644 --- a/src/core/ext/filters/deadline/deadline_filter.c +++ b/src/core/ext/filters/deadline/deadline_filter.c @@ -52,9 +52,8 @@ static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg, // Starts the deadline timer. static void start_timer_if_needed(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec deadline) { - grpc_millis deadline_millis = grpc_timespec_to_millis(deadline); - if (deadline_millis == GRPC_MILLIS_INF_FUTURE) { + grpc_millis deadline) { + if (deadline == GRPC_MILLIS_INF_FUTURE) { return; } grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data; @@ -94,7 +93,7 @@ retry: } GPR_ASSERT(closure); GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer"); - grpc_timer_init(exec_ctx, &deadline_state->timer, deadline_millis, closure); + grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, closure); } // Cancels the deadline timer. @@ -131,7 +130,7 @@ static void inject_on_complete_cb(grpc_deadline_state* deadline_state, // initialization has been completed. struct start_timer_after_init_state { grpc_call_element* elem; - gpr_timespec deadline; + grpc_millis deadline; grpc_closure closure; }; static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, @@ -143,13 +142,12 @@ static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, grpc_call_stack* call_stack, - gpr_timespec deadline) { + grpc_millis deadline) { grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data; deadline_state->call_stack = call_stack; // Deadline will always be infinite on servers, so the timer will only be // set on clients with a finite deadline. - deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); - if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) != 0) { + if (deadline != GRPC_MILLIS_INF_FUTURE) { // When the deadline passes, we indicate the failure by sending down // an op with cancel_error set. However, we can't send down any ops // until after the call stack is fully initialized. If we start the @@ -173,7 +171,7 @@ void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, } void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec new_deadline) { + grpc_millis new_deadline) { grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data; cancel_timer_if_needed(exec_ctx, deadline_state); start_timer_if_needed(exec_ctx, elem, new_deadline); diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h index 420bf7065a..776e6e5649 100644 --- a/src/core/ext/filters/deadline/deadline_filter.h +++ b/src/core/ext/filters/deadline/deadline_filter.h @@ -50,7 +50,7 @@ typedef struct grpc_deadline_state { // assumes elem->call_data is zero'd void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, grpc_call_stack* call_stack, - gpr_timespec deadline); + grpc_millis deadline); void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, grpc_call_element* elem); @@ -62,7 +62,7 @@ void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, // process of being reset, which means that attempting to increase the // deadline may result in the timer being called twice. void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec new_deadline); + grpc_millis new_deadline); // To be called from the client-side filter's start_transport_stream_op_batch() // method. Ensures that the deadline timer is cancelled when the call diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index ffcd715cf6..658d2d1e7b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -676,7 +676,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, grpc_chttp2_incoming_metadata_buffer_init(&s->metadata_buffer[1], arena); grpc_chttp2_data_parser_init(&s->data_parser); grpc_slice_buffer_init(&s->flow_controlled_buffer); - s->deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + s->deadline = GRPC_MILLIS_INF_FUTURE; GRPC_CLOSURE_INIT(&s->complete_fetch_locked, complete_fetch_locked, s, grpc_schedule_on_exec_ctx); grpc_slice_buffer_init(&s->unprocessed_incoming_frames_buffer); @@ -1276,8 +1276,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE]; if (t->is_client) { - s->deadline = - gpr_time_min(s->deadline, s->send_initial_metadata->deadline); + s->deadline = GPR_MIN(s->deadline, s->send_initial_metadata->deadline); } if (metadata_size > metadata_peer_limit) { grpc_chttp2_cancel_stream( @@ -1473,16 +1472,14 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, if (!t->is_client) { if (op->send_initial_metadata) { - gpr_timespec deadline = + grpc_millis deadline = op->payload->send_initial_metadata.send_initial_metadata->deadline; - GPR_ASSERT(0 == - gpr_time_cmp(gpr_inf_future(deadline.clock_type), deadline)); + GPR_ASSERT(deadline == GRPC_MILLIS_INF_FUTURE); } if (op->send_trailing_metadata) { - gpr_timespec deadline = + grpc_millis deadline = op->payload->send_trailing_metadata.send_trailing_metadata->deadline; - GPR_ASSERT(0 == - gpr_time_cmp(gpr_inf_future(deadline.clock_type), deadline)); + GPR_ASSERT(deadline == GRPC_MILLIS_INF_FUTURE); } } @@ -1556,8 +1553,8 @@ static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED; grpc_http2_error_code http_error; grpc_slice slice; - grpc_error_get_status(error, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL, - &slice, &http_error); + grpc_error_get_status(exec_ctx, error, GRPC_MILLIS_INF_FUTURE, NULL, &slice, + &http_error); grpc_chttp2_goaway_append(t->last_new_stream_id, (uint32_t)http_error, grpc_slice_ref_internal(slice), &t->qbuf); grpc_chttp2_initiate_write(exec_ctx, t, "goaway_sent"); @@ -1786,7 +1783,8 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx, if (!s->read_closed || !s->write_closed) { if (s->id != 0) { grpc_http2_error_code http_error; - grpc_error_get_status(due_to_error, s->deadline, NULL, NULL, &http_error); + grpc_error_get_status(exec_ctx, due_to_error, s->deadline, NULL, NULL, + &http_error); grpc_slice_buffer_add( &t->qbuf, grpc_chttp2_rst_stream_create(s->id, (uint32_t)http_error, &s->stats.outgoing)); @@ -1803,7 +1801,7 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_error *error) { grpc_status_code status; grpc_slice slice; - grpc_error_get_status(error, s->deadline, &status, &slice, NULL); + grpc_error_get_status(exec_ctx, error, s->deadline, &status, &slice, NULL); if (status != GRPC_STATUS_OK) { s->seen_error = true; @@ -1960,7 +1958,8 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, uint32_t len = 0; grpc_status_code grpc_status; grpc_slice slice; - grpc_error_get_status(error, s->deadline, &grpc_status, &slice, NULL); + grpc_error_get_status(exec_ctx, error, s->deadline, &grpc_status, &slice, + NULL); GPR_ASSERT(grpc_status >= 0 && (int)grpc_status < 100); diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index a0e748e7b1..207ef6c451 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -515,12 +515,12 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c, #define TIMEOUT_KEY "grpc-timeout" static void deadline_enc(grpc_exec_ctx *exec_ctx, - grpc_chttp2_hpack_compressor *c, gpr_timespec deadline, + grpc_chttp2_hpack_compressor *c, grpc_millis deadline, framer_state *st) { char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE]; grpc_mdelem mdelem; - grpc_http2_encode_timeout( - gpr_time_sub(deadline, gpr_now(deadline.clock_type)), timeout_str); + grpc_http2_encode_timeout(deadline - grpc_exec_ctx_now(exec_ctx), + timeout_str); mdelem = grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_TIMEOUT, grpc_slice_from_copied_string(timeout_str)); hpack_enc(exec_ctx, c, mdelem, st); @@ -639,8 +639,8 @@ void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx, for (grpc_linked_mdelem *l = metadata->list.head; l; l = l->next) { hpack_enc(exec_ctx, c, l->md, &st); } - gpr_timespec deadline = metadata->deadline; - if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) != 0) { + grpc_millis deadline = metadata->deadline; + if (deadline != GRPC_MILLIS_INF_FUTURE) { deadline_enc(exec_ctx, c, deadline, &st); } diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.c b/src/core/ext/transport/chttp2/transport/incoming_metadata.c index cf0a9ca920..089b360ecf 100644 --- a/src/core/ext/transport/chttp2/transport/incoming_metadata.c +++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.c @@ -29,7 +29,7 @@ void grpc_chttp2_incoming_metadata_buffer_init( grpc_chttp2_incoming_metadata_buffer *buffer, gpr_arena *arena) { buffer->arena = arena; grpc_metadata_batch_init(&buffer->batch); - buffer->batch.deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + buffer->batch.deadline = GRPC_MILLIS_INF_FUTURE; } void grpc_chttp2_incoming_metadata_buffer_destroy( @@ -61,7 +61,7 @@ grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add( } void grpc_chttp2_incoming_metadata_buffer_set_deadline( - grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline) { + grpc_chttp2_incoming_metadata_buffer *buffer, grpc_millis deadline) { buffer->batch.deadline = deadline; } diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/src/core/ext/transport/chttp2/transport/incoming_metadata.h index a951d8764c..0fc90b2d80 100644 --- a/src/core/ext/transport/chttp2/transport/incoming_metadata.h +++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.h @@ -43,6 +43,6 @@ grpc_error *grpc_chttp2_incoming_metadata_buffer_replace_or_add( grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem elem) GRPC_MUST_USE_RESULT; void grpc_chttp2_incoming_metadata_buffer_set_deadline( - grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline); + grpc_chttp2_incoming_metadata_buffer *buffer, grpc_millis deadline); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 44ea3bdc61..7701a21ea9 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -499,7 +499,7 @@ struct grpc_chttp2_stream { grpc_error *byte_stream_error; /* protected by t combiner */ bool received_last_frame; /* protected by t combiner */ - gpr_timespec deadline; + grpc_millis deadline; /** saw some stream level error */ grpc_error *forced_close_error; diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 3c8b470b4f..a76ec8e930 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -494,16 +494,16 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp, } if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_TIMEOUT)) { - gpr_timespec *cached_timeout = grpc_mdelem_get_user_data(md, free_timeout); - gpr_timespec timeout; + grpc_millis *cached_timeout = grpc_mdelem_get_user_data(md, free_timeout); + grpc_millis timeout; if (cached_timeout == NULL) { /* not already parsed: parse it now, and store the result away */ - cached_timeout = gpr_malloc(sizeof(gpr_timespec)); + cached_timeout = gpr_malloc(sizeof(grpc_millis)); if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), cached_timeout)) { char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'", val); gpr_free(val); - *cached_timeout = gpr_inf_future(GPR_TIMESPAN); + *cached_timeout = GRPC_MILLIS_INF_FUTURE; } timeout = *cached_timeout; grpc_mdelem_set_user_data(md, free_timeout, cached_timeout); @@ -511,8 +511,7 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp, timeout = *cached_timeout; } grpc_chttp2_incoming_metadata_buffer_set_deadline( - &s->metadata_buffer[0], - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), timeout)); + &s->metadata_buffer[0], grpc_exec_ctx_now(exec_ctx) + timeout); GRPC_MDELEM_UNREF(exec_ctx, md); } else { const size_t new_size = s->metadata_buffer[0].size + GRPC_MDELEM_LENGTH(md); diff --git a/src/core/ext/transport/inproc/inproc_transport.c b/src/core/ext/transport/inproc/inproc_transport.c index 4df64d81e2..02ed3d8a40 100644 --- a/src/core/ext/transport/inproc/inproc_transport.c +++ b/src/core/ext/transport/inproc/inproc_transport.c @@ -150,7 +150,7 @@ typedef struct inproc_stream { grpc_metadata_batch write_buffer_initial_md; bool write_buffer_initial_md_filled; uint32_t write_buffer_initial_md_flags; - gpr_timespec write_buffer_deadline; + grpc_millis write_buffer_deadline; slice_buffer_list write_buffer_message; grpc_metadata_batch write_buffer_trailing_md; bool write_buffer_trailing_md_filled; @@ -180,7 +180,7 @@ typedef struct inproc_stream { grpc_error *cancel_self_error; grpc_error *cancel_other_error; - gpr_timespec deadline; + grpc_millis deadline; bool listed; struct inproc_stream *stream_list_prev; @@ -358,8 +358,8 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, s->cancel_self_error = GRPC_ERROR_NONE; s->cancel_other_error = GRPC_ERROR_NONE; s->write_buffer_cancel_error = GRPC_ERROR_NONE; - s->deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - s->write_buffer_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + s->deadline = GRPC_MILLIS_INF_FUTURE; + s->write_buffer_deadline = GRPC_MILLIS_INF_FUTURE; s->stream_list_prev = NULL; gpr_mu_lock(&t->mu->mu); @@ -402,7 +402,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, cs->write_buffer_initial_md_flags, &s->to_read_initial_md, &s->to_read_initial_md_flags, &s->to_read_initial_md_filled); - s->deadline = gpr_time_min(s->deadline, cs->write_buffer_deadline); + s->deadline = GPR_MIN(s->deadline, cs->write_buffer_deadline); grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_initial_md); cs->write_buffer_initial_md_filled = false; } @@ -935,10 +935,10 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, dest, destflags, destfilled); } if (s->t->is_client) { - gpr_timespec *dl = + grpc_millis *dl = (other == NULL) ? &s->write_buffer_deadline : &other->deadline; - *dl = gpr_time_min(*dl, op->payload->send_initial_metadata - .send_initial_metadata->deadline); + *dl = GPR_MIN(*dl, op->payload->send_initial_metadata + .send_initial_metadata->deadline); s->initial_md_sent = true; } } diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index a80f8aa826..19506e492b 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -69,7 +69,7 @@ typedef struct { grpc_call_context_element *context; grpc_slice path; gpr_timespec start_time; - gpr_timespec deadline; + grpc_millis deadline; gpr_arena *arena; } grpc_call_element_args; diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 2365d27307..cfcf0c96a6 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -202,7 +202,7 @@ struct grpc_call { server, it's trailing metadata */ grpc_linked_mdelem send_extra_metadata[MAX_SEND_EXTRA_METADATA_COUNT]; int send_extra_metadata_count; - gpr_timespec send_deadline; + grpc_millis send_deadline; grpc_slice_buffer_stream sending_stream; @@ -252,7 +252,7 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call_stack, grpc_error *error); static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp, grpc_error *error); -static void get_final_status(grpc_call *call, +static void get_final_status(grpc_exec_ctx *exec_ctx, grpc_call *call, void (*set_value)(grpc_status_code code, void *user_data), void *set_value_user_data, grpc_slice *details); @@ -334,11 +334,10 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx, } for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { - call->metadata_batch[i][j].deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + call->metadata_batch[i][j].deadline = GRPC_MILLIS_INF_FUTURE; } } - gpr_timespec send_deadline = - gpr_convert_clock_type(args->send_deadline, GPR_CLOCK_MONOTONIC); + grpc_millis send_deadline = args->send_deadline; bool immediately_cancel = false; @@ -356,10 +355,7 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx, gpr_mu_lock(&pc->child_list_mu); if (args->propagation_mask & GRPC_PROPAGATE_DEADLINE) { - send_deadline = gpr_time_min( - gpr_convert_clock_type(send_deadline, - args->parent_call->send_deadline.clock_type), - args->parent_call->send_deadline); + send_deadline = GPR_MIN(send_deadline, args->parent_call->send_deadline); } /* for now GRPC_PROPAGATE_TRACING_CONTEXT *MUST* be passed with * GRPC_PROPAGATE_STATS_CONTEXT */ @@ -511,8 +507,8 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, void *call, GRPC_CQ_INTERNAL_UNREF(exec_ctx, c->cq, "bind"); } - get_final_status(call, set_status_value_directly, &c->final_info.final_status, - NULL); + get_final_status(exec_ctx, call, set_status_value_directly, + &c->final_info.final_status, NULL); c->final_info.stats.latency = gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time); @@ -662,13 +658,16 @@ static void cancel_with_status(grpc_exec_ctx *exec_ctx, grpc_call *c, * FINAL STATUS CODE MANIPULATION */ -static bool get_final_status_from( - grpc_call *call, grpc_error *error, bool allow_ok_status, - void (*set_value)(grpc_status_code code, void *user_data), - void *set_value_user_data, grpc_slice *details) { +static bool get_final_status_from(grpc_exec_ctx *exec_ctx, grpc_call *call, + grpc_error *error, bool allow_ok_status, + void (*set_value)(grpc_status_code code, + void *user_data), + void *set_value_user_data, + grpc_slice *details) { grpc_status_code code; grpc_slice slice = grpc_empty_slice(); - grpc_error_get_status(error, call->send_deadline, &code, &slice, NULL); + grpc_error_get_status(exec_ctx, error, call->send_deadline, &code, &slice, + NULL); if (code == GRPC_STATUS_OK && !allow_ok_status) { return false; } @@ -680,7 +679,7 @@ static bool get_final_status_from( return true; } -static void get_final_status(grpc_call *call, +static void get_final_status(grpc_exec_ctx *exec_ctx, grpc_call *call, void (*set_value)(grpc_status_code code, void *user_data), void *set_value_user_data, grpc_slice *details) { @@ -705,8 +704,9 @@ static void get_final_status(grpc_call *call, for (i = 0; i < STATUS_SOURCE_COUNT; i++) { if (status[i].is_set && grpc_error_has_clear_grpc_status(status[i].error)) { - if (get_final_status_from(call, status[i].error, allow_ok_status != 0, - set_value, set_value_user_data, details)) { + if (get_final_status_from(exec_ctx, call, status[i].error, + allow_ok_status != 0, set_value, + set_value_user_data, details)) { return; } } @@ -714,8 +714,9 @@ static void get_final_status(grpc_call *call, /* If no clearly defined status exists, search for 'anything' */ for (i = 0; i < STATUS_SOURCE_COUNT; i++) { if (status[i].is_set) { - if (get_final_status_from(call, status[i].error, allow_ok_status != 0, - set_value, set_value_user_data, details)) { + if (get_final_status_from(exec_ctx, call, status[i].error, + allow_ok_status != 0, set_value, + set_value_user_data, details)) { return; } } @@ -1146,11 +1147,11 @@ static void post_batch_completion(grpc_exec_ctx *exec_ctx, } if (call->is_client) { - get_final_status(call, set_status_value_directly, + get_final_status(exec_ctx, call, set_status_value_directly, call->final_op.client.status, call->final_op.client.status_details); } else { - get_final_status(call, set_cancelled_value, + get_final_status(exec_ctx, call, set_cancelled_value, call->final_op.server.cancelled, NULL); } @@ -1371,11 +1372,8 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx, validate_filtered_metadata(exec_ctx, bctl); GPR_TIMER_END("validate_filtered_metadata", 0); - if (gpr_time_cmp(md->deadline, gpr_inf_future(md->deadline.clock_type)) != - 0 && - !call->is_client) { - call->send_deadline = - gpr_convert_clock_type(md->deadline, GPR_CLOCK_MONOTONIC); + if (md->deadline != GRPC_MILLIS_INF_FUTURE && !call->is_client) { + call->send_deadline = md->deadline; } } diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index 185bfccb77..4c9652a6e9 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -49,7 +49,7 @@ typedef struct grpc_call_create_args { grpc_mdelem *add_initial_metadata; size_t add_initial_metadata_count; - gpr_timespec send_deadline; + grpc_millis send_deadline; } grpc_call_create_args; /* Create a new call based on \a args. diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index 5780a18ce8..b0ff428393 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -230,7 +230,7 @@ static grpc_call *grpc_channel_create_call_internal( grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *cq, grpc_pollset_set *pollset_set_alternative, grpc_mdelem path_mdelem, - grpc_mdelem authority_mdelem, gpr_timespec deadline) { + grpc_mdelem authority_mdelem, grpc_millis deadline) { grpc_mdelem send_metadata[2]; size_t num_metadata = 0; @@ -276,7 +276,7 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, host != NULL ? grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_AUTHORITY, grpc_slice_ref_internal(*host)) : GRPC_MDNULL, - deadline); + grpc_timespec_to_millis(deadline)); grpc_exec_ctx_finish(&exec_ctx); return call; } @@ -284,7 +284,7 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, grpc_call *grpc_channel_create_pollset_set_call( grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_pollset_set *pollset_set, grpc_slice method, - const grpc_slice *host, gpr_timespec deadline, void *reserved) { + const grpc_slice *host, grpc_millis deadline, void *reserved) { GPR_ASSERT(!reserved); return grpc_channel_create_call_internal( exec_ctx, channel, parent_call, propagation_mask, NULL, pollset_set, @@ -340,7 +340,8 @@ grpc_call *grpc_channel_create_registered_call( grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_call *call = grpc_channel_create_call_internal( &exec_ctx, channel, parent_call, propagation_mask, completion_queue, NULL, - GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority), deadline); + GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority), + grpc_timespec_to_millis(deadline)); grpc_exec_ctx_finish(&exec_ctx); return call; } diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 528bb868e2..827dd992b5 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -43,7 +43,7 @@ grpc_channel *grpc_channel_create_with_builder( grpc_call *grpc_channel_create_pollset_set_call( grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_pollset_set *pollset_set, grpc_slice method, - const grpc_slice *host, gpr_timespec deadline, void *reserved); + const grpc_slice *host, grpc_millis deadline, void *reserved); /** Get a (borrowed) pointer to this channels underlying channel stack */ grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel); diff --git a/src/core/lib/surface/lame_client.cc b/src/core/lib/surface/lame_client.cc index a0791080a9..d71de8a2bf 100644 --- a/src/core/lib/surface/lame_client.cc +++ b/src/core/lib/surface/lame_client.cc @@ -73,7 +73,7 @@ static void fill_metadata(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, mdb->list.head = &calld->status; mdb->list.tail = &calld->details; mdb->list.count = 2; - mdb->deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + mdb->deadline = GRPC_MILLIS_INF_FUTURE; } static void lame_start_transport_stream_op_batch( diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index fce7f8dca1..bad36241eb 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -136,7 +136,7 @@ struct call_data { bool host_set; grpc_slice path; grpc_slice host; - gpr_timespec deadline; + grpc_millis deadline; grpc_completion_queue *cq_new; @@ -489,11 +489,13 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server, GPR_ASSERT(calld->path_set); rc->data.batch.details->host = grpc_slice_ref_internal(calld->host); rc->data.batch.details->method = grpc_slice_ref_internal(calld->path); - rc->data.batch.details->deadline = calld->deadline; + rc->data.batch.details->deadline = + grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_REALTIME); rc->data.batch.details->flags = calld->recv_initial_metadata_flags; break; case REGISTERED_CALL: - *rc->data.registered.deadline = calld->deadline; + *rc->data.registered.deadline = + grpc_millis_to_timespec(calld->deadline, GPR_CLOCK_REALTIME); if (rc->data.registered.optional_payload) { *rc->data.registered.optional_payload = calld->payload; calld->payload = NULL; @@ -734,7 +736,7 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr, grpc_error *error) { grpc_call_element *elem = ptr; call_data *calld = elem->call_data; - gpr_timespec op_deadline; + grpc_millis op_deadline; if (error == GRPC_ERROR_NONE) { GPR_ASSERT(calld->recv_initial_metadata->idx.named.path != NULL); @@ -754,7 +756,7 @@ static void server_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, void *ptr, GRPC_ERROR_REF(error); } op_deadline = calld->recv_initial_metadata->deadline; - if (0 != gpr_time_cmp(op_deadline, gpr_inf_future(op_deadline.clock_type))) { + if (op_deadline != GRPC_MILLIS_INF_FUTURE) { calld->deadline = op_deadline; } if (calld->host_set && calld->path_set) { @@ -829,7 +831,7 @@ static void accept_stream(grpc_exec_ctx *exec_ctx, void *cd, memset(&args, 0, sizeof(args)); args.channel = chand->channel; args.server_transport_data = transport_server_data; - args.send_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + args.send_deadline = GRPC_MILLIS_INF_FUTURE; grpc_call *call; grpc_error *error = grpc_call_create(exec_ctx, &args, &call); grpc_call_element *elem = @@ -877,7 +879,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; memset(calld, 0, sizeof(call_data)); - calld->deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + calld->deadline = GRPC_MILLIS_INF_FUTURE; calld->call = grpc_call_from_top_element(elem); gpr_mu_init(&calld->mu_state); diff --git a/src/core/lib/transport/error_utils.c b/src/core/lib/transport/error_utils.c index 5e3920b627..2e3b61b7ab 100644 --- a/src/core/lib/transport/error_utils.c +++ b/src/core/lib/transport/error_utils.c @@ -39,8 +39,9 @@ static grpc_error *recursively_find_error_with_field(grpc_error *error, return NULL; } -void grpc_error_get_status(grpc_error *error, gpr_timespec deadline, - grpc_status_code *code, grpc_slice *slice, +void grpc_error_get_status(grpc_exec_ctx *exec_ctx, grpc_error *error, + grpc_millis deadline, grpc_status_code *code, + grpc_slice *slice, grpc_http2_error_code *http_error) { // Start with the parent error and recurse through the tree of children // until we find the first one that has a status code. @@ -63,8 +64,8 @@ void grpc_error_get_status(grpc_error *error, gpr_timespec deadline, status = (grpc_status_code)integer; } else if (grpc_error_get_int(found_error, GRPC_ERROR_INT_HTTP2_ERROR, &integer)) { - status = grpc_http2_error_to_grpc_status((grpc_http2_error_code)integer, - deadline); + status = grpc_http2_error_to_grpc_status( + exec_ctx, (grpc_http2_error_code)integer, deadline); } if (code != NULL) *code = status; diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h index e530884215..6211031a24 100644 --- a/src/core/lib/transport/error_utils.h +++ b/src/core/lib/transport/error_utils.h @@ -20,6 +20,7 @@ #define GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H #include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/http2_errors.h" /// A utility function to get the status code and message to be returned @@ -28,8 +29,9 @@ /// All attributes are pulled from the same child error. If any of the /// attributes (code, msg, http_status) are unneeded, they can be passed as /// NULL. -void grpc_error_get_status(grpc_error *error, gpr_timespec deadline, - grpc_status_code *code, grpc_slice *slice, +void grpc_error_get_status(grpc_exec_ctx *exec_ctx, grpc_error *error, + grpc_millis deadline, grpc_status_code *code, + grpc_slice *slice, grpc_http2_error_code *http_status); /// A utility function to check whether there is a clear status code that diff --git a/src/core/lib/transport/metadata_batch.c b/src/core/lib/transport/metadata_batch.c index 8f24b8527c..a5ff9c9685 100644 --- a/src/core/lib/transport/metadata_batch.c +++ b/src/core/lib/transport/metadata_batch.c @@ -74,7 +74,7 @@ void grpc_metadata_batch_assert_ok(grpc_metadata_batch *batch) { void grpc_metadata_batch_init(grpc_metadata_batch *batch) { memset(batch, 0, sizeof(*batch)); - batch->deadline = gpr_inf_future(GPR_CLOCK_REALTIME); + batch->deadline = GRPC_MILLIS_INF_FUTURE; } void grpc_metadata_batch_destroy(grpc_exec_ctx *exec_ctx, @@ -268,9 +268,7 @@ void grpc_metadata_batch_clear(grpc_exec_ctx *exec_ctx, } bool grpc_metadata_batch_is_empty(grpc_metadata_batch *batch) { - return batch->list.head == NULL && - gpr_time_cmp(gpr_inf_future(batch->deadline.clock_type), - batch->deadline) == 0; + return batch->list.head == NULL && batch->deadline == GRPC_MILLIS_INF_FUTURE; } size_t grpc_metadata_batch_size(grpc_metadata_batch *batch) { diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index 1b11a3e252..3498cdd926 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -50,9 +50,9 @@ typedef struct grpc_metadata_batch { grpc_mdelem_list list; grpc_metadata_batch_callouts idx; /** Used to calculate grpc-timeout at the point of sending, - or gpr_inf_future if this batch does not need to send a + or GRPC_MILLIS_INF_FUTURE if this batch does not need to send a grpc-timeout */ - gpr_timespec deadline; + grpc_millis deadline; } grpc_metadata_batch; void grpc_metadata_batch_init(grpc_metadata_batch *batch); diff --git a/src/core/lib/transport/status_conversion.c b/src/core/lib/transport/status_conversion.c index 9a76977e4b..73d20a170b 100644 --- a/src/core/lib/transport/status_conversion.c +++ b/src/core/lib/transport/status_conversion.c @@ -37,8 +37,9 @@ int grpc_status_to_http2_error(grpc_status_code status) { } } -grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error, - gpr_timespec deadline) { +grpc_status_code grpc_http2_error_to_grpc_status(grpc_exec_ctx *exec_ctx, + grpc_http2_error_code error, + grpc_millis deadline) { switch (error) { case GRPC_HTTP2_NO_ERROR: /* should never be received */ @@ -46,7 +47,7 @@ grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error, case GRPC_HTTP2_CANCEL: /* http2 cancel translates to STATUS_CANCELLED iff deadline hasn't been * exceeded */ - return gpr_time_cmp(gpr_now(deadline.clock_type), deadline) >= 0 + return grpc_exec_ctx_now(exec_ctx) > deadline ? GRPC_STATUS_DEADLINE_EXCEEDED : GRPC_STATUS_CANCELLED; case GRPC_HTTP2_ENHANCE_YOUR_CALM: diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h index e93f3dfd9b..a05ed7658c 100644 --- a/src/core/lib/transport/status_conversion.h +++ b/src/core/lib/transport/status_conversion.h @@ -20,12 +20,14 @@ #define GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/transport/http2_errors.h" /* Conversion of grpc status codes to http2 error codes (for RST_STREAM) */ grpc_http2_error_code grpc_status_to_http2_error(grpc_status_code status); -grpc_status_code grpc_http2_error_to_grpc_status(grpc_http2_error_code error, - gpr_timespec deadline); +grpc_status_code grpc_http2_error_to_grpc_status(grpc_exec_ctx *exec_ctx, + grpc_http2_error_code error, + grpc_millis deadline); /* Conversion of HTTP status codes (:status) to grpc status codes */ grpc_status_code grpc_http2_status_to_grpc_status(int status); diff --git a/src/core/lib/transport/timeout_encoding.c b/src/core/lib/transport/timeout_encoding.c index 02f179d6a3..779d016ca6 100644 --- a/src/core/lib/transport/timeout_encoding.c +++ b/src/core/lib/transport/timeout_encoding.c @@ -59,60 +59,27 @@ static void enc_seconds(char *buffer, int64_t sec) { } } -static void enc_nanos(char *buffer, int64_t x) { +static void enc_millis(char *buffer, int64_t x) { x = round_up_to_three_sig_figs(x); - if (x < 100000) { - if (x % 1000 == 0) { - enc_ext(buffer, x / 1000, 'u'); - } else { - enc_ext(buffer, x, 'n'); - } - } else if (x < 100000000) { - if (x % 1000000 == 0) { - enc_ext(buffer, x / 1000000, 'm'); - } else { - enc_ext(buffer, x / 1000, 'u'); - } - } else if (x < 1000000000) { - enc_ext(buffer, x / 1000000, 'm'); + if (x < GPR_MS_PER_SEC) { + enc_ext(buffer, x, 'm'); } else { - /* note that this is only ever called with times of less than one second, - so if we reach here the time must have been rounded up to a whole second - (and no more) */ - memcpy(buffer, "1S", 3); - } -} - -static void enc_micros(char *buffer, int64_t x) { - x = round_up_to_three_sig_figs(x); - if (x < 100000) { - if (x % 1000 == 0) { - enc_ext(buffer, x / 1000, 'm'); + if (x % GPR_MS_PER_SEC == 0) { + enc_seconds(buffer, x / GPR_MS_PER_SEC); } else { - enc_ext(buffer, x, 'u'); + enc_ext(buffer, x, 'm'); } - } else if (x < 100000000) { - if (x % 1000000 == 0) { - enc_ext(buffer, x / 1000000, 'S'); - } else { - enc_ext(buffer, x / 1000, 'm'); - } - } else { - enc_ext(buffer, x / 1000000, 'S'); } } -void grpc_http2_encode_timeout(gpr_timespec timeout, char *buffer) { - if (timeout.tv_sec < 0) { +void grpc_http2_encode_timeout(grpc_millis timeout, char *buffer) { + if (timeout <= 0) { enc_tiny(buffer); - } else if (timeout.tv_sec == 0) { - enc_nanos(buffer, timeout.tv_nsec); - } else if (timeout.tv_sec < 1000 && timeout.tv_nsec != 0) { - enc_micros(buffer, - (int64_t)(timeout.tv_sec * 1000000) + - (timeout.tv_nsec / 1000 + (timeout.tv_nsec % 1000 != 0))); + } else if (timeout < 1000 * GPR_MS_PER_SEC) { + enc_millis(buffer, timeout); } else { - enc_seconds(buffer, timeout.tv_sec + (timeout.tv_nsec != 0)); + enc_seconds(buffer, + timeout / GPR_MS_PER_SEC + (timeout % GPR_MS_PER_SEC != 0)); } } @@ -121,7 +88,7 @@ static int is_all_whitespace(const char *p, const char *end) { return p == end; } -int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) { +int grpc_http2_decode_timeout(grpc_slice text, grpc_millis *timeout) { int32_t x = 0; const uint8_t *p = GRPC_SLICE_START_PTR(text); const uint8_t *end = GRPC_SLICE_END_PTR(text); @@ -136,7 +103,7 @@ int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) { /* spec allows max. 8 digits, but we allow values up to 1,000,000,000 */ if (x >= (100 * 1000 * 1000)) { if (x != (100 * 1000 * 1000) || digit != 0) { - *timeout = gpr_inf_future(GPR_TIMESPAN); + *timeout = GRPC_MILLIS_INF_FUTURE; return 1; } } @@ -150,22 +117,22 @@ int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout) { /* decode unit specifier */ switch (*p) { case 'n': - *timeout = gpr_time_from_nanos(x, GPR_TIMESPAN); + *timeout = x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); break; case 'u': - *timeout = gpr_time_from_micros(x, GPR_TIMESPAN); + *timeout = x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); break; case 'm': - *timeout = gpr_time_from_millis(x, GPR_TIMESPAN); + *timeout = x; break; case 'S': - *timeout = gpr_time_from_seconds(x, GPR_TIMESPAN); + *timeout = x * GPR_MS_PER_SEC; break; case 'M': - *timeout = gpr_time_from_minutes(x, GPR_TIMESPAN); + *timeout = x * 60 * GPR_MS_PER_SEC; break; case 'H': - *timeout = gpr_time_from_hours(x, GPR_TIMESPAN); + *timeout = x * 60 * 60 * GPR_MS_PER_SEC; break; default: return 0; diff --git a/src/core/lib/transport/timeout_encoding.h b/src/core/lib/transport/timeout_encoding.h index 7ff35c4083..c8677719c4 100644 --- a/src/core/lib/transport/timeout_encoding.h +++ b/src/core/lib/transport/timeout_encoding.h @@ -22,13 +22,14 @@ #include #include +#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/support/string.h" #define GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE (GPR_LTOA_MIN_BUFSIZE + 1) /* Encode/decode timeouts to the GRPC over HTTP/2 format; encoding may round up arbitrarily */ -void grpc_http2_encode_timeout(gpr_timespec timeout, char *buffer); -int grpc_http2_decode_timeout(grpc_slice text, gpr_timespec *timeout); +void grpc_http2_encode_timeout(grpc_millis timeout, char *buffer); +int grpc_http2_decode_timeout(grpc_slice text, grpc_millis *timeout); #endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ diff --git a/src/core/lib/transport/transport_op_string.c b/src/core/lib/transport/transport_op_string.c index 7b18229ba6..14414c7ee9 100644 --- a/src/core/lib/transport/transport_op_string.c +++ b/src/core/lib/transport/transport_op_string.c @@ -48,10 +48,9 @@ static void put_metadata_list(gpr_strvec *b, grpc_metadata_batch md) { if (m != md.list.head) gpr_strvec_add(b, gpr_strdup(", ")); put_metadata(b, m->md); } - if (gpr_time_cmp(md.deadline, gpr_inf_future(md.deadline.clock_type)) != 0) { + if (md.deadline != GRPC_MILLIS_INF_FUTURE) { char *tmp; - gpr_asprintf(&tmp, " deadline=%" PRId64 ".%09d", md.deadline.tv_sec, - md.deadline.tv_nsec); + gpr_asprintf(&tmp, " deadline=%" PRIdPTR, md.deadline); gpr_strvec_add(b, tmp); } } diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index 0c4bae6ded..f78ebe7efa 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -130,7 +130,7 @@ static void test_create_channel_stack(void) { .context = NULL, .path = path, .start_time = gpr_now(GPR_CLOCK_MONOTONIC), - .deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC), + .deadline = GRPC_MILLIS_INF_FUTURE, .arena = NULL}; grpc_error *error = grpc_call_stack_init(&exec_ctx, channel_stack, 1, free_call, call_stack, &args); diff --git a/test/core/transport/status_conversion_test.c b/test/core/transport/status_conversion_test.c index 89558964c1..de8fa4458a 100644 --- a/test/core/transport/status_conversion_test.c +++ b/test/core/transport/status_conversion_test.c @@ -22,8 +22,13 @@ #define GRPC_STATUS_TO_HTTP2_ERROR(a, b) \ GPR_ASSERT(grpc_status_to_http2_error(a) == (b)) -#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \ - GPR_ASSERT(grpc_http2_error_to_grpc_status(a, deadline) == (b)) +#define HTTP2_ERROR_TO_GRPC_STATUS(a, deadline, b) \ + do { \ + grpc_exec_ctx my_exec_ctx = GRPC_EXEC_CTX_INIT; \ + GPR_ASSERT(grpc_http2_error_to_grpc_status(&my_exec_ctx, a, deadline) == \ + (b)); \ + grpc_exec_ctx_finish(&my_exec_ctx); \ + } while (0) #define GRPC_STATUS_TO_HTTP2_STATUS(a, b) \ GPR_ASSERT(grpc_status_to_http2_status(a) == (b)) #define HTTP2_STATUS_TO_GRPC_STATUS(a, b) \ @@ -79,7 +84,7 @@ int main(int argc, char **argv) { GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_UNAVAILABLE, 200); GRPC_STATUS_TO_HTTP2_STATUS(GRPC_STATUS_DATA_LOSS, 200); - const gpr_timespec before_deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis before_deadline = GRPC_MILLIS_INF_FUTURE; HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, before_deadline, GRPC_STATUS_INTERNAL); HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, before_deadline, @@ -107,7 +112,7 @@ int main(int argc, char **argv) { HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_INADEQUATE_SECURITY, before_deadline, GRPC_STATUS_PERMISSION_DENIED); - const gpr_timespec after_deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); + const grpc_millis after_deadline = 0; HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_NO_ERROR, after_deadline, GRPC_STATUS_INTERNAL); HTTP2_ERROR_TO_GRPC_STATUS(GRPC_HTTP2_PROTOCOL_ERROR, after_deadline, diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c index 6388ffbcec..fcd263f104 100644 --- a/test/core/transport/timeout_encoding_test.c +++ b/test/core/transport/timeout_encoding_test.c @@ -30,7 +30,7 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) -static void assert_encodes_as(gpr_timespec ts, const char *s) { +static void assert_encodes_as(grpc_millis ts, const char *s) { char buffer[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE]; grpc_http2_encode_timeout(ts, buffer); gpr_log(GPR_INFO, "check '%s' == '%s'", buffer, s); @@ -39,47 +39,38 @@ static void assert_encodes_as(gpr_timespec ts, const char *s) { void test_encoding(void) { LOG_TEST("test_encoding"); - assert_encodes_as(gpr_time_from_micros(-1, GPR_TIMESPAN), "1n"); - assert_encodes_as(gpr_time_from_seconds(-10, GPR_TIMESPAN), "1n"); - assert_encodes_as(gpr_time_from_nanos(10, GPR_TIMESPAN), "10n"); - assert_encodes_as(gpr_time_from_nanos(999999999, GPR_TIMESPAN), "1S"); - assert_encodes_as(gpr_time_from_micros(1, GPR_TIMESPAN), "1u"); - assert_encodes_as(gpr_time_from_micros(10, GPR_TIMESPAN), "10u"); - assert_encodes_as(gpr_time_from_micros(100, GPR_TIMESPAN), "100u"); - assert_encodes_as(gpr_time_from_micros(890, GPR_TIMESPAN), "890u"); - assert_encodes_as(gpr_time_from_micros(900, GPR_TIMESPAN), "900u"); - assert_encodes_as(gpr_time_from_micros(901, GPR_TIMESPAN), "901u"); - assert_encodes_as(gpr_time_from_millis(1, GPR_TIMESPAN), "1m"); - assert_encodes_as(gpr_time_from_millis(2, GPR_TIMESPAN), "2m"); - assert_encodes_as(gpr_time_from_micros(10001, GPR_TIMESPAN), "10100u"); - assert_encodes_as(gpr_time_from_micros(999999, GPR_TIMESPAN), "1S"); - assert_encodes_as(gpr_time_from_millis(1000, GPR_TIMESPAN), "1S"); - assert_encodes_as(gpr_time_from_millis(2000, GPR_TIMESPAN), "2S"); - assert_encodes_as(gpr_time_from_millis(2500, GPR_TIMESPAN), "2500m"); - assert_encodes_as(gpr_time_from_millis(59900, GPR_TIMESPAN), "59900m"); - assert_encodes_as(gpr_time_from_seconds(50, GPR_TIMESPAN), "50S"); - assert_encodes_as(gpr_time_from_seconds(59, GPR_TIMESPAN), "59S"); - assert_encodes_as(gpr_time_from_seconds(60, GPR_TIMESPAN), "1M"); - assert_encodes_as(gpr_time_from_seconds(80, GPR_TIMESPAN), "80S"); - assert_encodes_as(gpr_time_from_seconds(90, GPR_TIMESPAN), "90S"); - assert_encodes_as(gpr_time_from_minutes(2, GPR_TIMESPAN), "2M"); - assert_encodes_as(gpr_time_from_minutes(20, GPR_TIMESPAN), "20M"); - assert_encodes_as(gpr_time_from_hours(1, GPR_TIMESPAN), "1H"); - assert_encodes_as(gpr_time_from_hours(10, GPR_TIMESPAN), "10H"); - assert_encodes_as(gpr_time_from_seconds(1000000000, GPR_TIMESPAN), - "1000000000S"); + assert_encodes_as(-1, "1n"); + assert_encodes_as(-10, "1n"); + assert_encodes_as(1, "1m"); + assert_encodes_as(10, "10m"); + assert_encodes_as(100, "100m"); + assert_encodes_as(890, "890m"); + assert_encodes_as(900, "900m"); + assert_encodes_as(901, "901m"); + assert_encodes_as(1000, "1S"); + assert_encodes_as(2000, "2S"); + assert_encodes_as(2500, "2500m"); + assert_encodes_as(59900, "59900m"); + assert_encodes_as(50000, "50S"); + assert_encodes_as(59000, "59S"); + assert_encodes_as(60000, "1M"); + assert_encodes_as(80000, "80S"); + assert_encodes_as(90000, "90S"); + assert_encodes_as(120000, "2M"); + assert_encodes_as(20 * 60 * GPR_MS_PER_SEC, "20M"); + assert_encodes_as(60 * 60 * GPR_MS_PER_SEC, "1H"); + assert_encodes_as(10 * 60 * 60 * GPR_MS_PER_SEC, "10H"); } -static void assert_decodes_as(const char *buffer, gpr_timespec expected) { - gpr_timespec got; +static void assert_decodes_as(const char *buffer, grpc_millis expected) { + grpc_millis got; gpr_log(GPR_INFO, "check decoding '%s'", buffer); GPR_ASSERT(1 == grpc_http2_decode_timeout( grpc_slice_from_static_string(buffer), &got)); - GPR_ASSERT(0 == gpr_time_cmp(got, expected)); + GPR_ASSERT(got == expected); } -void decode_suite(char ext, - gpr_timespec (*answer)(int64_t x, gpr_clock_type clock)) { +void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) { long test_vals[] = {1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 98765432, 9876543, 987654, 98765, 9876, 987, 98, 9}; @@ -87,41 +78,51 @@ void decode_suite(char ext, char *input; for (i = 0; i < GPR_ARRAY_SIZE(test_vals); i++) { gpr_asprintf(&input, "%ld%c", test_vals[i], ext); - assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN)); + assert_decodes_as(input, answer(test_vals[i])); gpr_free(input); gpr_asprintf(&input, " %ld%c", test_vals[i], ext); - assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN)); + assert_decodes_as(input, answer(test_vals[i])); gpr_free(input); gpr_asprintf(&input, "%ld %c", test_vals[i], ext); - assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN)); + assert_decodes_as(input, answer(test_vals[i])); gpr_free(input); gpr_asprintf(&input, "%ld %c ", test_vals[i], ext); - assert_decodes_as(input, answer(test_vals[i], GPR_TIMESPAN)); + assert_decodes_as(input, answer(test_vals[i])); gpr_free(input); } } +static grpc_millis millis_from_nanos(int64_t x) { return x / GPR_NS_PER_MS; } +static grpc_millis millis_from_micros(int64_t x) { return x / GPR_US_PER_MS; } +static grpc_millis millis_from_millis(int64_t x) { return x; } +static grpc_millis millis_from_seconds(int64_t x) { return x * GPR_MS_PER_SEC; } +static grpc_millis millis_from_minutes(int64_t x) { + return x * 60 * GPR_MS_PER_SEC; +} +static grpc_millis millis_from_hours(int64_t x) { + return x * 3600 * GPR_MS_PER_SEC; +} + void test_decoding(void) { LOG_TEST("test_decoding"); - decode_suite('n', gpr_time_from_nanos); - decode_suite('u', gpr_time_from_micros); - decode_suite('m', gpr_time_from_millis); - decode_suite('S', gpr_time_from_seconds); - decode_suite('M', gpr_time_from_minutes); - decode_suite('H', gpr_time_from_hours); - assert_decodes_as("1000000000S", - gpr_time_from_seconds(1000 * 1000 * 1000, GPR_TIMESPAN)); - assert_decodes_as("1000000000000000000000u", gpr_inf_future(GPR_TIMESPAN)); - assert_decodes_as("1000000001S", gpr_inf_future(GPR_TIMESPAN)); - assert_decodes_as("2000000001S", gpr_inf_future(GPR_TIMESPAN)); - assert_decodes_as("9999999999S", gpr_inf_future(GPR_TIMESPAN)); + decode_suite('n', millis_from_nanos); + decode_suite('u', millis_from_micros); + decode_suite('m', millis_from_millis); + decode_suite('S', millis_from_seconds); + decode_suite('M', millis_from_minutes); + decode_suite('H', millis_from_hours); + assert_decodes_as("1000000000S", millis_from_seconds(1000 * 1000 * 1000)); + assert_decodes_as("1000000000000000000000u", GRPC_MILLIS_INF_FUTURE); + assert_decodes_as("1000000001S", GRPC_MILLIS_INF_FUTURE); + assert_decodes_as("2000000001S", GRPC_MILLIS_INF_FUTURE); + assert_decodes_as("9999999999S", GRPC_MILLIS_INF_FUTURE); } static void assert_decoding_fails(const char *s) { - gpr_timespec x; + grpc_millis x; GPR_ASSERT(0 == grpc_http2_decode_timeout(grpc_slice_from_static_string(s), &x)); } diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 508f7f94d6..c248c2348c 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -563,7 +563,7 @@ static void BM_IsolatedFilter(benchmark::State &state) { grpc_exec_ctx_flush(&exec_ctx); grpc_call_stack *call_stack = static_cast( gpr_zalloc(channel_stack->call_stack_size)); - gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + grpc_millis deadline = GRPC_MILLIS_INF_FUTURE; gpr_timespec start_time = gpr_now(GPR_CLOCK_MONOTONIC); grpc_slice method = grpc_slice_from_static_string("/foo/bar"); grpc_call_final_info final_info; diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 567ef1cf24..d3b98f4493 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -296,7 +296,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State &state) { grpc_metadata_batch b; grpc_metadata_batch_init(&b); - b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + b.deadline = GRPC_MILLIS_INF_FUTURE; std::vector elems = Metadata::GetElems(f.exec_ctx()); std::vector storage(elems.size()); for (size_t i = 0; i < elems.size(); i++) { @@ -377,7 +377,7 @@ static void BM_TransportStreamSend(benchmark::State &state) { grpc_metadata_batch b; grpc_metadata_batch_init(&b); - b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + b.deadline = GRPC_MILLIS_INF_FUTURE; std::vector elems = RepresentativeClientInitialMetadata::GetElems(f.exec_ctx()); std::vector storage(elems.size()); @@ -497,7 +497,7 @@ static void BM_TransportStreamRecv(benchmark::State &state) { grpc_metadata_batch_init(&b); grpc_metadata_batch b_recv; grpc_metadata_batch_init(&b_recv); - b.deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); + b.deadline = GRPC_MILLIS_INF_FUTURE; std::vector elems = RepresentativeClientInitialMetadata::GetElems(f.exec_ctx()); std::vector storage(elems.size()); diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index f79db15a47..574e76bfbd 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -70,9 +70,9 @@ static void cq_done_cb(grpc_exec_ctx* exec_ctx, void* done_arg, /* Queues a completion tag if deadline is > 0. * Does nothing if deadline is 0 (i.e gpr_time_0(GPR_CLOCK_MONOTONIC)) */ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps, - grpc_pollset_worker** worker, gpr_timespec now, - gpr_timespec deadline) { - if (gpr_time_cmp(deadline, gpr_time_0(GPR_CLOCK_MONOTONIC)) == 0) { + grpc_pollset_worker** worker, + grpc_millis deadline) { + if (deadline == 0) { gpr_log(GPR_DEBUG, "no-op"); return GRPC_ERROR_NONE; } diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index bd5f02e172..56b80dfcf6 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -159,39 +159,39 @@ BENCHMARK(BM_ErrorGetPresentInt); // Fixtures for tests: generate different kinds of errors class ErrorNone { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return GRPC_ERROR_NONE; } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; }; class ErrorCancelled { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return GRPC_ERROR_CANCELLED; } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; }; class SimpleError { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error")}; }; class ErrorWithGrpcStatus { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED)}; @@ -199,11 +199,11 @@ class ErrorWithGrpcStatus { class ErrorWithHttpError { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_COMPRESSION_ERROR)}; @@ -211,11 +211,11 @@ class ErrorWithHttpError { class ErrorWithNestedGrpcStatus { public: - gpr_timespec deadline() const { return deadline_; } + grpc_millis deadline() const { return deadline_; } grpc_error* error() const { return error_.get(); } private: - const gpr_timespec deadline_ = gpr_inf_future(GPR_CLOCK_MONOTONIC); + const grpc_millis deadline_ = GRPC_MILLIS_INF_FUTURE; ErrorPtr nested_error_{grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Error"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNIMPLEMENTED)}; @@ -248,12 +248,14 @@ template static void BM_ErrorGetStatus(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_status_code status; grpc_slice slice; - grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice, - NULL); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), + &status, &slice, NULL); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } @@ -261,11 +263,13 @@ template static void BM_ErrorGetStatusCode(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_status_code status; - grpc_error_get_status(fixture.error(), fixture.deadline(), &status, NULL, - NULL); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), + &status, NULL, NULL); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } @@ -273,11 +277,13 @@ template static void BM_ErrorHttpError(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_http2_error_code error; - grpc_error_get_status(fixture.error(), fixture.deadline(), NULL, NULL, - &error); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), NULL, + NULL, &error); } + grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); } diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index 683f4703c2..cd62e691d6 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -117,11 +117,9 @@ static void BM_PollEmptyPollset(benchmark::State& state) { gpr_mu* mu; grpc_pollset_init(ps, &mu); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_timespec now = gpr_time_0(GPR_CLOCK_MONOTONIC); - gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); gpr_mu_lock(mu); while (state.KeepRunning()) { - GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, now, deadline)); + GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, 0)); } grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, @@ -223,8 +221,6 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { gpr_mu* mu; grpc_pollset_init(ps, &mu); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_timespec now = gpr_time_0(GPR_CLOCK_MONOTONIC); - gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); grpc_wakeup_fd wakeup_fd; GRPC_ERROR_UNREF(grpc_wakeup_fd_init(&wakeup_fd)); grpc_fd* wakeup = grpc_fd_create(wakeup_fd.read_fd, "wakeup_read"); @@ -245,7 +241,8 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure); gpr_mu_lock(mu); while (!done) { - GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, now, deadline)); + GRPC_ERROR_UNREF( + grpc_pollset_work(&exec_ctx, ps, NULL, GRPC_MILLIS_INF_FUTURE)); } grpc_fd_orphan(&exec_ctx, wakeup, NULL, NULL, "done"); wakeup_fd.read_fd = 0; -- cgit v1.2.3 From 9a8c3f398aed287decf6f8966a46478624f7c4f1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 21 Jul 2017 13:14:14 -0700 Subject: Explicitly call out round up vs round down --- .../ext/filters/client_channel/channel_connectivity.c | 3 ++- src/core/ext/filters/client_channel/client_channel.c | 2 +- src/core/lib/iomgr/exec_ctx.c | 17 ++++++++++++++++- src/core/lib/iomgr/exec_ctx.h | 3 ++- src/core/lib/surface/alarm.c | 4 ++-- src/core/lib/surface/channel.c | 4 ++-- src/core/lib/surface/completion_queue.c | 4 ++-- test/core/http/httpcli_test.c | 3 ++- test/core/http/httpscli_test.c | 3 ++- test/core/iomgr/endpoint_tests.c | 4 ++-- test/core/iomgr/resolve_address_posix_test.c | 3 ++- test/core/iomgr/resolve_address_test.c | 3 ++- test/core/iomgr/tcp_client_posix_test.c | 8 ++++---- test/core/iomgr/tcp_posix_test.c | 10 +++++----- test/core/iomgr/tcp_server_posix_test.c | 2 +- test/core/iomgr/udp_server_test.c | 3 ++- test/core/util/test_tcp_server.c | 4 ++-- 17 files changed, 51 insertions(+), 29 deletions(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/channel_connectivity.c b/src/core/ext/filters/client_channel/channel_connectivity.c index 72324d7eb1..0a1d6f3207 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.c +++ b/src/core/ext/filters/client_channel/channel_connectivity.c @@ -186,7 +186,8 @@ 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(wa->deadline), &wa->w->on_timeout); + grpc_timespec_to_millis_round_up(wa->deadline), + &wa->w->on_timeout); gpr_free(wa); } diff --git a/src/core/ext/filters/client_channel/client_channel.c b/src/core/ext/filters/client_channel/client_channel.c index 508c473c6a..47bbd8416e 100644 --- a/src/core/ext/filters/client_channel/client_channel.c +++ b/src/core/ext/filters/client_channel/client_channel.c @@ -956,7 +956,7 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx *exec_ctx, if (chand->deadline_checking_enabled && calld->method_params->timeout != 0) { const grpc_millis per_method_deadline = - grpc_timespec_to_millis(calld->call_start_time) + + grpc_timespec_to_millis_round_up(calld->call_start_time) + calld->method_params->timeout; if (per_method_deadline < calld->deadline) { calld->deadline = per_method_deadline; diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c index 80aaaee0cb..884227b928 100644 --- a/src/core/lib/iomgr/exec_ctx.c +++ b/src/core/lib/iomgr/exec_ctx.c @@ -125,6 +125,16 @@ static gpr_atm timespec_to_atm_round_down(gpr_timespec ts) { return (gpr_atm)x; } +static gpr_atm timespec_to_atm_round_up(gpr_timespec ts) { + ts = gpr_time_sub(ts, g_start_time); + double x = GPR_MS_PER_SEC * (double)ts.tv_sec + + (double)ts.tv_nsec / GPR_NS_PER_MS + + (double)(GPR_NS_PER_SEC - 1) / (double)GPR_NS_PER_SEC; + if (x < 0) return 0; + if (x > GPR_ATM_MAX) return GPR_ATM_MAX; + return (gpr_atm)x; +} + grpc_millis grpc_exec_ctx_now(grpc_exec_ctx *exec_ctx) { if (!exec_ctx->now_is_valid) { exec_ctx->now = timespec_to_atm_round_down(gpr_now(GPR_CLOCK_MONOTONIC)); @@ -143,11 +153,16 @@ gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_time_from_millis(millis, GPR_TIMESPAN)); } -grpc_millis grpc_timespec_to_millis(gpr_timespec ts) { +grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec ts) { return timespec_to_atm_round_down( gpr_convert_clock_type(ts, g_start_time.clock_type)); } +grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec ts) { + return timespec_to_atm_round_up( + 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}; diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 87383809f3..bb561ee1c8 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -114,6 +114,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_millis millis, gpr_clock_type clock); -grpc_millis grpc_timespec_to_millis(gpr_timespec timespec); +grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec); +grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec); #endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */ diff --git a/src/core/lib/surface/alarm.c b/src/core/lib/surface/alarm.c index 5140780bac..39b9f45d05 100644 --- a/src/core/lib/surface/alarm.c +++ b/src/core/lib/surface/alarm.c @@ -52,8 +52,8 @@ 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(deadline), - &alarm->on_alarm); + grpc_timer_init(&exec_ctx, &alarm->alarm, + grpc_timespec_to_millis_round_up(deadline), &alarm->on_alarm); grpc_exec_ctx_finish(&exec_ctx); return alarm; } diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index b0ff428393..9013e6338b 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -276,7 +276,7 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, host != NULL ? grpc_mdelem_from_slices(&exec_ctx, GRPC_MDSTR_AUTHORITY, grpc_slice_ref_internal(*host)) : GRPC_MDNULL, - grpc_timespec_to_millis(deadline)); + grpc_timespec_to_millis_round_up(deadline)); grpc_exec_ctx_finish(&exec_ctx); return call; } @@ -341,7 +341,7 @@ grpc_call *grpc_channel_create_registered_call( grpc_call *call = grpc_channel_create_call_internal( &exec_ctx, channel, parent_call, propagation_mask, completion_queue, NULL, GRPC_MDELEM_REF(rc->path), GRPC_MDELEM_REF(rc->authority), - grpc_timespec_to_millis(deadline)); + grpc_timespec_to_millis_round_up(deadline)); grpc_exec_ctx_finish(&exec_ctx); return call; } diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index f3a8977241..25f8ff6b6a 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -815,7 +815,7 @@ 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); + grpc_millis deadline_millis = grpc_timespec_to_millis_round_up(deadline); cq_is_finished_arg is_finished_arg = { .last_seen_things_queued_ever = gpr_atm_no_barrier_load(&cqd->things_queued_ever), @@ -1048,7 +1048,7 @@ static grpc_event cq_pluck(grpc_completion_queue *cq, void *tag, GRPC_CQ_INTERNAL_REF(cq, "pluck"); gpr_mu_lock(cq->mu); - grpc_millis deadline_millis = grpc_timespec_to_millis(deadline); + grpc_millis deadline_millis = grpc_timespec_to_millis_round_up(deadline); cq_is_finished_arg is_finished_arg = { .last_seen_things_queued_ever = gpr_atm_no_barrier_load(&cqd->things_queued_ever), diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c index ea63cd1df8..3634932ef1 100644 --- a/test/core/http/httpcli_test.c +++ b/test/core/http/httpcli_test.c @@ -36,7 +36,8 @@ static gpr_mu *g_mu; static grpc_polling_entity g_pops; static grpc_millis n_seconds_time(int seconds) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); } static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c index 6d575d683d..d03dcdf779 100644 --- a/test/core/http/httpscli_test.c +++ b/test/core/http/httpscli_test.c @@ -36,7 +36,8 @@ static gpr_mu *g_mu; static grpc_polling_entity g_pops; static grpc_millis n_seconds_time(int seconds) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); } static void on_finish(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index e80dce01cf..684858088f 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -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(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(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(grpc_timeout_seconds_to_deadline(10)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); while (grpc_exec_ctx_now(exec_ctx) < deadline && *fail_count < want_fail_count) { grpc_pollset_worker *worker = NULL; diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.c index d9d200d2c4..0a18ec7508 100644 --- a/test/core/iomgr/resolve_address_posix_test.c +++ b/test/core/iomgr/resolve_address_posix_test.c @@ -71,7 +71,8 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { } static grpc_millis n_sec_deadline(int seconds) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); } static void actually_poll(void *argsp) { diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c index c6c53be5ca..d475b552b0 100644 --- a/test/core/iomgr/resolve_address_test.c +++ b/test/core/iomgr/resolve_address_test.c @@ -68,7 +68,8 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { } static grpc_millis n_sec_deadline(int seconds) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(seconds)); + return grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); } static void poll_pollset_until_request_done(args_struct *args) { diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c index 69dc82f45e..3cae13ba08 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.c @@ -47,7 +47,7 @@ static int g_connections_complete = 0; static grpc_endpoint *g_connecting = NULL; static grpc_millis test_deadline(void) { - return grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); + return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); } static void finish_connection() { @@ -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, - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(5))))); + grpc_pollset_work(&exec_ctx, g_pollset, &worker, + grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(5))))); gpr_mu_unlock(g_mu); grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index aa55b71725..03b707c247 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -162,7 +162,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { struct read_socket_state state; size_t written_bytes; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(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, @@ -215,7 +215,7 @@ static void large_read_test(size_t slice_size) { struct read_socket_state state; ssize_t written_bytes; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(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); @@ -318,7 +318,7 @@ 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, - grpc_timespec_to_millis( + grpc_timespec_to_millis_round_up( grpc_timeout_milliseconds_to_deadline(10))))); gpr_mu_unlock(g_mu); grpc_exec_ctx_finish(&exec_ctx); @@ -353,7 +353,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { grpc_slice_buffer outgoing; grpc_closure write_done_closure; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, @@ -419,7 +419,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { size_t written_bytes; int fd; grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(20)); + grpc_timespec_to_millis_round_up(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; diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c index 13ff92cb5b..0cde2d0e72 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.c @@ -231,7 +231,7 @@ 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) { grpc_millis deadline = - grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); int clifd; int nconnects_before; const struct sockaddr *remote_addr = diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c index 2f6f503443..5977da3d44 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -252,7 +252,8 @@ static void test_receive(int number_of_clients) { gpr_mu_lock(g_mu); for (i = 0; i < number_of_clients; i++) { - deadline = grpc_timespec_to_millis(grpc_timeout_seconds_to_deadline(10)); + deadline = + grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); number_of_reads_before = g_number_of_reads; /* Create a socket, send a packet to the UDP server. */ diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c index ce05833aa9..611ecb330c 100644 --- a/test/core/util/test_tcp_server.c +++ b/test/core/util/test_tcp_server.c @@ -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(grpc_timeout_seconds_to_deadline(seconds)); + grpc_millis deadline = grpc_timespec_to_millis_round_up( + grpc_timeout_seconds_to_deadline(seconds)); gpr_mu_lock(server->mu); GRPC_LOG_IF_ERROR( "pollset_work", -- cgit v1.2.3 From 6ef8db92bc16ea23dd579f2706335c764f45bc4c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 18:39:59 +0000 Subject: Fix test --- src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c | 3 +++ test/core/end2end/invalid_call_argument_test.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c index 7287a5dabc..fd91ac8699 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c @@ -150,6 +150,8 @@ static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_channel_args *result = NULL; GPR_ASSERT(r->resolving); r->resolving = false; + GRPC_ERROR_REF(error); + error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(r->name_to_resolve)); if (r->addresses != NULL) { grpc_lb_addresses *addresses = grpc_lb_addresses_create( r->addresses->naddrs, NULL /* user_data_vtable */); @@ -186,6 +188,7 @@ static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg, r->resolved_result = result; r->resolved_version++; dns_maybe_finish_next_locked(exec_ctx, r); + GRPC_ERROR_UNREF(error); GRPC_RESOLVER_UNREF(exec_ctx, &r->base, "dns-resolving"); } diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index bf0d08adec..e3fd5a8fbe 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -92,7 +92,7 @@ static void prepare_test(int is_client) { op = g_state.ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; - op->flags = 0; + op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY; op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(g_state.call, g_state.ops, -- cgit v1.2.3 From d0ceb377a434e6d8807d461417df3d6de089a1e2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 19 Sep 2017 12:02:31 -0700 Subject: clang-format --- .../filters/client_channel/resolver/dns/native/dns_resolver.c | 3 ++- test/core/transport/timeout_encoding_test.c | 11 ++++++++--- test/cpp/naming/resolver_component_test.cc | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c index fd91ac8699..e4bffbe871 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c @@ -151,7 +151,8 @@ static void dns_on_resolved_locked(grpc_exec_ctx *exec_ctx, void *arg, GPR_ASSERT(r->resolving); r->resolving = false; GRPC_ERROR_REF(error); - error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, grpc_slice_from_copied_string(r->name_to_resolve)); + error = grpc_error_set_str(error, GRPC_ERROR_STR_TARGET_ADDRESS, + grpc_slice_from_copied_string(r->name_to_resolve)); if (r->addresses != NULL) { grpc_lb_addresses *addresses = grpc_lb_addresses_create( r->addresses->naddrs, NULL /* user_data_vtable */); diff --git a/test/core/transport/timeout_encoding_test.c b/test/core/transport/timeout_encoding_test.c index 039bb33341..3010c6d057 100644 --- a/test/core/transport/timeout_encoding_test.c +++ b/test/core/transport/timeout_encoding_test.c @@ -70,7 +70,8 @@ static void assert_decodes_as(const char *buffer, grpc_millis expected) { GPR_ASSERT(1 == grpc_http2_decode_timeout( grpc_slice_from_static_string(buffer), &got)); if (got != expected) { - gpr_log(GPR_ERROR, "got:'%"PRIdPTR"' != expected:'%"PRIdPTR"'", got, expected); + gpr_log(GPR_ERROR, "got:'%" PRIdPTR "' != expected:'%" PRIdPTR "'", got, + expected); abort(); } } @@ -100,8 +101,12 @@ void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) { } } -static grpc_millis millis_from_nanos(int64_t x) { return x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); } -static grpc_millis millis_from_micros(int64_t x) { return x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); } +static grpc_millis millis_from_nanos(int64_t x) { + return x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0); +} +static grpc_millis millis_from_micros(int64_t x) { + return x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0); +} static grpc_millis millis_from_millis(int64_t x) { return x; } static grpc_millis millis_from_seconds(int64_t x) { return x * GPR_MS_PER_SEC; } static grpc_millis millis_from_minutes(int64_t x) { diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 47dee5cb3a..34575e0fe5 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -199,10 +199,10 @@ void PollPollsetUntilRequestDone(ArgsStruct *args) { 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, - grpc_timespec_to_millis_round_up(NSecondDeadline(1)))); + GRPC_LOG_IF_ERROR("pollset_work", + grpc_pollset_work(&exec_ctx, args->pollset, &worker, + grpc_timespec_to_millis_round_up( + NSecondDeadline(1)))); gpr_mu_unlock(args->mu); grpc_exec_ctx_finish(&exec_ctx); } -- cgit v1.2.3 From 301d4c93a478ffbaa533e523a3683140bb783929 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Oct 2017 09:43:01 -0700 Subject: Fix cast --- .../ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c index 9c6fb94bf1..4d5fb2081c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c @@ -300,9 +300,9 @@ int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs, } 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; + return (grpc_millis)( + (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( -- cgit v1.2.3 From 663f50c658b6f13dedac5541f8a0789257225a69 Mon Sep 17 00:00:00 2001 From: Juanli Shen Date: Thu, 5 Oct 2017 14:36:13 -0700 Subject: Cancel fallback timer in glb_shutdown() --- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index d8e314d1f9..773ae29e41 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1010,6 +1010,10 @@ static void glb_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer); glb_policy->retry_timer_active = false; } + if (glb_policy->fallback_timer_active) { + grpc_timer_cancel(exec_ctx, &glb_policy->lb_fallback_timer); + glb_policy->fallback_timer_active = false; + } pending_pick *pp = glb_policy->pending_picks; glb_policy->pending_picks = NULL; -- cgit v1.2.3 From 97b6e5db9f91f974a9655cbd591046d8c3b61a07 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Mon, 9 Oct 2017 08:31:41 -0700 Subject: Process updates immediately instead of waiting for a previous one to complete. --- .../client_channel/lb_policy/grpclb/grpclb.cc | 55 +++------------------- 1 file changed, 7 insertions(+), 48 deletions(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 53fa0fff04..ffd58129c6 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -345,9 +345,6 @@ typedef struct glb_lb_policy { /** are we currently updating lb_call? */ bool updating_lb_call; - /** are we currently updating lb_channel? */ - bool updating_lb_channel; - /** are we already watching the LB channel's connectivity? */ bool watching_lb_channel; @@ -360,9 +357,6 @@ typedef struct glb_lb_policy { /** called upon changes to the LB channel's connectivity. */ grpc_closure lb_channel_on_connectivity_changed; - /** args from the latest update received while already updating, or NULL */ - grpc_lb_policy_args *pending_update_args; - /************************************************************/ /* client data associated with the LB server communication */ /************************************************************/ @@ -982,10 +976,6 @@ static void glb_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { } grpc_fake_resolver_response_generator_unref(glb_policy->response_generator); grpc_subchannel_index_unref(); - if (glb_policy->pending_update_args != NULL) { - grpc_channel_args_destroy(exec_ctx, glb_policy->pending_update_args->args); - gpr_free(glb_policy->pending_update_args); - } gpr_free(glb_policy); } @@ -1752,45 +1742,22 @@ static void glb_update_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy, } const grpc_lb_addresses *addresses = (const grpc_lb_addresses *)arg->value.pointer.p; - + // If a non-empty serverlist hasn't been received from the balancer, + // propagate the update to fallback_backend_addresses. if (glb_policy->serverlist == NULL) { - // If a non-empty serverlist hasn't been received from the balancer, - // propagate the update to fallback_backend_addresses. fallback_update_locked(exec_ctx, glb_policy, addresses); - } else if (glb_policy->updating_lb_channel) { - // If we have recieved serverlist from the balancer, we need to defer update - // when there is an in-progress one. - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { - gpr_log(GPR_INFO, - "Update already in progress for grpclb %p. Deferring update.", - (void *)glb_policy); - } - if (glb_policy->pending_update_args != NULL) { - grpc_channel_args_destroy(exec_ctx, - glb_policy->pending_update_args->args); - gpr_free(glb_policy->pending_update_args); - } - glb_policy->pending_update_args = (grpc_lb_policy_args *)gpr_zalloc( - sizeof(*glb_policy->pending_update_args)); - glb_policy->pending_update_args->client_channel_factory = - args->client_channel_factory; - glb_policy->pending_update_args->args = grpc_channel_args_copy(args->args); - glb_policy->pending_update_args->combiner = args->combiner; - return; } - - glb_policy->updating_lb_channel = true; GPR_ASSERT(glb_policy->lb_channel != NULL); + // Propagate updates to the LB channel (pick_first) through the fake + // resolver. grpc_channel_args *lb_channel_args = build_lb_channel_args( exec_ctx, addresses, glb_policy->response_generator, args->args); - /* Propagate updates to the LB channel (pick first) through the fake resolver - */ grpc_fake_resolver_response_generator_set_response( exec_ctx, glb_policy->response_generator, lb_channel_args); grpc_channel_args_destroy(exec_ctx, lb_channel_args); - + // Start watching the LB channel connectivity for connection, if not + // already doing so. if (!glb_policy->watching_lb_channel) { - // Watch the LB channel connectivity for connection. glb_policy->lb_channel_connectivity = grpc_channel_check_connectivity_state( glb_policy->lb_channel, true /* try to connect */); grpc_channel_element *client_channel_elem = grpc_channel_stack_last_element( @@ -1842,18 +1809,10 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx *exec_ctx, /* fallthrough */ case GRPC_CHANNEL_READY: if (glb_policy->lb_call != NULL) { - glb_policy->updating_lb_channel = false; glb_policy->updating_lb_call = true; grpc_call_cancel(glb_policy->lb_call, NULL); - // lb_on_server_status_received will pick up the cancel and reinit + // lb_on_server_status_received() will pick up the cancel and reinit // lb_call. - if (glb_policy->pending_update_args != NULL) { - grpc_lb_policy_args *args = glb_policy->pending_update_args; - glb_policy->pending_update_args = NULL; - glb_update_locked(exec_ctx, &glb_policy->base, args); - grpc_channel_args_destroy(exec_ctx, args->args); - gpr_free(args); - } } else if (glb_policy->started_picking && !glb_policy->shutting_down) { if (glb_policy->retry_timer_active) { grpc_timer_cancel(exec_ctx, &glb_policy->lb_call_retry_timer); -- cgit v1.2.3 From 12fc6d461e7d8bf37bf0c858164af8b4cad3058c Mon Sep 17 00:00:00 2001 From: Yash Tibrewal Date: Mon, 9 Oct 2017 16:43:34 -0700 Subject: Add newline at the end of src/core headers that did not have it --- src/core/ext/census/base_resources.h | 2 +- src/core/ext/census/census_interface.h | 2 +- src/core/ext/census/census_log.h | 2 +- src/core/ext/census/hash_table.h | 2 +- src/core/ext/census/mlog.h | 2 +- src/core/ext/census/resource.h | 2 +- src/core/ext/census/trace_context.h | 2 +- src/core/ext/census/trace_propagation.h | 2 +- src/core/ext/census/tracing.h | 2 +- src/core/ext/census/window_stats.h | 2 +- src/core/ext/filters/client_channel/client_channel.h | 2 +- src/core/ext/filters/client_channel/client_channel_factory.h | 2 +- src/core/ext/filters/client_channel/connector.h | 2 +- src/core/ext/filters/client_channel/http_connect_handshaker.h | 2 +- src/core/ext/filters/client_channel/http_proxy.h | 2 +- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h | 2 +- src/core/ext/filters/client_channel/lb_policy_factory.h | 2 +- src/core/ext/filters/client_channel/lb_policy_registry.h | 2 +- src/core/ext/filters/client_channel/parse_address.h | 2 +- src/core/ext/filters/client_channel/proxy_mapper.h | 2 +- src/core/ext/filters/client_channel/proxy_mapper_registry.h | 2 +- src/core/ext/filters/client_channel/resolver_factory.h | 2 +- src/core/ext/filters/client_channel/resolver_registry.h | 2 +- src/core/ext/filters/client_channel/retry_throttle.h | 2 +- src/core/ext/filters/client_channel/subchannel_index.h | 2 +- src/core/ext/filters/client_channel/uri_parser.h | 2 +- src/core/ext/filters/deadline/deadline_filter.h | 2 +- src/core/ext/filters/workarounds/workaround_utils.h | 2 +- src/core/ext/transport/chttp2/alpn/alpn.h | 2 +- src/core/ext/transport/chttp2/server/chttp2_server.h | 2 +- src/core/ext/transport/chttp2/transport/bin_decoder.h | 2 +- src/core/ext/transport/chttp2/transport/bin_encoder.h | 2 +- src/core/ext/transport/chttp2/transport/frame_data.h | 2 +- src/core/ext/transport/chttp2/transport/frame_goaway.h | 2 +- src/core/ext/transport/chttp2/transport/frame_ping.h | 2 +- src/core/ext/transport/chttp2/transport/frame_rst_stream.h | 2 +- src/core/ext/transport/chttp2/transport/frame_settings.h | 2 +- src/core/ext/transport/chttp2/transport/frame_window_update.h | 2 +- src/core/ext/transport/chttp2/transport/hpack_encoder.h | 2 +- src/core/ext/transport/chttp2/transport/hpack_parser.h | 2 +- src/core/ext/transport/chttp2/transport/http2_settings.h | 2 +- src/core/ext/transport/chttp2/transport/incoming_metadata.h | 2 +- src/core/ext/transport/chttp2/transport/stream_map.h | 2 +- src/core/lib/channel/channel_args.h | 2 +- src/core/lib/channel/connected_channel.h | 2 +- src/core/lib/channel/handshaker.h | 2 +- src/core/lib/channel/handshaker_factory.h | 2 +- src/core/lib/channel/handshaker_registry.h | 2 +- src/core/lib/compression/algorithm_metadata.h | 2 +- src/core/lib/compression/message_compress.h | 2 +- src/core/lib/http/format_request.h | 2 +- src/core/lib/http/httpcli.h | 2 +- src/core/lib/http/parser.h | 2 +- src/core/lib/iomgr/endpoint.h | 2 +- src/core/lib/iomgr/endpoint_pair.h | 2 +- src/core/lib/iomgr/error_internal.h | 2 +- src/core/lib/iomgr/ev_epoll1_linux.h | 2 +- src/core/lib/iomgr/ev_epollex_linux.h | 2 +- src/core/lib/iomgr/ev_poll_posix.h | 2 +- src/core/lib/iomgr/ev_posix.h | 2 +- src/core/lib/iomgr/executor.h | 2 +- src/core/lib/iomgr/iocp_windows.h | 2 +- src/core/lib/iomgr/iomgr.h | 2 +- src/core/lib/iomgr/iomgr_internal.h | 2 +- src/core/lib/iomgr/is_epollexclusive_available.h | 2 +- src/core/lib/iomgr/lockfree_event.h | 2 +- src/core/lib/iomgr/network_status_tracker.h | 2 +- src/core/lib/iomgr/polling_entity.h | 2 +- src/core/lib/iomgr/pollset_set.h | 2 +- src/core/lib/iomgr/pollset_uv.h | 2 +- src/core/lib/iomgr/pollset_windows.h | 2 +- src/core/lib/iomgr/resolve_address.h | 2 +- src/core/lib/iomgr/resource_quota.h | 2 +- src/core/lib/iomgr/sockaddr_utils.h | 2 +- src/core/lib/iomgr/socket_utils.h | 2 +- src/core/lib/iomgr/socket_utils_posix.h | 2 +- src/core/lib/iomgr/socket_windows.h | 2 +- src/core/lib/iomgr/tcp_client.h | 2 +- src/core/lib/iomgr/tcp_client_posix.h | 2 +- src/core/lib/iomgr/tcp_posix.h | 2 +- src/core/lib/iomgr/tcp_server.h | 2 +- src/core/lib/iomgr/tcp_server_utils_posix.h | 2 +- src/core/lib/iomgr/tcp_uv.h | 2 +- src/core/lib/iomgr/time_averaged_stats.h | 2 +- src/core/lib/iomgr/timer_heap.h | 2 +- src/core/lib/iomgr/timer_manager.h | 2 +- src/core/lib/iomgr/udp_server.h | 2 +- src/core/lib/iomgr/unix_sockets_posix.h | 2 +- src/core/lib/json/json.h | 2 +- src/core/lib/json/json_reader.h | 2 +- src/core/lib/json/json_writer.h | 2 +- src/core/lib/security/credentials/fake/fake_credentials.h | 2 +- src/core/lib/security/credentials/jwt/jwt_credentials.h | 2 +- src/core/lib/security/credentials/oauth2/oauth2_credentials.h | 2 +- src/core/lib/security/transport/lb_targets_info.h | 2 +- src/core/lib/security/transport/secure_endpoint.h | 2 +- src/core/lib/security/transport/security_handshaker.h | 2 +- src/core/lib/security/transport/tsi_error.h | 2 +- src/core/lib/security/util/json_util.h | 2 +- src/core/lib/slice/b64.h | 2 +- src/core/lib/slice/percent_encoding.h | 2 +- src/core/lib/slice/slice_hash_table.h | 2 +- src/core/lib/slice/slice_internal.h | 2 +- src/core/lib/slice/slice_traits.h | 2 +- src/core/lib/surface/channel_stack_type.h | 2 +- src/core/lib/surface/completion_queue_factory.h | 2 +- src/core/lib/surface/event_string.h | 2 +- src/core/lib/surface/init.h | 2 +- src/core/lib/surface/server.h | 2 +- src/core/lib/surface/validate_metadata.h | 2 +- src/core/lib/transport/bdp_estimator.h | 2 +- src/core/lib/transport/byte_stream.h | 2 +- src/core/lib/transport/connectivity_state.h | 2 +- src/core/lib/transport/error_utils.h | 2 +- src/core/lib/transport/pid_controller.h | 2 +- src/core/lib/transport/service_config.h | 2 +- src/core/lib/transport/status_conversion.h | 2 +- src/core/lib/transport/timeout_encoding.h | 2 +- src/core/lib/transport/transport_impl.h | 2 +- src/core/tsi/gts_transport_security.h | 2 +- 120 files changed, 120 insertions(+), 120 deletions(-) (limited to 'src/core/ext/filters/client_channel') diff --git a/src/core/ext/census/base_resources.h b/src/core/ext/census/base_resources.h index 4b1b988e3f..d24923b597 100644 --- a/src/core/ext/census/base_resources.h +++ b/src/core/ext/census/base_resources.h @@ -29,4 +29,4 @@ void define_base_resources(); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */ diff --git a/src/core/ext/census/census_interface.h b/src/core/ext/census/census_interface.h index 12438e3c0a..113c2b16ef 100644 --- a/src/core/ext/census/census_interface.h +++ b/src/core/ext/census/census_interface.h @@ -66,4 +66,4 @@ void census_tracing_end_op(census_op_id op_id); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_INTERFACE_H */ diff --git a/src/core/ext/census/census_log.h b/src/core/ext/census/census_log.h index cc9e008907..ee336ae733 100644 --- a/src/core/ext/census/census_log.h +++ b/src/core/ext/census/census_log.h @@ -81,4 +81,4 @@ int census_log_out_of_space_count(void); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_CENSUS_LOG_H */ diff --git a/src/core/ext/census/hash_table.h b/src/core/ext/census/hash_table.h index c22ba8df9d..c3ed94ea14 100644 --- a/src/core/ext/census/hash_table.h +++ b/src/core/ext/census/hash_table.h @@ -121,4 +121,4 @@ uint64_t census_ht_for_all(const census_ht *ht, census_ht_itr_cb); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_HASH_TABLE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_HASH_TABLE_H */ diff --git a/src/core/ext/census/mlog.h b/src/core/ext/census/mlog.h index 7b4d39272b..8f74ba231d 100644 --- a/src/core/ext/census/mlog.h +++ b/src/core/ext/census/mlog.h @@ -85,4 +85,4 @@ int64_t census_log_out_of_space_count(void); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_MLOG_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_MLOG_H */ diff --git a/src/core/ext/census/resource.h b/src/core/ext/census/resource.h index 5f7ac2ad27..56aaaaf750 100644 --- a/src/core/ext/census/resource.h +++ b/src/core/ext/census/resource.h @@ -53,4 +53,4 @@ int32_t define_resource(const resource *base); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_RESOURCE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_RESOURCE_H */ diff --git a/src/core/ext/census/trace_context.h b/src/core/ext/census/trace_context.h index c707c63263..2b828ba4da 100644 --- a/src/core/ext/census/trace_context.h +++ b/src/core/ext/census/trace_context.h @@ -61,4 +61,4 @@ bool decode_trace_context(google_trace_TraceContext *ctxt, uint8_t *buffer, } #endif -#endif /* GRPC_CORE_EXT_CENSUS_TRACE_CONTEXT_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_TRACE_CONTEXT_H */ diff --git a/src/core/ext/census/trace_propagation.h b/src/core/ext/census/trace_propagation.h index 3394e9e0fd..e05fd23a1f 100644 --- a/src/core/ext/census/trace_propagation.h +++ b/src/core/ext/census/trace_propagation.h @@ -53,4 +53,4 @@ size_t http_format_to_trace_span_context(const char *buf, size_t buf_size, } #endif -#endif /* GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_TRACE_PROPAGATION_H */ diff --git a/src/core/ext/census/tracing.h b/src/core/ext/census/tracing.h index 5fcbb1e1f7..0690de8655 100644 --- a/src/core/ext/census/tracing.h +++ b/src/core/ext/census/tracing.h @@ -114,4 +114,4 @@ void trace_end_span(const trace_status *status, trace_span_context *span_ctxt); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_TRACING_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_TRACING_H */ diff --git a/src/core/ext/census/window_stats.h b/src/core/ext/census/window_stats.h index 3b1d197f76..2a1d6d0d16 100644 --- a/src/core/ext/census/window_stats.h +++ b/src/core/ext/census/window_stats.h @@ -163,4 +163,4 @@ void census_window_stats_destroy(struct census_window_stats *wstats); } #endif -#endif /* GRPC_CORE_EXT_CENSUS_WINDOW_STATS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_CENSUS_WINDOW_STATS_H */ diff --git a/src/core/ext/filters/client_channel/client_channel.h b/src/core/ext/filters/client_channel/client_channel.h index b32f378c6c..152fe2365a 100644 --- a/src/core/ext/filters/client_channel/client_channel.h +++ b/src/core/ext/filters/client_channel/client_channel.h @@ -60,4 +60,4 @@ grpc_subchannel_call *grpc_client_channel_get_subchannel_call( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_H */ diff --git a/src/core/ext/filters/client_channel/client_channel_factory.h b/src/core/ext/filters/client_channel/client_channel_factory.h index bad8b97042..4273c90058 100644 --- a/src/core/ext/filters/client_channel/client_channel_factory.h +++ b/src/core/ext/filters/client_channel/client_channel_factory.h @@ -82,4 +82,4 @@ grpc_arg grpc_client_channel_factory_create_channel_arg( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CLIENT_CHANNEL_FACTORY_H */ diff --git a/src/core/ext/filters/client_channel/connector.h b/src/core/ext/filters/client_channel/connector.h index b91c93e446..b71e0aab00 100644 --- a/src/core/ext/filters/client_channel/connector.h +++ b/src/core/ext/filters/client_channel/connector.h @@ -78,4 +78,4 @@ void grpc_connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *connector, } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */ diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.h b/src/core/ext/filters/client_channel/http_connect_handshaker.h index 5042c61bec..05a23cdba3 100644 --- a/src/core/ext/filters/client_channel/http_connect_handshaker.h +++ b/src/core/ext/filters/client_channel/http_connect_handshaker.h @@ -39,4 +39,4 @@ void grpc_http_connect_register_handshaker_factory(); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H */ diff --git a/src/core/ext/filters/client_channel/http_proxy.h b/src/core/ext/filters/client_channel/http_proxy.h index 65d52334af..bdad03def3 100644 --- a/src/core/ext/filters/client_channel/http_proxy.h +++ b/src/core/ext/filters/client_channel/http_proxy.h @@ -29,4 +29,4 @@ void grpc_register_http_proxy_mapper(); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_PROXY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_PROXY_H */ diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h index c67df609fc..15c8a680b7 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h @@ -34,4 +34,4 @@ grpc_lb_policy_factory *grpc_glb_lb_factory_create(); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_H */ diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.h b/src/core/ext/filters/client_channel/lb_policy_factory.h index 69bcba4232..8790ffdda3 100644 --- a/src/core/ext/filters/client_channel/lb_policy_factory.h +++ b/src/core/ext/filters/client_channel/lb_policy_factory.h @@ -138,4 +138,4 @@ grpc_lb_policy *grpc_lb_policy_factory_create_lb_policy( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_FACTORY_H */ diff --git a/src/core/ext/filters/client_channel/lb_policy_registry.h b/src/core/ext/filters/client_channel/lb_policy_registry.h index 0867844c37..55154cb02a 100644 --- a/src/core/ext/filters/client_channel/lb_policy_registry.h +++ b/src/core/ext/filters/client_channel/lb_policy_registry.h @@ -45,4 +45,4 @@ grpc_lb_policy *grpc_lb_policy_create(grpc_exec_ctx *exec_ctx, const char *name, } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_REGISTRY_H */ diff --git a/src/core/ext/filters/client_channel/parse_address.h b/src/core/ext/filters/client_channel/parse_address.h index 742df380b7..27d06a1cb3 100644 --- a/src/core/ext/filters/client_channel/parse_address.h +++ b/src/core/ext/filters/client_channel/parse_address.h @@ -53,4 +53,4 @@ bool grpc_parse_ipv6_hostport(const char *hostport, grpc_resolved_address *addr, } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PARSE_ADDRESS_H */ diff --git a/src/core/ext/filters/client_channel/proxy_mapper.h b/src/core/ext/filters/client_channel/proxy_mapper.h index 1325a9f1f6..bb8259f854 100644 --- a/src/core/ext/filters/client_channel/proxy_mapper.h +++ b/src/core/ext/filters/client_channel/proxy_mapper.h @@ -79,4 +79,4 @@ void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H */ diff --git a/src/core/ext/filters/client_channel/proxy_mapper_registry.h b/src/core/ext/filters/client_channel/proxy_mapper_registry.h index 2d389f1c21..39c607cefc 100644 --- a/src/core/ext/filters/client_channel/proxy_mapper_registry.h +++ b/src/core/ext/filters/client_channel/proxy_mapper_registry.h @@ -49,4 +49,4 @@ bool grpc_proxy_mappers_map_address(grpc_exec_ctx* exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */ diff --git a/src/core/ext/filters/client_channel/resolver_factory.h b/src/core/ext/filters/client_channel/resolver_factory.h index 6e533e3248..c8b2c58db3 100644 --- a/src/core/ext/filters/client_channel/resolver_factory.h +++ b/src/core/ext/filters/client_channel/resolver_factory.h @@ -75,4 +75,4 @@ char *grpc_resolver_factory_get_default_authority( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */ diff --git a/src/core/ext/filters/client_channel/resolver_registry.h b/src/core/ext/filters/client_channel/resolver_registry.h index eb08d887b1..06d0b99a35 100644 --- a/src/core/ext/filters/client_channel/resolver_registry.h +++ b/src/core/ext/filters/client_channel/resolver_registry.h @@ -74,4 +74,4 @@ char *grpc_resolver_factory_add_default_prefix_if_needed( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */ diff --git a/src/core/ext/filters/client_channel/retry_throttle.h b/src/core/ext/filters/client_channel/retry_throttle.h index 3b849475b9..399383df78 100644 --- a/src/core/ext/filters/client_channel/retry_throttle.h +++ b/src/core/ext/filters/client_channel/retry_throttle.h @@ -55,4 +55,4 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server( } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RETRY_THROTTLE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RETRY_THROTTLE_H */ diff --git a/src/core/ext/filters/client_channel/subchannel_index.h b/src/core/ext/filters/client_channel/subchannel_index.h index 09bac3592c..05c3878379 100644 --- a/src/core/ext/filters/client_channel/subchannel_index.h +++ b/src/core/ext/filters/client_channel/subchannel_index.h @@ -86,4 +86,4 @@ void grpc_subchannel_index_test_only_set_force_creation(bool force_creation); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INDEX_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_SUBCHANNEL_INDEX_H */ diff --git a/src/core/ext/filters/client_channel/uri_parser.h b/src/core/ext/filters/client_channel/uri_parser.h index 43e8ae64e0..e78da5928b 100644 --- a/src/core/ext/filters/client_channel/uri_parser.h +++ b/src/core/ext/filters/client_channel/uri_parser.h @@ -55,4 +55,4 @@ void grpc_uri_destroy(grpc_uri *uri); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_URI_PARSER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_URI_PARSER_H */ diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h index 4a80535b14..e665dc53ee 100644 --- a/src/core/ext/filters/deadline/deadline_filter.h +++ b/src/core/ext/filters/deadline/deadline_filter.h @@ -98,4 +98,4 @@ extern const grpc_channel_filter grpc_server_deadline_filter; } #endif -#endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */ diff --git a/src/core/ext/filters/workarounds/workaround_utils.h b/src/core/ext/filters/workarounds/workaround_utils.h index afd5291333..3913cae6b2 100644 --- a/src/core/ext/filters/workarounds/workaround_utils.h +++ b/src/core/ext/filters/workarounds/workaround_utils.h @@ -42,4 +42,4 @@ void grpc_register_workaround(uint32_t id, user_agent_parser parser); } #endif -#endif /* GRPC_CORE_EXT_FILTERS_WORKAROUNDS_WORKAROUND_UTILS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_FILTERS_WORKAROUNDS_WORKAROUND_UTILS_H */ diff --git a/src/core/ext/transport/chttp2/alpn/alpn.h b/src/core/ext/transport/chttp2/alpn/alpn.h index 5842204c20..99b928ea59 100644 --- a/src/core/ext/transport/chttp2/alpn/alpn.h +++ b/src/core/ext/transport/chttp2/alpn/alpn.h @@ -39,4 +39,4 @@ const char *grpc_chttp2_get_alpn_version_index(size_t i); } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */ diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h index e1df28ed11..2ac155160f 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -37,4 +37,4 @@ grpc_error *grpc_chttp2_server_add_port(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */ diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h index f50e0a8ac4..1c0b2b7e97 100644 --- a/src/core/ext/transport/chttp2/transport/bin_decoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h @@ -57,4 +57,4 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h index ae8219c5ce..0be3633354 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h @@ -44,4 +44,4 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input); } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h index 2df99ccf98..81ec5361a3 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/src/core/ext/transport/chttp2/transport/frame_data.h @@ -88,4 +88,4 @@ grpc_error *grpc_deframe_unprocessed_incoming_frames( } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h index ce6f18b35c..7b3aa45f3f 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -68,4 +68,4 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h index 91f16f050f..ffc2f0cf2f 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -49,4 +49,4 @@ void grpc_set_disable_ping_ack(bool disable_ping_ack); } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index bdca064a91..102ffdb3f3 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -48,4 +48,4 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h index f0793f0e73..3364da1520 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -66,4 +66,4 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h index 29cf0cc740..400f9f5398 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -47,4 +47,4 @@ grpc_error *grpc_chttp2_window_update_parser_parse( } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h index dc28b5566a..16316b63f7 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -99,4 +99,4 @@ void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index 6c36ebdf8d..52014175a0 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -119,4 +119,4 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ diff --git a/src/core/ext/transport/chttp2/transport/http2_settings.h b/src/core/ext/transport/chttp2/transport/http2_settings.h index 01e80b8d01..0f76106dce 100644 --- a/src/core/ext/transport/chttp2/transport/http2_settings.h +++ b/src/core/ext/transport/chttp2/transport/http2_settings.h @@ -64,4 +64,4 @@ extern const grpc_chttp2_setting_parameters } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_H */ diff --git a/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/src/core/ext/transport/chttp2/transport/incoming_metadata.h index 995e8001b1..a0e01f2c4d 100644 --- a/src/core/ext/transport/chttp2/transport/incoming_metadata.h +++ b/src/core/ext/transport/chttp2/transport/incoming_metadata.h @@ -53,4 +53,4 @@ void grpc_chttp2_incoming_metadata_buffer_set_deadline( } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ diff --git a/src/core/ext/transport/chttp2/transport/stream_map.h b/src/core/ext/transport/chttp2/transport/stream_map.h index 364d37c33a..7ab6a4f5ed 100644 --- a/src/core/ext/transport/chttp2/transport/stream_map.h +++ b/src/core/ext/transport/chttp2/transport/stream_map.h @@ -73,4 +73,4 @@ void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map, } #endif -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */ \ No newline at end of file +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */ diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h index 2837174f49..1896d35cf4 100644 --- a/src/core/lib/channel/channel_args.h +++ b/src/core/lib/channel/channel_args.h @@ -157,4 +157,4 @@ grpc_arg grpc_channel_arg_pointer_create(char *name, void *value, } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */ diff --git a/src/core/lib/channel/connected_channel.h b/src/core/lib/channel/connected_channel.h index b55a1089a0..4615727baa 100644 --- a/src/core/lib/channel/connected_channel.h +++ b/src/core/lib/channel/connected_channel.h @@ -38,4 +38,4 @@ grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem); } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */ diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h index 51ee56af43..8ed38c15ba 100644 --- a/src/core/lib/channel/handshaker.h +++ b/src/core/lib/channel/handshaker.h @@ -172,4 +172,4 @@ void grpc_handshake_manager_pending_list_shutdown_all( } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */ diff --git a/src/core/lib/channel/handshaker_factory.h b/src/core/lib/channel/handshaker_factory.h index 2a130de252..59008adf05 100644 --- a/src/core/lib/channel/handshaker_factory.h +++ b/src/core/lib/channel/handshaker_factory.h @@ -56,4 +56,4 @@ void grpc_handshaker_factory_destroy( } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */ diff --git a/src/core/lib/channel/handshaker_registry.h b/src/core/lib/channel/handshaker_registry.h index e96bf06b6a..ddd280bea8 100644 --- a/src/core/lib/channel/handshaker_registry.h +++ b/src/core/lib/channel/handshaker_registry.h @@ -53,4 +53,4 @@ void grpc_handshakers_add(grpc_exec_ctx* exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */ diff --git a/src/core/lib/compression/algorithm_metadata.h b/src/core/lib/compression/algorithm_metadata.h index 3eb7088230..17caf58f69 100644 --- a/src/core/lib/compression/algorithm_metadata.h +++ b/src/core/lib/compression/algorithm_metadata.h @@ -57,4 +57,4 @@ grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice( } #endif -#endif /* GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H */ diff --git a/src/core/lib/compression/message_compress.h b/src/core/lib/compression/message_compress.h index d2545a02c2..fffe175fd2 100644 --- a/src/core/lib/compression/message_compress.h +++ b/src/core/lib/compression/message_compress.h @@ -44,4 +44,4 @@ int grpc_msg_decompress(grpc_exec_ctx* exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */ diff --git a/src/core/lib/http/format_request.h b/src/core/lib/http/format_request.h index a559aac660..2e77e8661a 100644 --- a/src/core/lib/http/format_request.h +++ b/src/core/lib/http/format_request.h @@ -37,4 +37,4 @@ grpc_slice grpc_httpcli_format_connect_request( } #endif -#endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */ diff --git a/src/core/lib/http/httpcli.h b/src/core/lib/http/httpcli.h index 3e6bdc0e46..76b790fa8a 100644 --- a/src/core/lib/http/httpcli.h +++ b/src/core/lib/http/httpcli.h @@ -131,4 +131,4 @@ void grpc_httpcli_set_override(grpc_httpcli_get_override get, } #endif -#endif /* GRPC_CORE_LIB_HTTP_HTTPCLI_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_HTTP_HTTPCLI_H */ diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h index 5484948bea..d2bda6ae0e 100644 --- a/src/core/lib/http/parser.h +++ b/src/core/lib/http/parser.h @@ -117,4 +117,4 @@ extern grpc_tracer_flag grpc_http1_trace; } #endif -#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */ diff --git a/src/core/lib/iomgr/endpoint.h b/src/core/lib/iomgr/endpoint.h index 16ff0ab733..21347d9023 100644 --- a/src/core/lib/iomgr/endpoint.h +++ b/src/core/lib/iomgr/endpoint.h @@ -103,4 +103,4 @@ struct grpc_endpoint { } #endif -#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_H */ diff --git a/src/core/lib/iomgr/endpoint_pair.h b/src/core/lib/iomgr/endpoint_pair.h index f8830022f4..ee91795749 100644 --- a/src/core/lib/iomgr/endpoint_pair.h +++ b/src/core/lib/iomgr/endpoint_pair.h @@ -37,4 +37,4 @@ grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H */ diff --git a/src/core/lib/iomgr/error_internal.h b/src/core/lib/iomgr/error_internal.h index f718e06d4e..8746d5d353 100644 --- a/src/core/lib/iomgr/error_internal.h +++ b/src/core/lib/iomgr/error_internal.h @@ -65,4 +65,4 @@ bool grpc_error_is_special(grpc_error *err); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_ERROR_INTERNAL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_ERROR_INTERNAL_H */ diff --git a/src/core/lib/iomgr/ev_epoll1_linux.h b/src/core/lib/iomgr/ev_epoll1_linux.h index 66fd826b49..b437032b36 100644 --- a/src/core/lib/iomgr/ev_epoll1_linux.h +++ b/src/core/lib/iomgr/ev_epoll1_linux.h @@ -34,4 +34,4 @@ const grpc_event_engine_vtable *grpc_init_epoll1_linux(bool explicit_request); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL1_LINUX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLL1_LINUX_H */ diff --git a/src/core/lib/iomgr/ev_epollex_linux.h b/src/core/lib/iomgr/ev_epollex_linux.h index 58cc5a24f8..2849a23283 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.h +++ b/src/core/lib/iomgr/ev_epollex_linux.h @@ -33,4 +33,4 @@ const grpc_event_engine_vtable *grpc_init_epollex_linux( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EV_EPOLLEX_LINUX_H */ diff --git a/src/core/lib/iomgr/ev_poll_posix.h b/src/core/lib/iomgr/ev_poll_posix.h index 84b68155b5..861257204b 100644 --- a/src/core/lib/iomgr/ev_poll_posix.h +++ b/src/core/lib/iomgr/ev_poll_posix.h @@ -32,4 +32,4 @@ const grpc_event_engine_vtable *grpc_init_poll_cv_posix(bool explicit_request); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */ diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 955326c5f7..bc4456c2a2 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -166,4 +166,4 @@ const grpc_event_engine_vtable *grpc_get_event_engine_test_only(); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */ diff --git a/src/core/lib/iomgr/executor.h b/src/core/lib/iomgr/executor.h index ab3fc901de..ef5ac56c83 100644 --- a/src/core/lib/iomgr/executor.h +++ b/src/core/lib/iomgr/executor.h @@ -53,4 +53,4 @@ void grpc_executor_set_threading(grpc_exec_ctx *exec_ctx, bool enable); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */ diff --git a/src/core/lib/iomgr/iocp_windows.h b/src/core/lib/iomgr/iocp_windows.h index aefe7a294a..4efbc94645 100644 --- a/src/core/lib/iomgr/iocp_windows.h +++ b/src/core/lib/iomgr/iocp_windows.h @@ -45,4 +45,4 @@ void grpc_iocp_add_socket(grpc_winsocket *); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */ diff --git a/src/core/lib/iomgr/iomgr.h b/src/core/lib/iomgr/iomgr.h index fea08496fe..6c0a08b918 100644 --- a/src/core/lib/iomgr/iomgr.h +++ b/src/core/lib/iomgr/iomgr.h @@ -40,4 +40,4 @@ void grpc_iomgr_shutdown(grpc_exec_ctx *exec_ctx); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_H */ diff --git a/src/core/lib/iomgr/iomgr_internal.h b/src/core/lib/iomgr/iomgr_internal.h index 005abbed13..52db37c89a 100644 --- a/src/core/lib/iomgr/iomgr_internal.h +++ b/src/core/lib/iomgr/iomgr_internal.h @@ -48,4 +48,4 @@ bool grpc_iomgr_abort_on_leaks(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H */ diff --git a/src/core/lib/iomgr/is_epollexclusive_available.h b/src/core/lib/iomgr/is_epollexclusive_available.h index 5c3e483065..9ae9c5c191 100644 --- a/src/core/lib/iomgr/is_epollexclusive_available.h +++ b/src/core/lib/iomgr/is_epollexclusive_available.h @@ -31,4 +31,4 @@ bool grpc_is_epollexclusive_available(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_IS_EPOLLEXCLUSIVE_AVAILABLE_H */ diff --git a/src/core/lib/iomgr/lockfree_event.h b/src/core/lib/iomgr/lockfree_event.h index 925f004945..02229e569e 100644 --- a/src/core/lib/iomgr/lockfree_event.h +++ b/src/core/lib/iomgr/lockfree_event.h @@ -45,4 +45,4 @@ void grpc_lfev_set_ready(grpc_exec_ctx *exec_ctx, gpr_atm *state, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_LOCKFREE_EVENT_H */ diff --git a/src/core/lib/iomgr/network_status_tracker.h b/src/core/lib/iomgr/network_status_tracker.h index af50d51257..cba38d4530 100644 --- a/src/core/lib/iomgr/network_status_tracker.h +++ b/src/core/lib/iomgr/network_status_tracker.h @@ -35,4 +35,4 @@ void grpc_network_status_shutdown_all_endpoints(); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_NETWORK_STATUS_TRACKER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_NETWORK_STATUS_TRACKER_H */ diff --git a/src/core/lib/iomgr/polling_entity.h b/src/core/lib/iomgr/polling_entity.h index 4a37acf212..009f968fac 100644 --- a/src/core/lib/iomgr/polling_entity.h +++ b/src/core/lib/iomgr/polling_entity.h @@ -72,4 +72,4 @@ void grpc_polling_entity_del_from_pollset_set(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */ diff --git a/src/core/lib/iomgr/pollset_set.h b/src/core/lib/iomgr/pollset_set.h index 17df86542d..5455eda02f 100644 --- a/src/core/lib/iomgr/pollset_set.h +++ b/src/core/lib/iomgr/pollset_set.h @@ -52,4 +52,4 @@ void grpc_pollset_set_del_pollset_set(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_H */ diff --git a/src/core/lib/iomgr/pollset_uv.h b/src/core/lib/iomgr/pollset_uv.h index d8f72ff867..5cc9faf4ff 100644 --- a/src/core/lib/iomgr/pollset_uv.h +++ b/src/core/lib/iomgr/pollset_uv.h @@ -32,4 +32,4 @@ void grpc_pollset_global_shutdown(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_UV_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_UV_H */ diff --git a/src/core/lib/iomgr/pollset_windows.h b/src/core/lib/iomgr/pollset_windows.h index 7733d26471..2479b25286 100644 --- a/src/core/lib/iomgr/pollset_windows.h +++ b/src/core/lib/iomgr/pollset_windows.h @@ -68,4 +68,4 @@ void grpc_pollset_global_shutdown(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ diff --git a/src/core/lib/iomgr/resolve_address.h b/src/core/lib/iomgr/resolve_address.h index 4a6df2cf26..5f0634299e 100644 --- a/src/core/lib/iomgr/resolve_address.h +++ b/src/core/lib/iomgr/resolve_address.h @@ -60,4 +60,4 @@ extern grpc_error *(*grpc_blocking_resolve_address)( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */ diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h index 3afb525434..1d4249b7e2 100644 --- a/src/core/lib/iomgr/resource_quota.h +++ b/src/core/lib/iomgr/resource_quota.h @@ -158,4 +158,4 @@ grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */ diff --git a/src/core/lib/iomgr/sockaddr_utils.h b/src/core/lib/iomgr/sockaddr_utils.h index 129bb54fc9..1fd552febb 100644 --- a/src/core/lib/iomgr/sockaddr_utils.h +++ b/src/core/lib/iomgr/sockaddr_utils.h @@ -85,4 +85,4 @@ int grpc_sockaddr_get_family(const grpc_resolved_address *resolved_addr); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */ diff --git a/src/core/lib/iomgr/socket_utils.h b/src/core/lib/iomgr/socket_utils.h index f319e931b6..d6c538ec6f 100644 --- a/src/core/lib/iomgr/socket_utils.h +++ b/src/core/lib/iomgr/socket_utils.h @@ -32,4 +32,4 @@ const char *grpc_inet_ntop(int af, const void *src, char *dst, size_t size); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */ diff --git a/src/core/lib/iomgr/socket_utils_posix.h b/src/core/lib/iomgr/socket_utils_posix.h index 623b83f08b..73809b68d3 100644 --- a/src/core/lib/iomgr/socket_utils_posix.h +++ b/src/core/lib/iomgr/socket_utils_posix.h @@ -137,4 +137,4 @@ grpc_error *grpc_create_dualstack_socket_using_factory( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */ diff --git a/src/core/lib/iomgr/socket_windows.h b/src/core/lib/iomgr/socket_windows.h index a00a7615a3..84fa071e89 100644 --- a/src/core/lib/iomgr/socket_windows.h +++ b/src/core/lib/iomgr/socket_windows.h @@ -115,4 +115,4 @@ void grpc_socket_become_ready(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */ diff --git a/src/core/lib/iomgr/tcp_client.h b/src/core/lib/iomgr/tcp_client.h index 1b102b5784..b2f365f2af 100644 --- a/src/core/lib/iomgr/tcp_client.h +++ b/src/core/lib/iomgr/tcp_client.h @@ -45,4 +45,4 @@ void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_connect, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */ diff --git a/src/core/lib/iomgr/tcp_client_posix.h b/src/core/lib/iomgr/tcp_client_posix.h index 0b9775504c..8740511804 100644 --- a/src/core/lib/iomgr/tcp_client_posix.h +++ b/src/core/lib/iomgr/tcp_client_posix.h @@ -35,4 +35,4 @@ grpc_endpoint *grpc_tcp_client_create_from_fd( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */ diff --git a/src/core/lib/iomgr/tcp_posix.h b/src/core/lib/iomgr/tcp_posix.h index dda78b2f8e..47e78fa67e 100644 --- a/src/core/lib/iomgr/tcp_posix.h +++ b/src/core/lib/iomgr/tcp_posix.h @@ -61,4 +61,4 @@ void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_POSIX_H */ diff --git a/src/core/lib/iomgr/tcp_server.h b/src/core/lib/iomgr/tcp_server.h index 3f190ac285..8f9ce3819e 100644 --- a/src/core/lib/iomgr/tcp_server.h +++ b/src/core/lib/iomgr/tcp_server.h @@ -106,4 +106,4 @@ void grpc_tcp_server_shutdown_listeners(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_H */ diff --git a/src/core/lib/iomgr/tcp_server_utils_posix.h b/src/core/lib/iomgr/tcp_server_utils_posix.h index 4bb0660f09..6746333960 100644 --- a/src/core/lib/iomgr/tcp_server_utils_posix.h +++ b/src/core/lib/iomgr/tcp_server_utils_posix.h @@ -125,4 +125,4 @@ bool grpc_tcp_server_have_ifaddrs(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_UTILS_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_UTILS_POSIX_H */ diff --git a/src/core/lib/iomgr/tcp_uv.h b/src/core/lib/iomgr/tcp_uv.h index ba7db8a0f7..3399535b42 100644 --- a/src/core/lib/iomgr/tcp_uv.h +++ b/src/core/lib/iomgr/tcp_uv.h @@ -50,4 +50,4 @@ grpc_endpoint *grpc_tcp_create(uv_tcp_t *handle, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TCP_UV_H */ diff --git a/src/core/lib/iomgr/time_averaged_stats.h b/src/core/lib/iomgr/time_averaged_stats.h index e255b58fee..d38ed272b6 100644 --- a/src/core/lib/iomgr/time_averaged_stats.h +++ b/src/core/lib/iomgr/time_averaged_stats.h @@ -78,4 +78,4 @@ double grpc_time_averaged_stats_update_average(grpc_time_averaged_stats* stats); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H */ diff --git a/src/core/lib/iomgr/timer_heap.h b/src/core/lib/iomgr/timer_heap.h index f15e8a3abb..228d038ab3 100644 --- a/src/core/lib/iomgr/timer_heap.h +++ b/src/core/lib/iomgr/timer_heap.h @@ -47,4 +47,4 @@ int grpc_timer_heap_is_empty(grpc_timer_heap *heap); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */ diff --git a/src/core/lib/iomgr/timer_manager.h b/src/core/lib/iomgr/timer_manager.h index d8a59a9477..72960d6ffc 100644 --- a/src/core/lib/iomgr/timer_manager.h +++ b/src/core/lib/iomgr/timer_manager.h @@ -42,4 +42,4 @@ void grpc_timer_manager_tick(void); } #endif -#endif /* GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_TIMER_MANAGER_H */ diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h index bcd8572260..e887cb1bcf 100644 --- a/src/core/lib/iomgr/udp_server.h +++ b/src/core/lib/iomgr/udp_server.h @@ -81,4 +81,4 @@ void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server, } #endif -#endif /* GRPC_CORE_LIB_IOMGR_UDP_SERVER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_UDP_SERVER_H */ diff --git a/src/core/lib/iomgr/unix_sockets_posix.h b/src/core/lib/iomgr/unix_sockets_posix.h index b96131ae1c..3e7f9c7d1e 100644 --- a/src/core/lib/iomgr/unix_sockets_posix.h +++ b/src/core/lib/iomgr/unix_sockets_posix.h @@ -46,4 +46,4 @@ char *grpc_sockaddr_to_uri_unix_if_possible( } #endif -#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */ diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index 81b7e0c9da..c9fdec4ecb 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -78,4 +78,4 @@ void grpc_json_destroy(grpc_json* json); } #endif -#endif /* GRPC_CORE_LIB_JSON_JSON_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_JSON_JSON_H */ diff --git a/src/core/lib/json/json_reader.h b/src/core/lib/json/json_reader.h index ab2384f7a7..7f14a9a9c8 100644 --- a/src/core/lib/json/json_reader.h +++ b/src/core/lib/json/json_reader.h @@ -150,4 +150,4 @@ int grpc_json_reader_is_complete(grpc_json_reader *reader); } #endif -#endif /* GRPC_CORE_LIB_JSON_JSON_READER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_JSON_JSON_READER_H */ diff --git a/src/core/lib/json/json_writer.h b/src/core/lib/json/json_writer.h index 18bd2a80fe..132d1f24e8 100644 --- a/src/core/lib/json/json_writer.h +++ b/src/core/lib/json/json_writer.h @@ -87,4 +87,4 @@ void grpc_json_writer_value_string(grpc_json_writer *writer, } #endif -#endif /* GRPC_CORE_LIB_JSON_JSON_WRITER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_JSON_JSON_WRITER_H */ diff --git a/src/core/lib/security/credentials/fake/fake_credentials.h b/src/core/lib/security/credentials/fake/fake_credentials.h index 64f6f439f0..ed3f893c58 100644 --- a/src/core/lib/security/credentials/fake/fake_credentials.h +++ b/src/core/lib/security/credentials/fake/fake_credentials.h @@ -64,4 +64,4 @@ typedef struct { } #endif -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */ diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.h b/src/core/lib/security/credentials/jwt/jwt_credentials.h index c09485fd55..5cee6ed0da 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.h +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.h @@ -53,4 +53,4 @@ grpc_service_account_jwt_access_credentials_create_from_auth_json_key( } #endif -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */ diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 4beaec93e3..c12db896f3 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -110,4 +110,4 @@ grpc_oauth2_token_fetcher_credentials_parse_server_response( } #endif -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ diff --git a/src/core/lib/security/transport/lb_targets_info.h b/src/core/lib/security/transport/lb_targets_info.h index 705d33b0ab..43f0e64556 100644 --- a/src/core/lib/security/transport/lb_targets_info.h +++ b/src/core/lib/security/transport/lb_targets_info.h @@ -37,4 +37,4 @@ grpc_slice_hash_table *grpc_lb_targets_info_find_in_args( } #endif -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_LB_TARGETS_INFO_H */ diff --git a/src/core/lib/security/transport/secure_endpoint.h b/src/core/lib/security/transport/secure_endpoint.h index 832cc1c0ce..980449c03e 100644 --- a/src/core/lib/security/transport/secure_endpoint.h +++ b/src/core/lib/security/transport/secure_endpoint.h @@ -44,4 +44,4 @@ grpc_endpoint *grpc_secure_endpoint_create( } #endif -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */ diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h index 345065f26c..178099bb94 100644 --- a/src/core/lib/security/transport/security_handshaker.h +++ b/src/core/lib/security/transport/security_handshaker.h @@ -39,4 +39,4 @@ void grpc_security_register_handshaker_factories(); } #endif -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */ diff --git a/src/core/lib/security/transport/tsi_error.h b/src/core/lib/security/transport/tsi_error.h index 4c78b06603..4e19daf796 100644 --- a/src/core/lib/security/transport/tsi_error.h +++ b/src/core/lib/security/transport/tsi_error.h @@ -32,4 +32,4 @@ grpc_error *grpc_set_tsi_error_result(grpc_error *error, tsi_result result); } #endif -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H */ diff --git a/src/core/lib/security/util/json_util.h b/src/core/lib/security/util/json_util.h index 43a2f6b9d1..cdd8a7198a 100644 --- a/src/core/lib/security/util/json_util.h +++ b/src/core/lib/security/util/json_util.h @@ -45,4 +45,4 @@ bool grpc_copy_json_string_property(const grpc_json *json, } #endif -#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */ diff --git a/src/core/lib/slice/b64.h b/src/core/lib/slice/b64.h index c01da56575..9b4dc65dbb 100644 --- a/src/core/lib/slice/b64.h +++ b/src/core/lib/slice/b64.h @@ -55,4 +55,4 @@ grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, const char *b64, } #endif -#endif /* GRPC_CORE_LIB_SLICE_B64_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_B64_H */ diff --git a/src/core/lib/slice/percent_encoding.h b/src/core/lib/slice/percent_encoding.h index e6f85120c3..14a4deb44b 100644 --- a/src/core/lib/slice/percent_encoding.h +++ b/src/core/lib/slice/percent_encoding.h @@ -68,4 +68,4 @@ grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in); } #endif -#endif /* GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H */ diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h index 3c3f0e61f3..41250df738 100644 --- a/src/core/lib/slice/slice_hash_table.h +++ b/src/core/lib/slice/slice_hash_table.h @@ -75,4 +75,4 @@ int grpc_slice_hash_table_cmp(const grpc_slice_hash_table *a, } #endif -#endif /* GRPC_CORE_LIB_SLICE_SLICE_HASH_TABLE_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_SLICE_HASH_TABLE_H */ diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 8591185c53..fcf70a0e55 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -54,4 +54,4 @@ int grpc_static_slice_eq(grpc_slice a, grpc_slice b); } #endif -#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */ diff --git a/src/core/lib/slice/slice_traits.h b/src/core/lib/slice/slice_traits.h index 1eda17cf00..7fdb6752cb 100644 --- a/src/core/lib/slice/slice_traits.h +++ b/src/core/lib/slice/slice_traits.h @@ -34,4 +34,4 @@ bool grpc_slice_is_bin_suffixed(grpc_slice s); } #endif -#endif /* GRPC_CORE_LIB_SLICE_SLICE_TRAITS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SLICE_SLICE_TRAITS_H */ diff --git a/src/core/lib/surface/channel_stack_type.h b/src/core/lib/surface/channel_stack_type.h index 903b90a071..c77848794c 100644 --- a/src/core/lib/surface/channel_stack_type.h +++ b/src/core/lib/surface/channel_stack_type.h @@ -50,4 +50,4 @@ const char *grpc_channel_stack_type_string(grpc_channel_stack_type type); } #endif -#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */ diff --git a/src/core/lib/surface/completion_queue_factory.h b/src/core/lib/surface/completion_queue_factory.h index cb0af6f0fb..af8f3d60c3 100644 --- a/src/core/lib/surface/completion_queue_factory.h +++ b/src/core/lib/surface/completion_queue_factory.h @@ -41,4 +41,4 @@ struct grpc_completion_queue_factory { } #endif -#endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_FACTORY_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_FACTORY_H */ diff --git a/src/core/lib/surface/event_string.h b/src/core/lib/surface/event_string.h index 127609c404..2d53cf0fac 100644 --- a/src/core/lib/surface/event_string.h +++ b/src/core/lib/surface/event_string.h @@ -32,4 +32,4 @@ char *grpc_event_string(grpc_event *ev); } #endif -#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */ diff --git a/src/core/lib/surface/init.h b/src/core/lib/surface/init.h index b2f48576e5..d429026327 100644 --- a/src/core/lib/surface/init.h +++ b/src/core/lib/surface/init.h @@ -32,4 +32,4 @@ int grpc_is_initialized(void); } #endif -#endif /* GRPC_CORE_LIB_SURFACE_INIT_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_INIT_H */ diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 1114715833..375eab4a04 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -62,4 +62,4 @@ void grpc_server_get_pollsets(grpc_server *server, grpc_pollset ***pollsets, } #endif -#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */ diff --git a/src/core/lib/surface/validate_metadata.h b/src/core/lib/surface/validate_metadata.h index aa02419d9f..afc8be6dfd 100644 --- a/src/core/lib/surface/validate_metadata.h +++ b/src/core/lib/surface/validate_metadata.h @@ -33,4 +33,4 @@ grpc_error *grpc_validate_header_nonbin_value_is_legal(grpc_slice slice); } #endif -#endif /* GRPC_CORE_LIB_SURFACE_VALIDATE_METADATA_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_SURFACE_VALIDATE_METADATA_H */ diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 480d5237b8..a9d986782c 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -82,4 +82,4 @@ void grpc_bdp_estimator_complete_ping(grpc_exec_ctx *exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H */ diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index d3e04df5c0..c1d8ee543f 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -143,4 +143,4 @@ void grpc_caching_byte_stream_reset(grpc_caching_byte_stream *stream); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index 1796a540a7..c0ba188148 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -92,4 +92,4 @@ bool grpc_connectivity_state_notify_on_state_change( } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */ diff --git a/src/core/lib/transport/error_utils.h b/src/core/lib/transport/error_utils.h index 2c97f9f0bc..b4f9df4bf1 100644 --- a/src/core/lib/transport/error_utils.h +++ b/src/core/lib/transport/error_utils.h @@ -48,4 +48,4 @@ bool grpc_error_has_clear_grpc_status(grpc_error *error); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_ERROR_UTILS_H */ diff --git a/src/core/lib/transport/pid_controller.h b/src/core/lib/transport/pid_controller.h index 17feabfd39..80899e9a20 100644 --- a/src/core/lib/transport/pid_controller.h +++ b/src/core/lib/transport/pid_controller.h @@ -67,4 +67,4 @@ double grpc_pid_controller_last(grpc_pid_controller *pid_controller); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H */ diff --git a/src/core/lib/transport/service_config.h b/src/core/lib/transport/service_config.h index c485f52472..9c43093627 100644 --- a/src/core/lib/transport/service_config.h +++ b/src/core/lib/transport/service_config.h @@ -67,4 +67,4 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx, } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */ diff --git a/src/core/lib/transport/status_conversion.h b/src/core/lib/transport/status_conversion.h index fd58a82cb7..8ef91aecfe 100644 --- a/src/core/lib/transport/status_conversion.h +++ b/src/core/lib/transport/status_conversion.h @@ -41,4 +41,4 @@ int grpc_status_to_http2_status(grpc_status_code status); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_STATUS_CONVERSION_H */ diff --git a/src/core/lib/transport/timeout_encoding.h b/src/core/lib/transport/timeout_encoding.h index 25cb663959..91cdf0f728 100644 --- a/src/core/lib/transport/timeout_encoding.h +++ b/src/core/lib/transport/timeout_encoding.h @@ -40,4 +40,4 @@ int grpc_http2_decode_timeout(grpc_slice text, grpc_millis *timeout); } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ diff --git a/src/core/lib/transport/transport_impl.h b/src/core/lib/transport/transport_impl.h index 41d34d3954..445fb41ab1 100644 --- a/src/core/lib/transport/transport_impl.h +++ b/src/core/lib/transport/transport_impl.h @@ -77,4 +77,4 @@ struct grpc_transport { } #endif -#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ \ No newline at end of file +#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ diff --git a/src/core/tsi/gts_transport_security.h b/src/core/tsi/gts_transport_security.h index b988c3f861..9590038ed0 100644 --- a/src/core/tsi/gts_transport_security.h +++ b/src/core/tsi/gts_transport_security.h @@ -42,4 +42,4 @@ gts_shared_resource *gts_get_shared_resource(void); } #endif -#endif /* GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H */ \ No newline at end of file +#endif /* GRPC_CORE_TSI_GTS_TRANSPORT_SECURITY_H */ -- cgit v1.2.3