[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36466)

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT
Replacing GPR_ASSERT with absl CHECK.
These changes have been made using string replacement and regex.
Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced.
Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36466

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36466 from tanvi-jagtap:tjagtap_src_core_lob_event_engine d101d5f701
PiperOrigin-RevId: 629105415
pull/36446/head^2
Tanvi Jagtap 7 months ago committed by Copybara-Service
parent 60dc14e833
commit f68f8e8fa3
  1. 14
      CMakeLists.txt
  2. 1
      Makefile
  3. 10
      build_autogenerated.yaml
  4. 1
      config.m4
  5. 1
      config.w32
  6. 1
      gRPC-Core.podspec
  7. 4
      grpc.gemspec
  8. 4
      package.xml
  9. 30
      src/core/BUILD
  10. 33
      src/core/lib/event_engine/ares_resolver.cc
  11. 4
      src/core/lib/event_engine/cf_engine/cf_engine.cc
  12. 3
      src/core/lib/event_engine/cf_engine/dns_service_resolver.cc
  13. 3
      src/core/lib/event_engine/cf_engine/dns_service_resolver.h
  14. 10
      src/core/lib/event_engine/forkable.cc
  15. 13
      src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc
  16. 19
      src/core/lib/event_engine/posix_engine/ev_poll_posix.cc
  17. 3
      src/core/lib/event_engine/posix_engine/lockfree_event.cc
  18. 46
      src/core/lib/event_engine/posix_engine/posix_endpoint.cc
  19. 22
      src/core/lib/event_engine/posix_engine/posix_endpoint.h
  20. 17
      src/core/lib/event_engine/posix_engine/posix_engine.cc
  21. 5
      src/core/lib/event_engine/posix_engine/posix_engine_listener.cc
  22. 9
      src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc
  23. 3
      src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc
  24. 3
      src/core/lib/event_engine/posix_engine/tcp_socket_utils.h
  25. 7
      src/core/lib/event_engine/posix_engine/timer_manager.cc
  26. 6
      src/core/lib/event_engine/resolved_address.cc
  27. 4
      src/core/lib/event_engine/slice.cc
  28. 17
      src/core/lib/event_engine/tcp_socket_utils.cc
  29. 13
      src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc
  30. 61
      src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc
  31. 18
      src/core/lib/event_engine/windows/iocp.cc
  32. 12
      src/core/lib/event_engine/windows/win_socket.cc
  33. 17
      src/core/lib/event_engine/windows/windows_endpoint.cc
  34. 13
      src/core/lib/event_engine/windows/windows_engine.cc
  35. 13
      src/core/lib/event_engine/windows/windows_listener.cc
  36. 1
      src/python/grpcio/grpc_core_dependencies.py

14
CMakeLists.txt generated

@ -2677,6 +2677,7 @@ target_link_libraries(grpc
absl::bind_front
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::random_bit_gen_ref
absl::random_distributions
@ -2844,7 +2845,6 @@ target_link_libraries(grpc_test_util
absl::failure_signal_handler
absl::stacktrace
absl::symbolize
absl::check
grpc
)
if(_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC)
@ -2910,7 +2910,6 @@ target_link_libraries(grpc_test_util_unsecure
absl::failure_signal_handler
absl::stacktrace
absl::symbolize
absl::check
grpc_unsecure
)
if(_gRPC_PLATFORM_IOS OR _gRPC_PLATFORM_MAC)
@ -3381,6 +3380,7 @@ target_link_libraries(grpc_unsecure
absl::bind_front
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::random_bit_gen_ref
absl::random_distributions
@ -4149,7 +4149,6 @@ target_include_directories(grpc++
)
target_link_libraries(grpc++
${_gRPC_ALLTARGETS_LIBRARIES}
absl::check
grpc
${_gRPC_PROTOBUF_LIBRARIES}
)
@ -4891,7 +4890,6 @@ target_include_directories(grpc++_unsecure
)
target_link_libraries(grpc++_unsecure
${_gRPC_ALLTARGETS_LIBRARIES}
absl::check
grpc_unsecure
${_gRPC_PROTOBUF_LIBRARIES}
)
@ -5447,6 +5445,7 @@ target_link_libraries(grpc_authorization_provider
absl::inlined_vector
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
absl::span
@ -14430,6 +14429,7 @@ target_include_directories(forkable_test
target_link_libraries(forkable_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
absl::statusor
gpr
)
@ -18004,6 +18004,7 @@ target_link_libraries(interception_chain_test
absl::inlined_vector
absl::function_ref
absl::hash
absl::check
absl::type_traits
absl::statusor
absl::span
@ -29696,7 +29697,6 @@ target_include_directories(tcp_socket_utils_test
target_link_libraries(tcp_socket_utils_test
${_gRPC_ALLTARGETS_LIBRARIES}
gtest
absl::check
grpc
)
@ -36940,7 +36940,7 @@ generate_pkgconfig(
"gRPC"
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"libcares openssl re2 zlib"
"-lgrpc"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"
@ -36951,7 +36951,7 @@ generate_pkgconfig(
"gRPC unsecure"
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"absl_algorithm_container absl_any_invocable absl_base absl_bind_front absl_check absl_cleanup absl_config absl_cord absl_core_headers absl_flags absl_flags_marshalling absl_flat_hash_map absl_flat_hash_set absl_function_ref absl_hash absl_inlined_vector absl_log absl_log_severity absl_memory absl_no_destructor absl_optional absl_random_bit_gen_ref absl_random_distributions absl_random_random absl_span absl_status absl_statusor absl_str_format absl_strings absl_synchronization absl_time absl_type_traits absl_utility absl_variant gpr"
"libcares zlib"
"-lgrpc_unsecure"
"-laddress_sorting -lupb_message_lib -lupb_mem_lib -lupb_base_lib -lutf8_range_lib"

1
Makefile generated

@ -1550,6 +1550,7 @@ LIBGRPC_SRC = \
third_party/abseil-cpp/absl/hash/internal/hash.cc \
third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc \
third_party/abseil-cpp/absl/log/globals.cc \
third_party/abseil-cpp/absl/log/internal/check_op.cc \
third_party/abseil-cpp/absl/log/internal/conditions.cc \
third_party/abseil-cpp/absl/log/internal/fnmatch.cc \
third_party/abseil-cpp/absl/log/internal/globals.cc \

@ -2057,6 +2057,7 @@ libs:
- absl/functional:bind_front
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/random:bit_gen_ref
- absl/random:distributions
@ -2098,7 +2099,6 @@ libs:
- absl/debugging:failure_signal_handler
- absl/debugging:stacktrace
- absl/debugging:symbolize
- absl/log:check
- grpc
- name: grpc_test_util_unsecure
build: private
@ -2127,7 +2127,6 @@ libs:
- absl/debugging:failure_signal_handler
- absl/debugging:stacktrace
- absl/debugging:symbolize
- absl/log:check
- grpc_unsecure
- name: grpc_unsecure
build: all
@ -3119,6 +3118,7 @@ libs:
- absl/functional:bind_front
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/random:bit_gen_ref
- absl/random:distributions
@ -3937,7 +3937,6 @@ libs:
- src/cpp/util/string_ref.cc
- src/cpp/util/time_cc.cc
deps:
- absl/log:check
- grpc
- protobuf
baselib: true
@ -4311,7 +4310,6 @@ libs:
- src/cpp/util/string_ref.cc
- src/cpp/util/time_cc.cc
deps:
- absl/log:check
- grpc_unsecure
- protobuf
baselib: true
@ -5034,6 +5032,7 @@ libs:
- absl/container:inlined_vector
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- absl/types:span
@ -10070,6 +10069,7 @@ targets:
- test/core/event_engine/forkable_test.cc
deps:
- gtest
- absl/log:check
- absl/status:statusor
- gpr
- name: format_request_test
@ -12160,6 +12160,7 @@ targets:
- absl/container:inlined_vector
- absl/functional:function_ref
- absl/hash:hash
- absl/log:check
- absl/meta:type_traits
- absl/status:statusor
- absl/types:span
@ -19232,7 +19233,6 @@ targets:
- test/core/event_engine/tcp_socket_utils_test.cc
deps:
- gtest
- absl/log:check
- grpc
uses_polling: false
- name: test_core_channelz_channelz_test

1
config.m4 generated

@ -935,6 +935,7 @@ if test "$PHP_GRPC" != "no"; then
third_party/abseil-cpp/absl/hash/internal/hash.cc \
third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc \
third_party/abseil-cpp/absl/log/globals.cc \
third_party/abseil-cpp/absl/log/internal/check_op.cc \
third_party/abseil-cpp/absl/log/internal/conditions.cc \
third_party/abseil-cpp/absl/log/internal/fnmatch.cc \
third_party/abseil-cpp/absl/log/internal/globals.cc \

1
config.w32 generated

@ -900,6 +900,7 @@ if (PHP_GRPC != "no") {
"third_party\\abseil-cpp\\absl\\hash\\internal\\hash.cc " +
"third_party\\abseil-cpp\\absl\\hash\\internal\\low_level_hash.cc " +
"third_party\\abseil-cpp\\absl\\log\\globals.cc " +
"third_party\\abseil-cpp\\absl\\log\\internal\\check_op.cc " +
"third_party\\abseil-cpp\\absl\\log\\internal\\conditions.cc " +
"third_party\\abseil-cpp\\absl\\log\\internal\\fnmatch.cc " +
"third_party\\abseil-cpp\\absl\\log\\internal\\globals.cc " +

1
gRPC-Core.podspec generated

@ -214,6 +214,7 @@ Pod::Spec.new do |s|
ss.dependency 'abseil/functional/bind_front', abseil_version
ss.dependency 'abseil/functional/function_ref', abseil_version
ss.dependency 'abseil/hash/hash', abseil_version
ss.dependency 'abseil/log/check', abseil_version
ss.dependency 'abseil/log/log', abseil_version
ss.dependency 'abseil/memory/memory', abseil_version
ss.dependency 'abseil/meta/type_traits', abseil_version

4
grpc.gemspec generated

@ -2178,9 +2178,13 @@ Gem::Specification.new do |s|
s.files += %w( third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc )
s.files += %w( third_party/abseil-cpp/absl/hash/internal/low_level_hash.h )
s.files += %w( third_party/abseil-cpp/absl/log/absl_vlog_is_on.h )
s.files += %w( third_party/abseil-cpp/absl/log/check.h )
s.files += %w( third_party/abseil-cpp/absl/log/globals.cc )
s.files += %w( third_party/abseil-cpp/absl/log/globals.h )
s.files += %w( third_party/abseil-cpp/absl/log/internal/append_truncated.h )
s.files += %w( third_party/abseil-cpp/absl/log/internal/check_impl.h )
s.files += %w( third_party/abseil-cpp/absl/log/internal/check_op.cc )
s.files += %w( third_party/abseil-cpp/absl/log/internal/check_op.h )
s.files += %w( third_party/abseil-cpp/absl/log/internal/conditions.cc )
s.files += %w( third_party/abseil-cpp/absl/log/internal/conditions.h )
s.files += %w( third_party/abseil-cpp/absl/log/internal/config.h )

4
package.xml generated

@ -2182,9 +2182,13 @@
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/hash/internal/low_level_hash.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/absl_vlog_is_on.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/check.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/globals.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/globals.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/internal/append_truncated.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/internal/check_impl.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/internal/check_op.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/internal/check_op.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/internal/conditions.cc" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/internal/conditions.h" role="src" />
<file baseinstalldir="/" name="third_party/abseil-cpp/absl/log/internal/config.h" role="src" />

@ -92,6 +92,7 @@ grpc_cc_library(
external_deps = [
"absl/container:flat_hash_set",
"absl/hash",
"absl/log:check",
"absl/strings",
"absl/utility",
],
@ -1683,6 +1684,9 @@ grpc_cc_library(
hdrs = [
"lib/event_engine/forkable.h",
],
external_deps = [
"absl/log:check",
],
deps = [
"//:config_vars",
"//:gpr",
@ -1830,6 +1834,7 @@ grpc_cc_library(
"absl/base:core_headers",
"absl/container:flat_hash_set",
"absl/functional:any_invocable",
"absl/log:check",
"absl/time",
"absl/types:optional",
],
@ -1879,6 +1884,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/time",
"absl/types:optional",
],
@ -1938,7 +1944,10 @@ grpc_cc_library(
hdrs = [
"lib/event_engine/posix_engine/lockfree_event.h",
],
external_deps = ["absl/status"],
external_deps = [
"absl/log:check",
"absl/status",
],
deps = [
"gpr_atm",
"posix_event_engine_closure",
@ -2032,6 +2041,7 @@ grpc_cc_library(
"absl/base:core_headers",
"absl/container:inlined_vector",
"absl/functional:function_ref",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2068,6 +2078,7 @@ grpc_cc_library(
"absl/container:inlined_vector",
"absl/functional:any_invocable",
"absl/functional:function_ref",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2160,6 +2171,7 @@ grpc_cc_library(
"absl/container:flat_hash_map",
"absl/functional:any_invocable",
"absl/hash",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2199,7 +2211,10 @@ grpc_cc_library(
name = "event_engine_utils",
srcs = ["lib/event_engine/utils.cc"],
hdrs = ["lib/event_engine/utils.h"],
external_deps = ["absl/strings"],
external_deps = [
"absl/log:check",
"absl/strings",
],
deps = [
"time",
"//:event_engine_base_hdrs",
@ -2217,6 +2232,7 @@ grpc_cc_library(
],
external_deps = [
"absl/cleanup",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2248,6 +2264,7 @@ grpc_cc_library(
],
external_deps = [
"absl/cleanup",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2274,6 +2291,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/functional:any_invocable",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2309,6 +2327,7 @@ grpc_cc_library(
"absl/container:flat_hash_map",
"absl/functional:any_invocable",
"absl/hash",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2350,6 +2369,7 @@ grpc_cc_library(
srcs = ["lib/event_engine/windows/windows_engine.cc"],
hdrs = ["lib/event_engine/windows/windows_engine.h"],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2403,6 +2423,7 @@ grpc_cc_library(
external_deps = [
"absl/base:core_headers",
"absl/functional:any_invocable",
"absl/log:check",
"absl/status",
"absl/strings:str_format",
],
@ -2431,6 +2452,7 @@ grpc_cc_library(
external_deps = [
"absl/cleanup",
"absl/functional:any_invocable",
"absl/log:check",
"absl/status",
"absl/strings:str_format",
],
@ -2458,6 +2480,7 @@ grpc_cc_library(
],
external_deps = [
"absl/base:core_headers",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings:str_format",
@ -2491,6 +2514,7 @@ grpc_cc_library(
],
external_deps = [
"absl/container:flat_hash_map",
"absl/log:check",
"absl/strings",
"absl/strings:str_format",
],
@ -2524,6 +2548,7 @@ grpc_cc_library(
"lib/event_engine/tcp_socket_utils.h",
],
external_deps = [
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",
@ -2738,6 +2763,7 @@ grpc_cc_library(
"absl/container:flat_hash_map",
"absl/functional:any_invocable",
"absl/hash",
"absl/log:check",
"absl/status",
"absl/status:statusor",
"absl/strings",

@ -52,6 +52,7 @@
#include "absl/functional/any_invocable.h"
#include "absl/hash/hash.h"
#include "absl/log/check.h"
#include "absl/strings/match.h"
#include "absl/strings/numbers.h"
#include "absl/strings/str_cat.h"
@ -229,8 +230,8 @@ AresResolver::AresResolver(
}
AresResolver::~AresResolver() {
GPR_ASSERT(fd_node_list_.empty());
GPR_ASSERT(callback_map_.empty());
CHECK(fd_node_list_.empty());
CHECK(callback_map_.empty());
ares_destroy(channel_);
}
@ -246,7 +247,7 @@ void AresResolver::Orphan() {
if (!fd_node->already_shutdown) {
GRPC_ARES_RESOLVER_TRACE_LOG("resolver: %p shutdown fd: %s", this,
fd_node->polled_fd->GetName());
GPR_ASSERT(fd_node->polled_fd->ShutdownLocked(
CHECK(fd_node->polled_fd->ShutdownLocked(
absl::CancelledError("AresResolver::Orphan")));
fd_node->already_shutdown = true;
}
@ -513,7 +514,7 @@ void AresResolver::MaybeStartTimerLocked() {
void AresResolver::OnReadable(FdNode* fd_node, absl::Status status) {
grpc_core::MutexLock lock(&mutex_);
GPR_ASSERT(fd_node->readable_registered);
CHECK(fd_node->readable_registered);
fd_node->readable_registered = false;
GRPC_ARES_RESOLVER_TRACE_LOG("OnReadable: fd: %d; request: %p; status: %s",
fd_node->as, this, status.ToString().c_str());
@ -532,7 +533,7 @@ void AresResolver::OnReadable(FdNode* fd_node, absl::Status status) {
void AresResolver::OnWritable(FdNode* fd_node, absl::Status status) {
grpc_core::MutexLock lock(&mutex_);
GPR_ASSERT(fd_node->writable_registered);
CHECK(fd_node->writable_registered);
fd_node->writable_registered = false;
GRPC_ARES_RESOLVER_TRACE_LOG("OnWritable: fd: %d; request:%p; status: %s",
fd_node->as, this, status.ToString().c_str());
@ -582,7 +583,7 @@ void AresResolver::OnHostbynameDoneLocked(void* arg, int status,
int /*timeouts*/,
struct hostent* hostent) {
auto* hostname_qa = static_cast<HostnameQueryArg*>(arg);
GPR_ASSERT(hostname_qa->pending_requests-- > 0);
CHECK_GT(hostname_qa->pending_requests--, 0);
auto* ares_resolver = hostname_qa->ares_resolver;
if (status != ARES_SUCCESS) {
std::string error_msg =
@ -643,9 +644,9 @@ void AresResolver::OnHostbynameDoneLocked(void* arg, int status,
if (hostname_qa->pending_requests == 0) {
auto nh =
ares_resolver->callback_map_.extract(hostname_qa->callback_map_id);
GPR_ASSERT(!nh.empty());
GPR_ASSERT(absl::holds_alternative<
EventEngine::DNSResolver::LookupHostnameCallback>(nh.mapped()));
CHECK(!nh.empty());
CHECK(absl::holds_alternative<
EventEngine::DNSResolver::LookupHostnameCallback>(nh.mapped()));
auto callback = absl::get<EventEngine::DNSResolver::LookupHostnameCallback>(
std::move(nh.mapped()));
if (!hostname_qa->result.empty() || hostname_qa->error_status.ok()) {
@ -670,10 +671,9 @@ void AresResolver::OnSRVQueryDoneLocked(void* arg, int status, int /*timeouts*/,
std::unique_ptr<QueryArg> qa(static_cast<QueryArg*>(arg));
auto* ares_resolver = qa->ares_resolver;
auto nh = ares_resolver->callback_map_.extract(qa->callback_map_id);
GPR_ASSERT(!nh.empty());
GPR_ASSERT(
absl::holds_alternative<EventEngine::DNSResolver::LookupSRVCallback>(
nh.mapped()));
CHECK(!nh.empty());
CHECK(absl::holds_alternative<EventEngine::DNSResolver::LookupSRVCallback>(
nh.mapped()));
auto callback = absl::get<EventEngine::DNSResolver::LookupSRVCallback>(
std::move(nh.mapped()));
auto fail = [&](absl::string_view prefix) {
@ -726,10 +726,9 @@ void AresResolver::OnTXTDoneLocked(void* arg, int status, int /*timeouts*/,
std::unique_ptr<QueryArg> qa(static_cast<QueryArg*>(arg));
auto* ares_resolver = qa->ares_resolver;
auto nh = ares_resolver->callback_map_.extract(qa->callback_map_id);
GPR_ASSERT(!nh.empty());
GPR_ASSERT(
absl::holds_alternative<EventEngine::DNSResolver::LookupTXTCallback>(
nh.mapped()));
CHECK(!nh.empty());
CHECK(absl::holds_alternative<EventEngine::DNSResolver::LookupTXTCallback>(
nh.mapped()));
auto callback = absl::get<EventEngine::DNSResolver::LookupTXTCallback>(
std::move(nh.mapped()));
auto fail = [&](absl::string_view prefix) {

@ -20,6 +20,8 @@
#include <CoreFoundation/CoreFoundation.h>
#include "absl/log/check.h"
#include <grpc/support/cpu.h>
#include "src/core/lib/event_engine/cf_engine/cf_engine.h"
@ -68,7 +70,7 @@ CFEventEngine::~CFEventEngine() {
HandleToString(handle).c_str());
}
}
GPR_ASSERT(GPR_LIKELY(known_handles_.empty()));
CHECK(GPR_LIKELY(known_handles_.empty()));
timer_manager_.Shutdown();
}
thread_pool_->Quiesce();

@ -18,6 +18,7 @@
#include <AvailabilityMacros.h>
#ifdef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
#include "absl/log/check.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -153,7 +154,7 @@ void DNSServiceResolverImpl::ResolveCallback(
grpc_core::ReleasableMutexLock lock(&that->request_mu_);
auto request_it = that->requests_.find(sdRef);
GPR_ASSERT(request_it != that->requests_.end());
CHECK(request_it != that->requests_.end());
if (errorCode != kDNSServiceErr_NoError &&
errorCode != kDNSServiceErr_NoSuchRecord) {

@ -23,6 +23,7 @@
#include <dns_sd.h>
#include "absl/container/flat_hash_map.h"
#include "absl/log/check.h"
#include <grpc/event_engine/event_engine.h>
@ -47,7 +48,7 @@ class DNSServiceResolverImpl
explicit DNSServiceResolverImpl(std::shared_ptr<CFEventEngine> engine)
: engine_(std::move((engine))) {}
~DNSServiceResolverImpl() override {
GPR_ASSERT(requests_.empty());
CHECK(requests_.empty());
dispatch_release(queue_);
}

@ -14,6 +14,8 @@
#include "src/core/lib/event_engine/forkable.h"
#include "absl/log/check.h"
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -43,7 +45,7 @@ void ObjectGroupForkHandler::RegisterForkable(
std::shared_ptr<Forkable> forkable, GRPC_UNUSED void (*prepare)(void),
GRPC_UNUSED void (*parent)(void), GRPC_UNUSED void (*child)(void)) {
if (IsForkEnabled()) {
GPR_ASSERT(!is_forking_);
CHECK(!is_forking_);
forkables_.emplace_back(forkable);
#ifdef GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
if (!std::exchange(registered_, true)) {
@ -55,7 +57,7 @@ void ObjectGroupForkHandler::RegisterForkable(
void ObjectGroupForkHandler::Prefork() {
if (IsForkEnabled()) {
GPR_ASSERT(!std::exchange(is_forking_, true));
CHECK(!std::exchange(is_forking_, true));
GRPC_FORK_TRACE_LOG_STRING("PrepareFork");
for (auto it = forkables_.begin(); it != forkables_.end();) {
auto shared = it->lock();
@ -71,7 +73,7 @@ void ObjectGroupForkHandler::Prefork() {
void ObjectGroupForkHandler::PostforkParent() {
if (IsForkEnabled()) {
GPR_ASSERT(is_forking_);
CHECK(is_forking_);
GRPC_FORK_TRACE_LOG_STRING("PostforkParent");
for (auto it = forkables_.begin(); it != forkables_.end();) {
auto shared = it->lock();
@ -88,7 +90,7 @@ void ObjectGroupForkHandler::PostforkParent() {
void ObjectGroupForkHandler::PostforkChild() {
if (IsForkEnabled()) {
GPR_ASSERT(is_forking_);
CHECK(is_forking_);
GRPC_FORK_TRACE_LOG_STRING("PostforkChild");
for (auto it = forkables_.begin(); it != forkables_.end();) {
auto shared = it->lock();

@ -18,6 +18,7 @@
#include <atomic>
#include <memory>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
@ -353,14 +354,14 @@ Epoll1Poller::Epoll1Poller(Scheduler* scheduler)
: scheduler_(scheduler), was_kicked_(false), closed_(false) {
g_epoll_set_.epfd = EpollCreateAndCloexec();
wakeup_fd_ = *CreateWakeupFd();
GPR_ASSERT(wakeup_fd_ != nullptr);
GPR_ASSERT(g_epoll_set_.epfd >= 0);
CHECK(wakeup_fd_ != nullptr);
CHECK_GE(g_epoll_set_.epfd, 0);
gpr_log(GPR_INFO, "grpc epoll fd: %d", g_epoll_set_.epfd);
struct epoll_event ev;
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLET);
ev.data.ptr = wakeup_fd_.get();
GPR_ASSERT(epoll_ctl(g_epoll_set_.epfd, EPOLL_CTL_ADD, wakeup_fd_->ReadFd(),
&ev) == 0);
CHECK(epoll_ctl(g_epoll_set_.epfd, EPOLL_CTL_ADD, wakeup_fd_->ReadFd(),
&ev) == 0);
g_epoll_set_.num_events = 0;
g_epoll_set_.cursor = 0;
ForkPollerListAddPoller(this);
@ -438,7 +439,7 @@ bool Epoll1Poller::ProcessEpollEvents(int max_epoll_events_to_handle,
struct epoll_event* ev = &g_epoll_set_.events[c];
void* data_ptr = ev->data.ptr;
if (data_ptr == wakeup_fd_.get()) {
GPR_ASSERT(wakeup_fd_->ConsumeWakeup().ok());
CHECK(wakeup_fd_->ConsumeWakeup().ok());
was_kicked = true;
} else {
Epoll1EventHandle* handle = reinterpret_cast<Epoll1EventHandle*>(
@ -557,7 +558,7 @@ void Epoll1Poller::Kick() {
return;
}
was_kicked_ = true;
GPR_ASSERT(wakeup_fd_->Wakeup().ok());
CHECK(wakeup_fd_->Wakeup().ok());
}
std::shared_ptr<Epoll1Poller> MakeEpoll1Poller(Scheduler* scheduler) {

@ -23,6 +23,7 @@
#include "absl/container/inlined_vector.h"
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
@ -339,7 +340,7 @@ EventHandle* PollPoller::CreateHandle(int fd, absl::string_view /*name*/,
bool track_err) {
// Avoid unused-parameter warning for debug-only parameter
(void)track_err;
GPR_DEBUG_ASSERT(track_err == false);
DCHECK(track_err == false);
PollEventHandle* handle = new PollEventHandle(fd, shared_from_this());
ForkFdListAddHandle(handle);
// We need to send a kick to the thread executing Work(..) so that it can
@ -359,7 +360,7 @@ void PollEventHandle::OrphanHandle(PosixEngineClosure* on_done, int* release_fd,
if (release_fd != nullptr) {
*release_fd = fd_;
}
GPR_ASSERT(!is_orphaned_);
CHECK(!is_orphaned_);
is_orphaned_ = true;
// Perform shutdown operations if not already done so.
if (!is_shutdown_) {
@ -573,7 +574,7 @@ void PollPoller::KickExternal(bool ext) {
}
was_kicked_ = true;
was_kicked_ext_ = ext;
GPR_ASSERT(wakeup_fd_->Wakeup().ok());
CHECK(wakeup_fd_->Wakeup().ok());
}
void PollPoller::Kick() { KickExternal(true); }
@ -612,7 +613,7 @@ PollPoller::PollPoller(Scheduler* scheduler)
poll_handles_list_head_(nullptr),
closed_(false) {
wakeup_fd_ = *CreateWakeupFd();
GPR_ASSERT(wakeup_fd_ != nullptr);
CHECK(wakeup_fd_ != nullptr);
ForkPollerListAddPoller(this);
}
@ -625,15 +626,15 @@ PollPoller::PollPoller(Scheduler* scheduler, bool use_phony_poll)
poll_handles_list_head_(nullptr),
closed_(false) {
wakeup_fd_ = *CreateWakeupFd();
GPR_ASSERT(wakeup_fd_ != nullptr);
CHECK(wakeup_fd_ != nullptr);
ForkPollerListAddPoller(this);
}
PollPoller::~PollPoller() {
// Assert that no active handles are present at the time of destruction.
// They should have been orphaned before reaching this state.
GPR_ASSERT(num_poll_handles_ == 0);
GPR_ASSERT(poll_handles_list_head_ == nullptr);
CHECK_EQ(num_poll_handles_, 0);
CHECK_EQ(poll_handles_list_head_, nullptr);
}
Poller::WorkResult PollPoller::Work(
@ -685,7 +686,7 @@ Poller::WorkResult PollPoller::Work(
// There shouldn't be any orphaned fds at this point. This is because
// prior to marking a handle as orphaned it is first removed from
// poll handle list for the poller under the poller lock.
GPR_ASSERT(!head->IsOrphaned());
CHECK(!head->IsOrphaned());
if (!head->IsPollhup()) {
pfds[pfd_count].fd = head->WrappedFd();
watchers[pfd_count] = head;
@ -761,7 +762,7 @@ Poller::WorkResult PollPoller::Work(
}
} else {
if (pfds[0].revents & kPollinCheck) {
GPR_ASSERT(wakeup_fd_->ConsumeWakeup().ok());
CHECK(wakeup_fd_->ConsumeWakeup().ok());
}
for (i = 1; i < pfd_count; i++) {
PollEventHandle* head = watchers[i];

@ -16,6 +16,7 @@
#include <atomic>
#include <cstdint>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include <grpc/support/atm.h>
@ -78,7 +79,7 @@ void LockfreeEvent::DestroyEvent() {
if (curr & kShutdownBit) {
grpc_core::internal::StatusFreeHeapPtr(curr & ~kShutdownBit);
} else {
GPR_ASSERT(curr == kClosureNotReady || curr == kClosureReady);
CHECK(curr == kClosureNotReady || curr == kClosureReady);
}
// we CAS in a shutdown, no error value here. If this event is interacted
// with post-deletion (see the note in the constructor) we want the bit

@ -26,6 +26,7 @@
#include <type_traits>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -245,7 +246,7 @@ msg_iovlen_type TcpZerocopySendRecord::PopulateIovs(size_t* unwind_slice_idx,
++(out_offset_.slice_idx);
out_offset_.byte_idx = 0;
}
GPR_DEBUG_ASSERT(iov_size > 0);
DCHECK_GT(iov_size, 0u);
return iov_size;
}
@ -314,8 +315,8 @@ bool PosixEndpointImpl::TcpDoRead(absl::Status& status) {
iov[i].iov_len = slice.length();
}
GPR_ASSERT(incoming_buffer_->Length() != 0);
GPR_DEBUG_ASSERT(min_progress_size_ > 0);
CHECK_NE(incoming_buffer_->Length(), 0u);
DCHECK_GT(min_progress_size_, 0);
do {
// Assume there is something on the queue. If we receive TCP_INQ from
@ -371,12 +372,11 @@ bool PosixEndpointImpl::TcpDoRead(absl::Status& status) {
}
AddToEstimate(static_cast<size_t>(read_bytes));
GPR_DEBUG_ASSERT((size_t)read_bytes <=
incoming_buffer_->Length() - total_read_bytes);
DCHECK((size_t)read_bytes <= incoming_buffer_->Length() - total_read_bytes);
#ifdef GRPC_HAVE_TCP_INQ
if (inq_capable_) {
GPR_DEBUG_ASSERT(!(msg.msg_flags & MSG_CTRUNC));
DCHECK(!(msg.msg_flags & MSG_CTRUNC));
struct cmsghdr* cmsg = CMSG_FIRSTHDR(&msg);
for (; cmsg != nullptr; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level == SOL_TCP && cmsg->cmsg_type == TCP_CM_INQ &&
@ -419,7 +419,7 @@ bool PosixEndpointImpl::TcpDoRead(absl::Status& status) {
FinishEstimate();
}
GPR_DEBUG_ASSERT(total_read_bytes > 0);
DCHECK_GT(total_read_bytes, 0u);
status = absl::OkStatus();
if (grpc_core::IsTcpFrameSizeTuningEnabled()) {
// Update min progress size based on the total number of bytes read in
@ -595,7 +595,7 @@ bool PosixEndpointImpl::Read(absl::AnyInvocable<void(absl::Status)> on_read,
const EventEngine::Endpoint::ReadArgs* args) {
grpc_core::ReleasableMutexLock lock(&read_mu_);
GRPC_EVENT_ENGINE_ENDPOINT_TRACE("Endpoint[%p]: Read", this);
GPR_ASSERT(read_cb_ == nullptr);
CHECK(read_cb_ == nullptr);
incoming_buffer_ = buffer;
incoming_buffer_->Clear();
incoming_buffer_->Swap(last_read_buffer_);
@ -670,8 +670,8 @@ TcpZerocopySendRecord* PosixEndpointImpl::TcpGetSendZerocopyRecord(
}
if (zerocopy_send_record != nullptr) {
zerocopy_send_record->PrepareForSends(buf);
GPR_DEBUG_ASSERT(buf.Count() == 0);
GPR_DEBUG_ASSERT(buf.Length() == 0);
DCHECK_EQ(buf.Count(), 0u);
DCHECK_EQ(buf.Length(), 0u);
outgoing_byte_idx_ = 0;
outgoing_buffer_ = nullptr;
}
@ -758,10 +758,10 @@ void PosixEndpointImpl::ZerocopyDisableAndWaitForRemaining() {
// Reads \a cmsg to process zerocopy control messages.
void PosixEndpointImpl::ProcessZerocopy(struct cmsghdr* cmsg) {
GPR_DEBUG_ASSERT(cmsg);
DCHECK(cmsg);
auto serr = reinterpret_cast<struct sock_extended_err*>(CMSG_DATA(cmsg));
GPR_DEBUG_ASSERT(serr->ee_errno == 0);
GPR_DEBUG_ASSERT(serr->ee_origin == SO_EE_ORIGIN_ZEROCOPY);
DCHECK_EQ(serr->ee_errno, 0u);
DCHECK(serr->ee_origin == SO_EE_ORIGIN_ZEROCOPY);
const uint32_t lo = serr->ee_info;
const uint32_t hi = serr->ee_data;
for (uint32_t seq = lo; seq <= hi; ++seq) {
@ -771,7 +771,7 @@ void PosixEndpointImpl::ProcessZerocopy(struct cmsghdr* cmsg) {
// both; if so, batch the unref/put.
TcpZerocopySendRecord* record =
tcp_zerocopy_send_ctx_->ReleaseSendRecord(seq);
GPR_DEBUG_ASSERT(record);
DCHECK(record);
UnrefMaybePutZerocopySendRecord(record);
}
if (tcp_zerocopy_send_ctx_->UpdateZeroCopyOptMemStateAfterFree()) {
@ -1057,7 +1057,7 @@ bool PosixEndpointImpl::TcpFlush(absl::Status& status) {
outgoing_slice_idx++;
outgoing_byte_idx_ = 0;
}
GPR_ASSERT(iov_size > 0);
CHECK_GT(iov_size, 0u);
msg.msg_name = nullptr;
msg.msg_namelen = 0;
@ -1100,7 +1100,7 @@ bool PosixEndpointImpl::TcpFlush(absl::Status& status) {
}
}
GPR_ASSERT(outgoing_byte_idx_ == 0);
CHECK_EQ(outgoing_byte_idx_, 0u);
bytes_counter_ += sent_length;
trailing = sending_length - static_cast<size_t>(sent_length);
while (trailing > 0) {
@ -1139,7 +1139,7 @@ void PosixEndpointImpl::HandleWrite(absl::Status status) {
? TcpFlushZerocopy(current_zerocopy_send_, status)
: TcpFlush(status);
if (!flush_result) {
GPR_DEBUG_ASSERT(status.ok());
DCHECK(status.ok());
handle_->NotifyOnWrite(on_write_);
} else {
GRPC_EVENT_ENGINE_ENDPOINT_TRACE("Endpoint[%p]: Write complete: %s", this,
@ -1158,9 +1158,9 @@ bool PosixEndpointImpl::Write(
absl::Status status = absl::OkStatus();
TcpZerocopySendRecord* zerocopy_send_record = nullptr;
GPR_ASSERT(write_cb_ == nullptr);
GPR_DEBUG_ASSERT(current_zerocopy_send_ == nullptr);
GPR_DEBUG_ASSERT(data != nullptr);
CHECK(write_cb_ == nullptr);
DCHECK_EQ(current_zerocopy_send_, nullptr);
DCHECK_NE(data, nullptr);
GRPC_EVENT_ENGINE_ENDPOINT_TRACE("Endpoint[%p]: Write %" PRIdPTR " bytes",
this, data->Length());
@ -1191,7 +1191,7 @@ bool PosixEndpointImpl::Write(
outgoing_buffer_arg_ = args->google_specific;
}
if (outgoing_buffer_arg_) {
GPR_ASSERT(poller_->CanTrackErrors());
CHECK(poller_->CanTrackErrors());
}
bool flush_result = zerocopy_send_record != nullptr
@ -1266,7 +1266,7 @@ PosixEndpointImpl::PosixEndpointImpl(EventHandle* handle,
engine_(engine) {
PosixSocketWrapper sock(handle->WrappedFd());
fd_ = handle_->WrappedFd();
GPR_ASSERT(options.resource_quota != nullptr);
CHECK(options.resource_quota != nullptr);
auto peer_addr_string = sock.PeerAddressString();
mem_quota_ = options.resource_quota->memory_quota();
memory_owner_ = mem_quota_->CreateMemoryOwner();
@ -1348,7 +1348,7 @@ std::unique_ptr<PosixEndpoint> CreatePosixEndpoint(
EventHandle* handle, PosixEngineClosure* on_shutdown,
std::shared_ptr<EventEngine> engine, MemoryAllocator&& allocator,
const PosixTcpOptions& options) {
GPR_DEBUG_ASSERT(handle != nullptr);
DCHECK_NE(handle, nullptr);
return std::make_unique<PosixEndpoint>(handle, on_shutdown, std::move(engine),
std::move(allocator), options);
}

@ -29,6 +29,7 @@
#include "absl/container/flat_hash_map.h"
#include "absl/functional/any_invocable.h"
#include "absl/hash/hash.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -130,7 +131,7 @@ class TcpZerocopySendRecord {
// sendmsg() failed or when tcp_write() is done.
bool Unref() {
const intptr_t prior = ref_.fetch_sub(1, std::memory_order_acq_rel);
GPR_DEBUG_ASSERT(prior > 0);
DCHECK_GT(prior, 0);
if (prior == 1) {
AllSendsComplete();
return true;
@ -145,9 +146,9 @@ class TcpZerocopySendRecord {
};
void DebugAssertEmpty() {
GPR_DEBUG_ASSERT(buf_.Count() == 0);
GPR_DEBUG_ASSERT(buf_.Length() == 0);
GPR_DEBUG_ASSERT(ref_.load(std::memory_order_relaxed) == 0);
DCHECK_EQ(buf_.Count(), 0u);
DCHECK_EQ(buf_.Length(), 0u);
DCHECK_EQ(ref_.load(std::memory_order_relaxed), 0);
}
// When all sendmsg() calls associated with this tcp_write() have been
@ -155,7 +156,7 @@ class TcpZerocopySendRecord {
// for each sendmsg()) and all reference counts have been dropped, drop our
// reference to the underlying data since we no longer need it.
void AllSendsComplete() {
GPR_DEBUG_ASSERT(ref_.load(std::memory_order_relaxed) == 0);
DCHECK_EQ(ref_.load(std::memory_order_relaxed), 0);
buf_.Clear();
}
@ -236,7 +237,7 @@ class TcpZerocopySendCtx {
--last_send_;
if (ReleaseSendRecord(last_send_)->Unref()) {
// We should still be holding the ref taken by tcp_write().
GPR_DEBUG_ASSERT(0);
DCHECK(0);
}
}
@ -274,8 +275,7 @@ class TcpZerocopySendCtx {
// same time.
void PutSendRecord(TcpZerocopySendRecord* record) {
grpc_core::MutexLock lock(&mu_);
GPR_DEBUG_ASSERT(record >= send_records_ &&
record < send_records_ + max_sends_);
DCHECK(record >= send_records_ && record < send_records_ + max_sends_);
PutSendRecordLocked(record);
}
@ -332,7 +332,7 @@ class TcpZerocopySendCtx {
zcopy_enobuf_state_ = OptMemState::kCheck;
return false;
}
GPR_DEBUG_ASSERT(zcopy_enobuf_state_ != OptMemState::kCheck);
DCHECK(zcopy_enobuf_state_ != OptMemState::kCheck);
if (zcopy_enobuf_state_ == OptMemState::kFull) {
// A previous sendmsg attempt was blocked by ENOBUFS. Return true to
// mark the fd as writable so the next write attempt could be made.
@ -423,7 +423,7 @@ class TcpZerocopySendCtx {
TcpZerocopySendRecord* ReleaseSendRecordLocked(uint32_t seq)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
auto iter = ctx_lookup_.find(seq);
GPR_DEBUG_ASSERT(iter != ctx_lookup_.end());
DCHECK(iter != ctx_lookup_.end());
TcpZerocopySendRecord* record = iter->second;
ctx_lookup_.erase(iter);
return record;
@ -443,7 +443,7 @@ class TcpZerocopySendCtx {
void PutSendRecordLocked(TcpZerocopySendRecord* record)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
GPR_DEBUG_ASSERT(free_send_records_size_ < max_sends_);
DCHECK(free_send_records_size_ < max_sends_);
free_send_records_[free_send_records_size_] = record;
free_send_records_size_++;
}

@ -25,6 +25,7 @@
#include "absl/cleanup/cleanup.h"
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "absl/strings/str_cat.h"
@ -142,7 +143,7 @@ void AsyncConnect::OnWritable(absl::Status status)
absl::StatusOr<std::unique_ptr<EventEngine::Endpoint>> ep;
mu_.Lock();
GPR_ASSERT(fd_ != nullptr);
CHECK_NE(fd_, nullptr);
fd = std::exchange(fd_, nullptr);
bool connect_cancelled = connect_cancelled_;
if (fd->IsHandleShutdown() && status.ok()) {
@ -334,7 +335,7 @@ PosixEnginePollerManager::PosixEnginePollerManager(
poller_state_(PollerState::kExternal),
executor_(nullptr),
trigger_shutdown_called_(false) {
GPR_DEBUG_ASSERT(poller_ != nullptr);
DCHECK_NE(poller_, nullptr);
}
void PosixEnginePollerManager::Run(
@ -351,7 +352,7 @@ void PosixEnginePollerManager::Run(absl::AnyInvocable<void()> cb) {
}
void PosixEnginePollerManager::TriggerShutdown() {
GPR_DEBUG_ASSERT(trigger_shutdown_called_ == false);
DCHECK(trigger_shutdown_called_ == false);
trigger_shutdown_called_ = true;
// If the poller is external, dont try to shut it down. Otherwise
// set poller state to PollerState::kShuttingDown.
@ -467,7 +468,7 @@ PosixEventEngine::~PosixEventEngine() {
this, HandleToString(handle).c_str());
}
}
GPR_ASSERT(GPR_LIKELY(known_handles_.empty()));
CHECK(GPR_LIKELY(known_handles_.empty()));
}
timer_manager_->Shutdown();
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
@ -592,7 +593,7 @@ bool PosixEventEngine::CancelConnect(EventEngine::ConnectionHandle handle) {
auto it = shard->pending_connections.find(connection_handle);
if (it != shard->pending_connections.end()) {
ac = it->second;
GPR_ASSERT(ac != nullptr);
CHECK_NE(ac, nullptr);
// Trying to acquire ac->mu here would could cause a deadlock because
// the OnWritable method tries to acquire the two mutexes used
// here in the reverse order. But we dont need to acquire ac->mu before
@ -639,7 +640,7 @@ EventEngine::ConnectionHandle PosixEventEngine::Connect(
const EndpointConfig& args, MemoryAllocator memory_allocator,
Duration timeout) {
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
GPR_ASSERT(poller_manager_ != nullptr);
CHECK_NE(poller_manager_, nullptr);
PosixTcpOptions options = TcpOptionsFromEndpointConfig(args);
absl::StatusOr<PosixSocketWrapper::PosixSocketCreateResult> socket =
PosixSocketWrapper::CreateAndPrepareTcpClientSocket(options, addr);
@ -661,9 +662,9 @@ PosixEventEngine::CreatePosixEndpointFromFd(int fd,
const EndpointConfig& config,
MemoryAllocator memory_allocator) {
#if GRPC_PLATFORM_SUPPORTS_POSIX_POLLING
GPR_DEBUG_ASSERT(fd > 0);
DCHECK_GT(fd, 0);
PosixEventPoller* poller = poller_manager_->Poller();
GPR_DEBUG_ASSERT(poller != nullptr);
DCHECK_NE(poller, nullptr);
EventHandle* handle =
poller->CreateHandle(fd, "tcp-client", poller->CanTrackErrors());
return CreatePosixEndpoint(handle, nullptr, shared_from_this(),

@ -31,6 +31,7 @@
#include <utility>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/types/optional.h"
@ -79,7 +80,7 @@ absl::StatusOr<int> PosixEngineListenerImpl::Bind(
EventEngine::ResolvedAddress res_addr = addr;
EventEngine::ResolvedAddress addr6_v4mapped;
int requested_port = ResolvedAddressGetPort(res_addr);
GPR_ASSERT(addr.size() <= EventEngine::ResolvedAddress::MAX_SIZE_BYTES);
CHECK(addr.size() <= EventEngine::ResolvedAddress::MAX_SIZE_BYTES);
UnlinkIfUnixDomainSocket(addr);
/// Check if this is a wildcard port, and if so, try to keep the port the same
@ -303,7 +304,7 @@ void PosixEngineListenerImpl::AsyncConnectionAcceptor::Shutdown() {
absl::Status PosixEngineListenerImpl::Start() {
grpc_core::MutexLock lock(&this->mu_);
// Start each asynchronous acceptor.
GPR_ASSERT(!this->started_);
CHECK(!this->started_);
this->started_ = true;
for (auto it = acceptors_.begin(); it != acceptors_.end(); it++) {
(*it)->Start();

@ -22,6 +22,7 @@
#include <string>
#include "absl/cleanup/cleanup.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_replace.h"
@ -137,7 +138,7 @@ absl::Status PrepareSocket(const PosixTcpOptions& options,
ListenerSocket& socket) {
ResolvedAddress sockname_temp;
int fd = socket.sock.Fd();
GPR_ASSERT(fd >= 0);
CHECK_GE(fd, 0);
bool close_fd = true;
socket.zero_copy_enabled = false;
socket.port = 0;
@ -226,7 +227,7 @@ absl::StatusOr<ListenerSocket> CreateAndPrepareListenerSocket(
socket.addr = addr;
}
GRPC_RETURN_IF_ERROR(PrepareSocket(options, socket));
GPR_ASSERT(socket.port > 0);
CHECK_GT(socket.port, 0);
return socket;
}
@ -359,8 +360,8 @@ absl::StatusOr<int> ListenerContainerAddWildcardAddresses(
}
return assigned_port;
} else {
GPR_ASSERT(!v6_sock.ok());
GPR_ASSERT(!v4_sock.ok());
CHECK(!v6_sock.ok());
CHECK(!v4_sock.ok());
return absl::FailedPreconditionError(absl::StrCat(
"Failed to add any wildcard listeners: ", v6_sock.status().message(),
v4_sock.status().message()));

@ -48,6 +48,7 @@
#include <atomic>
#include <cstring>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include <grpc/support/log.h>
@ -662,7 +663,7 @@ void PosixSocketWrapper::TrySetSocketTcpUserTimeout(
// Set a socket using a grpc_socket_mutator
absl::Status PosixSocketWrapper::SetSocketMutator(
grpc_fd_usage usage, grpc_socket_mutator* mutator) {
GPR_ASSERT(mutator);
CHECK(mutator);
if (!grpc_socket_mutator_mutate_fd(mutator, fd_, usage)) {
return absl::Status(absl::StatusCode::kInternal,
"grpc_socket_mutator failed.");

@ -19,6 +19,7 @@
#include <string>
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@ -161,7 +162,7 @@ void UnlinkIfUnixDomainSocket(
class PosixSocketWrapper {
public:
explicit PosixSocketWrapper(int fd) : fd_(fd) { GPR_ASSERT(fd_ > 0); }
explicit PosixSocketWrapper(int fd) : fd_(fd) { CHECK_GT(fd_, 0); }
PosixSocketWrapper() : fd_(-1){};

@ -21,6 +21,7 @@
#include <memory>
#include <utility>
#include "absl/log/check.h"
#include "absl/time/time.h"
#include "absl/types/optional.h"
@ -68,8 +69,8 @@ void TimerManager::MainLoop() {
grpc_core::Timestamp next = grpc_core::Timestamp::InfFuture();
absl::optional<std::vector<experimental::EventEngine::Closure*>>
check_result = timer_list_->TimerCheck(&next);
GPR_ASSERT(check_result.has_value() &&
"ERROR: More than one MainLoop is running.");
CHECK(check_result.has_value())
<< "ERROR: More than one MainLoop is running.";
bool timers_found = !check_result->empty();
if (timers_found) {
RunSomeTimers(std::move(*check_result));
@ -145,7 +146,7 @@ void TimerManager::Kick() {
void TimerManager::RestartPostFork() {
grpc_core::MutexLock lock(&mu_);
GPR_ASSERT(GPR_LIKELY(shutdown_));
CHECK(GPR_LIKELY(shutdown_));
if (grpc_event_engine_timer_trace.enabled()) {
gpr_log(GPR_DEBUG, "TimerManager::%p restarting after shutdown", this);
}

@ -16,6 +16,8 @@
#include <string.h>
#include "absl/log/check.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@ -30,8 +32,8 @@ namespace experimental {
EventEngine::ResolvedAddress::ResolvedAddress(const sockaddr* address,
socklen_t size)
: size_(size) {
GPR_DEBUG_ASSERT(size >= 0);
GPR_ASSERT(static_cast<size_t>(size) <= sizeof(address_));
DCHECK_GE(size, 0u);
CHECK(static_cast<size_t>(size) <= sizeof(address_));
memcpy(&address_, address, size);
}

@ -19,6 +19,8 @@
#include <string>
#include <utility>
#include "absl/log/check.h"
#include <grpc/event_engine/slice.h>
#include <grpc/slice.h>
#include <grpc/support/log.h>
@ -48,7 +50,7 @@ Slice CopyConstructors<Slice>::FromCopiedString(std::string s) {
MutableSlice::MutableSlice(const grpc_slice& slice)
: slice_detail::BaseSlice(slice) {
GPR_DEBUG_ASSERT(slice.refcount == nullptr || slice.refcount->IsUnique());
DCHECK(slice.refcount == nullptr || slice.refcount->IsUnique());
}
MutableSlice::~MutableSlice() { grpc_core::CSliceUnref(c_slice()); }

@ -53,6 +53,7 @@
#include <utility>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
@ -223,7 +224,7 @@ bool ResolvedAddressIsV4Mapped(
bool ResolvedAddressToV4Mapped(
const EventEngine::ResolvedAddress& resolved_addr,
EventEngine::ResolvedAddress* resolved_addr6_out) {
GPR_ASSERT(&resolved_addr != resolved_addr6_out);
CHECK(&resolved_addr != resolved_addr6_out);
const sockaddr* addr = resolved_addr.address();
sockaddr_in6* addr6_out = const_cast<sockaddr_in6*>(
reinterpret_cast<const sockaddr_in6*>(resolved_addr6_out->address()));
@ -245,7 +246,8 @@ EventEngine::ResolvedAddress ResolvedAddressMakeWild6(int port) {
EventEngine::ResolvedAddress resolved_wild_out;
sockaddr_in6* wild_out = reinterpret_cast<sockaddr_in6*>(
const_cast<sockaddr*>(resolved_wild_out.address()));
GPR_ASSERT(port >= 0 && port < 65536);
CHECK_GE(port, 0);
CHECK_LT(port, 65536);
memset(wild_out, 0, sizeof(sockaddr_in6));
wild_out->sin6_family = AF_INET6;
wild_out->sin6_port = htons(static_cast<uint16_t>(port));
@ -258,7 +260,8 @@ EventEngine::ResolvedAddress ResolvedAddressMakeWild4(int port) {
EventEngine::ResolvedAddress resolved_wild_out;
sockaddr_in* wild_out = reinterpret_cast<sockaddr_in*>(
const_cast<sockaddr*>(resolved_wild_out.address()));
GPR_ASSERT(port >= 0 && port < 65536);
CHECK_GE(port, 0);
CHECK_LT(port, 65536);
memset(wild_out, 0, sizeof(sockaddr_in));
wild_out->sin_family = AF_INET;
wild_out->sin_port = htons(static_cast<uint16_t>(port));
@ -294,12 +297,14 @@ void ResolvedAddressSetPort(EventEngine::ResolvedAddress& resolved_addr,
sockaddr* addr = const_cast<sockaddr*>(resolved_addr.address());
switch (addr->sa_family) {
case AF_INET:
GPR_ASSERT(port >= 0 && port < 65536);
CHECK_GE(port, 0);
CHECK_LT(port, 65536);
(reinterpret_cast<sockaddr_in*>(addr))->sin_port =
htons(static_cast<uint16_t>(port));
return;
case AF_INET6:
GPR_ASSERT(port >= 0 && port < 65536);
CHECK_GE(port, 0);
CHECK_LT(port, 65536);
(reinterpret_cast<sockaddr_in6*>(addr))->sin6_port =
htons(static_cast<uint16_t>(port));
return;
@ -445,7 +450,7 @@ absl::StatusOr<EventEngine::ResolvedAddress> URIToResolvedAddress(
uri.status().ToString().c_str());
}
GRPC_RETURN_IF_ERROR(uri.status());
GPR_ASSERT(grpc_parse_uri(*uri, &addr));
CHECK(grpc_parse_uri(*uri, &addr));
return EventEngine::ResolvedAddress(
reinterpret_cast<const sockaddr*>(addr.addr), addr.len);
}

@ -26,6 +26,7 @@
#include <utility>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "absl/types/optional.h"
@ -183,7 +184,7 @@ WorkStealingThreadPool::WorkStealingThreadPool(size_t reserve_threads)
void WorkStealingThreadPool::Quiesce() { pool_->Quiesce(); }
WorkStealingThreadPool::~WorkStealingThreadPool() {
GPR_ASSERT(pool_->IsQuiesced());
CHECK(pool_->IsQuiesced());
}
void WorkStealingThreadPool::Run(absl::AnyInvocable<void()> callback) {
@ -237,7 +238,7 @@ void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Start() {
void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Run(
EventEngine::Closure* closure) {
GPR_DEBUG_ASSERT(quiesced_.load(std::memory_order_relaxed) == false);
DCHECK(quiesced_.load(std::memory_order_relaxed) == false);
if (g_local_queue != nullptr && g_local_queue->owner() == this) {
g_local_queue->Add(closure);
} else {
@ -280,7 +281,7 @@ void WorkStealingThreadPool::WorkStealingThreadPoolImpl::Quiesce() {
if (!threads_were_shut_down.ok() && g_log_verbose_failures) {
DumpStacksAndCrash();
}
GPR_ASSERT(queue_.Empty());
CHECK(queue_.Empty());
quiesced_.store(true, std::memory_order_relaxed);
lifeguard_.BlockUntilShutdownAndReset();
}
@ -293,14 +294,14 @@ bool WorkStealingThreadPool::WorkStealingThreadPoolImpl::SetThrottled(
void WorkStealingThreadPool::WorkStealingThreadPoolImpl::SetShutdown(
bool is_shutdown) {
auto was_shutdown = shutdown_.exchange(is_shutdown);
GPR_ASSERT(is_shutdown != was_shutdown);
CHECK(is_shutdown != was_shutdown);
work_signal_.SignalAll();
}
void WorkStealingThreadPool::WorkStealingThreadPoolImpl::SetForking(
bool is_forking) {
auto was_forking = forking_.exchange(is_forking);
GPR_ASSERT(is_forking != was_forking);
CHECK(is_forking != was_forking);
}
bool WorkStealingThreadPool::WorkStealingThreadPoolImpl::IsForking() {
@ -507,7 +508,7 @@ void WorkStealingThreadPool::ThreadState::ThreadBody() {
} else if (pool_->IsShutdown()) {
FinishDraining();
}
GPR_ASSERT(g_local_queue->Empty());
CHECK(g_local_queue->Empty());
pool_->theft_registry()->Unenroll(g_local_queue);
delete g_local_queue;
if (g_log_verbose_failures) {

@ -23,6 +23,7 @@
#include <ares.h>
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
@ -132,8 +133,8 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
shutdown_called_);
grpc_core::CSliceUnref(read_buf_);
grpc_core::CSliceUnref(write_buf_);
GPR_ASSERT(read_closure_ == nullptr);
GPR_ASSERT(write_closure_ == nullptr);
CHECK(read_closure_ == nullptr);
CHECK(write_closure_ == nullptr);
if (!shutdown_called_) {
winsocket_->Shutdown(DEBUG_LOCATION, "~GrpcPolledFdWindows");
}
@ -141,15 +142,15 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
void RegisterForOnReadableLocked(
absl::AnyInvocable<void(absl::Status)> read_closure) override {
GPR_ASSERT(read_closure_ == nullptr);
CHECK(read_closure_ == nullptr);
read_closure_ = std::move(read_closure);
grpc_core::CSliceUnref(read_buf_);
GPR_ASSERT(!read_buf_has_data_);
CHECK(!read_buf_has_data_);
read_buf_ = GRPC_SLICE_MALLOC(kReadBufferSize);
if (connect_done_) {
ContinueRegisterForOnReadableLocked();
} else {
GPR_ASSERT(pending_continue_register_for_on_readable_locked_ == false);
CHECK(pending_continue_register_for_on_readable_locked_ == false);
pending_continue_register_for_on_readable_locked_ = true;
}
}
@ -160,16 +161,16 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
GRPC_ARES_RESOLVER_TRACE_LOG(
"fd:|%s| RegisterForOnWriteableLocked called", GetName());
} else {
GPR_ASSERT(socket_type_ == SOCK_STREAM);
CHECK(socket_type_ == SOCK_STREAM);
GRPC_ARES_RESOLVER_TRACE_LOG(
"fd:|%s| RegisterForOnWriteableLocked called tcp_write_state_: %d "
"connect_done_: %d",
GetName(), tcp_write_state_, connect_done_);
}
GPR_ASSERT(write_closure_ == nullptr);
CHECK(write_closure_ == nullptr);
write_closure_ = std::move(write_closure);
if (!connect_done_) {
GPR_ASSERT(!pending_continue_register_for_on_writeable_locked_);
CHECK(!pending_continue_register_for_on_writeable_locked_);
pending_continue_register_for_on_writeable_locked_ = true;
} else {
ContinueRegisterForOnWriteableLocked();
@ -179,7 +180,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
bool IsFdStillReadableLocked() override { return read_buf_has_data_; }
bool ShutdownLocked(absl::Status error) override {
GPR_ASSERT(!shutdown_called_);
CHECK(!shutdown_called_);
if (!absl::IsCancelled(error)) {
return false;
}
@ -223,7 +224,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
// c-ares overloads this recv_from virtual socket function to receive
// data on both UDP and TCP sockets, and from is nullptr for TCP.
if (from != nullptr) {
GPR_ASSERT(*from_len <= recv_from_source_addr_len_);
CHECK(*from_len <= recv_from_source_addr_len_);
memcpy(from, &recv_from_source_addr_, recv_from_source_addr_len_);
*from_len = recv_from_source_addr_len_;
}
@ -291,7 +292,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
"fd:|%s| ContinueRegisterForOnReadableLocked "
"wsa_connect_error_:%d",
GetName(), wsa_connect_error_);
GPR_ASSERT(connect_done_);
CHECK(connect_done_);
if (wsa_connect_error_ != 0) {
ScheduleAndNullReadClosure(GRPC_WSA_ERROR(wsa_connect_error_, "connect"));
return;
@ -328,7 +329,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
"fd:|%s| ContinueRegisterForOnWriteableLocked "
"wsa_connect_error_:%d",
GetName(), wsa_connect_error_);
GPR_ASSERT(connect_done_);
CHECK(connect_done_);
if (wsa_connect_error_ != 0) {
ScheduleAndNullWriteClosure(
GRPC_WSA_ERROR(wsa_connect_error_, "connect"));
@ -338,7 +339,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
ScheduleAndNullWriteClosure(absl::OkStatus());
return;
}
GPR_ASSERT(socket_type_ == SOCK_STREAM);
CHECK(socket_type_ == SOCK_STREAM);
int wsa_error_code = 0;
switch (tcp_write_state_) {
case WRITE_IDLE:
@ -386,7 +387,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
// Therefore, the sendv handler for UDP sockets must only attempt
// to write everything inline.
GRPC_ARES_RESOLVER_TRACE_LOG("fd:|%s| SendVUDP called", GetName());
GPR_ASSERT(GRPC_SLICE_LENGTH(write_buf_) == 0);
CHECK_EQ(GRPC_SLICE_LENGTH(write_buf_), 0);
grpc_core::CSliceUnref(write_buf_);
write_buf_ = FlattenIovec(iov, iov_count);
DWORD bytes_sent = 0;
@ -434,12 +435,12 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
// send again. If c-ares still needs to send even more data, we'll get
// to it eventually.
grpc_slice currently_attempted = FlattenIovec(iov, iov_count);
GPR_ASSERT(GRPC_SLICE_LENGTH(currently_attempted) >=
GRPC_SLICE_LENGTH(write_buf_));
CHECK(GRPC_SLICE_LENGTH(currently_attempted) >=
GRPC_SLICE_LENGTH(write_buf_));
ares_ssize_t total_sent = 0;
for (size_t i = 0; i < GRPC_SLICE_LENGTH(write_buf_); i++) {
GPR_ASSERT(GRPC_SLICE_START_PTR(currently_attempted)[i] ==
GRPC_SLICE_START_PTR(write_buf_)[i]);
CHECK(GRPC_SLICE_START_PTR(currently_attempted)[i] ==
GRPC_SLICE_START_PTR(write_buf_)[i]);
total_sent++;
}
grpc_core::CSliceUnref(currently_attempted);
@ -458,9 +459,9 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
" pending_register_for_writeable:%d",
GetName(), pending_continue_register_for_on_readable_locked_,
pending_continue_register_for_on_writeable_locked_);
GPR_ASSERT(!connect_done_);
CHECK(!connect_done_);
connect_done_ = true;
GPR_ASSERT(wsa_connect_error_ == 0);
CHECK_EQ(wsa_connect_error_, 0);
if (shutdown_called_) {
wsa_connect_error_ = WSA_OPERATION_ABORTED;
} else {
@ -469,7 +470,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
BOOL wsa_success = WSAGetOverlappedResult(
winsocket_->raw_socket(), winsocket_->write_info()->overlapped(),
&transferred_bytes, FALSE, &flags);
GPR_ASSERT(transferred_bytes == 0);
CHECK_EQ(transferred_bytes, 0);
if (!wsa_success) {
wsa_connect_error_ = WSAGetLastError();
char* msg = gpr_format_message(wsa_connect_error_);
@ -491,8 +492,8 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
int ConnectUDP(WSAErrorContext* wsa_error_ctx, const struct sockaddr* target,
ares_socklen_t target_len) {
GRPC_ARES_RESOLVER_TRACE_LOG("fd:%s ConnectUDP", GetName());
GPR_ASSERT(!connect_done_);
GPR_ASSERT(wsa_connect_error_ == 0);
CHECK(!connect_done_);
CHECK_EQ(wsa_connect_error_, 0);
SOCKET s = winsocket_->raw_socket();
int out =
WSAConnect(s, target, target_len, nullptr, nullptr, nullptr, nullptr);
@ -620,7 +621,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
void OnIocpWriteable() {
grpc_core::MutexLock lock(mu_);
GRPC_ARES_RESOLVER_TRACE_LOG("OnIocpWriteableInner. fd:|%s|", GetName());
GPR_ASSERT(socket_type_ == SOCK_STREAM);
CHECK(socket_type_ == SOCK_STREAM);
absl::Status error;
if (winsocket_->write_info()->result().wsa_error != 0) {
error = GRPC_WSA_ERROR(winsocket_->write_info()->result().wsa_error,
@ -631,7 +632,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
GetName(), winsocket_->write_info()->result().wsa_error,
grpc_core::StatusToString(error).c_str());
}
GPR_ASSERT(tcp_write_state_ == WRITE_PENDING);
CHECK(tcp_write_state_ == WRITE_PENDING);
if (error.ok()) {
tcp_write_state_ = WRITE_WAITING_FOR_VERIFICATION_UPON_RETRY;
write_buf_ = grpc_slice_sub_no_ref(
@ -712,7 +713,7 @@ class CustomSockFuncs {
GRPC_ARES_RESOLVER_TRACE_LOG(
"fd:|%s| created with params af:%d type:%d protocol:%d",
polled_fd->GetName(), af, type, protocol);
GPR_ASSERT(self->sockets_.insert({s, std::move(polled_fd)}).second);
CHECK(self->sockets_.insert({s, std::move(polled_fd)}).second);
return s;
}
@ -722,7 +723,7 @@ class CustomSockFuncs {
GrpcPolledFdFactoryWindows* self =
static_cast<GrpcPolledFdFactoryWindows*>(user_data);
auto it = self->sockets_.find(as);
GPR_ASSERT(it != self->sockets_.end());
CHECK(it != self->sockets_.end());
return it->second->Connect(&wsa_error_ctx, target, target_len);
}
@ -732,7 +733,7 @@ class CustomSockFuncs {
GrpcPolledFdFactoryWindows* self =
static_cast<GrpcPolledFdFactoryWindows*>(user_data);
auto it = self->sockets_.find(as);
GPR_ASSERT(it != self->sockets_.end());
CHECK(it != self->sockets_.end());
return it->second->SendV(&wsa_error_ctx, iov, iovec_count);
}
@ -743,7 +744,7 @@ class CustomSockFuncs {
GrpcPolledFdFactoryWindows* self =
static_cast<GrpcPolledFdFactoryWindows*>(user_data);
auto it = self->sockets_.find(as);
GPR_ASSERT(it != self->sockets_.end());
CHECK(it != self->sockets_.end());
return it->second->RecvFrom(&wsa_error_ctx, data, data_len, flags, from,
from_len);
}
@ -802,7 +803,7 @@ void GrpcPolledFdFactoryWindows::Initialize(grpc_core::Mutex* mutex,
std::unique_ptr<GrpcPolledFd> GrpcPolledFdFactoryWindows::NewGrpcPolledFdLocked(
ares_socket_t as) {
auto it = sockets_.find(as);
GPR_ASSERT(it != sockets_.end());
CHECK(it != sockets_.end());
return std::make_unique<GrpcPolledFdWrapper>(it->second.get());
}

@ -17,6 +17,7 @@
#include <chrono>
#include "absl/log/check.h"
#include "absl/strings/str_format.h"
#include <grpc/support/alloc.h>
@ -37,7 +38,7 @@ IOCP::IOCP(ThreadPool* thread_pool) noexcept
: thread_pool_(thread_pool),
iocp_handle_(CreateIoCompletionPort(INVALID_HANDLE_VALUE, nullptr,
(ULONG_PTR) nullptr, 0)) {
GPR_ASSERT(iocp_handle_);
CHECK(iocp_handle_);
WSASocketFlagsInit();
}
@ -54,7 +55,7 @@ std::unique_ptr<WinSocket> IOCP::Watch(SOCKET socket) {
GRPC_WSA_ERROR(WSAGetLastError(), "Unable to add socket to iocp")
.ToString());
}
GPR_ASSERT(ret == iocp_handle_);
CHECK(ret == iocp_handle_);
return wrapped_socket;
}
@ -65,7 +66,7 @@ void IOCP::Shutdown() {
while (outstanding_kicks_.load() > 0) {
Work(std::chrono::hours(42), []() {});
}
GPR_ASSERT(CloseHandle(iocp_handle_));
CHECK(CloseHandle(iocp_handle_));
}
Poller::WorkResult IOCP::Work(EventEngine::Duration timeout,
@ -81,7 +82,8 @@ Poller::WorkResult IOCP::Work(EventEngine::Duration timeout,
GRPC_EVENT_ENGINE_POLLER_TRACE("IOCP::%p deadline exceeded", this);
return Poller::WorkResult::kDeadlineExceeded;
}
GPR_ASSERT(completion_key && overlapped);
CHECK(completion_key);
CHECK(overlapped);
if (overlapped == &kick_overlap_) {
GRPC_EVENT_ENGINE_POLLER_TRACE("IOCP::%p kicked", this);
outstanding_kicks_.fetch_sub(1);
@ -100,7 +102,7 @@ Poller::WorkResult IOCP::Work(EventEngine::Duration timeout,
// about to register for notification of an overlapped event.
auto* socket = reinterpret_cast<WinSocket*>(completion_key);
WinSocket::OpState* info = socket->GetOpInfoForOverlapped(overlapped);
GPR_ASSERT(info != nullptr);
CHECK_NE(info, nullptr);
info->GetOverlappedResult();
info->SetReady();
schedule_poll_again();
@ -109,9 +111,9 @@ Poller::WorkResult IOCP::Work(EventEngine::Duration timeout,
void IOCP::Kick() {
outstanding_kicks_.fetch_add(1);
GPR_ASSERT(PostQueuedCompletionStatus(
iocp_handle_, 0, reinterpret_cast<ULONG_PTR>(&kick_token_),
&kick_overlap_));
CHECK(PostQueuedCompletionStatus(iocp_handle_, 0,
reinterpret_cast<ULONG_PTR>(&kick_token_),
&kick_overlap_));
}
DWORD IOCP::GetDefaultSocketFlags() {

@ -14,6 +14,8 @@
#include <grpc/support/port_platform.h>
#ifdef GPR_WINDOWS
#include "absl/log/check.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log_windows.h>
@ -45,7 +47,7 @@ WinSocket::WinSocket(SOCKET socket, ThreadPool* thread_pool) noexcept
write_info_(this) {}
WinSocket::~WinSocket() {
GPR_ASSERT(is_shutdown_.load());
CHECK(is_shutdown_.load());
GRPC_EVENT_ENGINE_ENDPOINT_TRACE("WinSocket::%p destroyed", this);
}
@ -94,7 +96,7 @@ void WinSocket::NotifyOnReady(OpState& info, EventEngine::Closure* closure) {
return;
};
// It is an error if any notification is already registered for this socket.
GPR_ASSERT(std::exchange(info.closure_, closure) == nullptr);
CHECK_EQ(std::exchange(info.closure_, closure), nullptr);
}
void WinSocket::NotifyOnRead(EventEngine::Closure* on_read) {
@ -106,11 +108,11 @@ void WinSocket::NotifyOnWrite(EventEngine::Closure* on_write) {
}
void WinSocket::UnregisterReadCallback() {
GPR_ASSERT(std::exchange(read_info_.closure_, nullptr) != nullptr);
CHECK_NE(std::exchange(read_info_.closure_, nullptr), nullptr);
}
void WinSocket::UnregisterWriteCallback() {
GPR_ASSERT(std::exchange(write_info_.closure_, nullptr) != nullptr);
CHECK_NE(std::exchange(write_info_.closure_, nullptr), nullptr);
}
// ---- WinSocket::OpState ----
@ -124,7 +126,7 @@ void WinSocket::OpState::SetReady() {
auto* closure = std::exchange(closure_, nullptr);
// If an IOCP event is returned for a socket, and no callback has been
// registered for notification, this is invalid usage.
GPR_ASSERT(closure != nullptr);
CHECK_NE(closure, nullptr);
win_socket_->thread_pool_->Run(closure);
}

@ -17,6 +17,7 @@
#include "absl/cleanup/cleanup.h"
#include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
@ -85,7 +86,7 @@ void WindowsEndpoint::AsyncIOState::DoTcpRead(SliceBuffer* buffer) {
return;
}
// Prepare the WSABUF struct
GPR_ASSERT(buffer->Count() <= kMaxWSABUFCount);
CHECK(buffer->Count() <= kMaxWSABUFCount);
WSABUF wsa_buffers[kMaxWSABUFCount];
for (size_t i = 0; i < buffer->Count(); i++) {
auto& slice = buffer->MutableSliceAt(i);
@ -164,11 +165,11 @@ bool WindowsEndpoint::Write(absl::AnyInvocable<void(absl::Status)> on_writable,
peer_address_string_.c_str(), str.length(), str.data());
}
}
GPR_ASSERT(data->Count() <= UINT_MAX);
CHECK(data->Count() <= UINT_MAX);
absl::InlinedVector<WSABUF, kMaxWSABUFCount> buffers(data->Count());
for (size_t i = 0; i < data->Count(); i++) {
auto& slice = data->MutableSliceAt(i);
GPR_ASSERT(slice.size() <= ULONG_MAX);
CHECK(slice.size() <= ULONG_MAX);
buffers[i].len = slice.size();
buffers[i].buf = (char*)slice.begin();
}
@ -305,8 +306,8 @@ void WindowsEndpoint::HandleReadClosure::Run() {
buffer_->Swap(last_read_buffer_);
return ResetAndReturnCallback()(status);
}
GPR_DEBUG_ASSERT(result.bytes_transferred > 0);
GPR_DEBUG_ASSERT(result.bytes_transferred <= buffer_->Length());
DCHECK_GT(result.bytes_transferred, 0);
DCHECK(result.bytes_transferred <= buffer_->Length());
buffer_->MoveFirstNBytesIntoSliceBuffer(result.bytes_transferred,
last_read_buffer_);
if (buffer_->Length() == 0) {
@ -332,9 +333,9 @@ bool WindowsEndpoint::HandleReadClosure::MaybeFinishIfDataHasAlreadyBeenRead() {
void WindowsEndpoint::HandleReadClosure::DonateSpareSlices(
SliceBuffer* buffer) {
// Donee buffer must be empty.
GPR_ASSERT(buffer->Length() == 0);
CHECK_EQ(buffer->Length(), 0);
// HandleReadClosure must be in the reset state.
GPR_ASSERT(buffer_ == nullptr);
CHECK_EQ(buffer_, nullptr);
buffer->Swap(last_read_buffer_);
}
@ -352,7 +353,7 @@ void WindowsEndpoint::HandleWriteClosure::Run() {
if (result.wsa_error != 0) {
status = GRPC_WSA_ERROR(result.wsa_error, "WSASend");
} else {
GPR_ASSERT(result.bytes_transferred == buffer_->Length());
CHECK(result.bytes_transferred == buffer_->Length());
}
return ResetAndReturnCallback()(status);
}

@ -17,6 +17,7 @@
#include <memory>
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
@ -114,7 +115,7 @@ WindowsEventEngine::WindowsEventEngine()
iocp_worker_(thread_pool_.get(), &iocp_) {
WSADATA wsaData;
int status = WSAStartup(MAKEWORD(2, 0), &wsaData);
GPR_ASSERT(status == 0);
CHECK_EQ(status, 0);
}
WindowsEventEngine::~WindowsEventEngine() {
@ -143,13 +144,13 @@ WindowsEventEngine::~WindowsEventEngine() {
task_mu_.Lock();
}
}
GPR_ASSERT(GPR_LIKELY(known_handles_.empty()));
CHECK(GPR_LIKELY(known_handles_.empty()));
task_mu_.Unlock();
}
iocp_.Kick();
iocp_worker_.WaitForShutdown();
iocp_.Shutdown();
GPR_ASSERT(WSACleanup() == 0);
CHECK_EQ(WSACleanup(), 0);
timer_manager_.Shutdown();
thread_pool_->Quiesce();
}
@ -369,7 +370,7 @@ EventEngine::ConnectionHandle WindowsEventEngine::Connect(
auto connection_state = std::make_shared<ConnectionState>();
grpc_core::MutexLock lock(&connection_state->mu);
connection_state->socket = iocp_.Watch(sock);
GPR_ASSERT(connection_state->socket != nullptr);
CHECK_NE(connection_state->socket, nullptr);
auto* info = connection_state->socket->write_info();
connection_state->address = address;
connection_state->allocator = std::move(memory_allocator);
@ -455,8 +456,8 @@ bool WindowsEventEngine::CancelConnectFromDeadlineTimer(
// Erase the connection handle, which is guaranteed to exist.
{
grpc_core::MutexLock lock(&connection_mu_);
GPR_ASSERT(known_connection_handles_.erase(
connection_state->connection_handle) == 1);
CHECK(known_connection_handles_.erase(
connection_state->connection_handle) == 1);
}
return CancelConnectInternalStateLocked(connection_state);
}

@ -15,6 +15,7 @@
#ifdef GPR_WINDOWS
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
@ -47,7 +48,7 @@ WindowsEventEngineListener::SinglePortSocketListener::AsyncIOState::
void WindowsEventEngineListener::SinglePortSocketListener::
OnAcceptCallbackWrapper::Run() {
GPR_ASSERT(io_state_ != nullptr);
CHECK_NE(io_state_, nullptr);
grpc_core::ReleasableMutexLock lock(&io_state_->mu);
if (io_state_->listener_socket->IsShutdown()) {
GRPC_EVENT_ENGINE_TRACE(
@ -124,7 +125,7 @@ WindowsEventEngineListener::SinglePortSocketListener::Create(
}
auto result = SinglePortSocketListener::PrepareListenerSocket(sock, addr);
GRPC_RETURN_IF_ERROR(result.status());
GPR_ASSERT(result->port >= 0);
CHECK_GE(result->port, 0);
// Using `new` to access non-public constructor
return absl::WrapUnique(new SinglePortSocketListener(
listener, AcceptEx, /*win_socket=*/listener->iocp_->Watch(sock),
@ -190,8 +191,8 @@ void WindowsEventEngineListener::SinglePortSocketListener::
ABSL_EXCLUSIVE_LOCKS_REQUIRED(io_state_->mu) {
if (do_close_socket) closesocket(io_state_->accept_socket);
io_state_->accept_socket = INVALID_SOCKET;
GPR_ASSERT(GRPC_LOG_IF_ERROR("SinglePortSocketListener::Start",
StartLocked()));
CHECK(GRPC_LOG_IF_ERROR("SinglePortSocketListener::Start",
StartLocked()));
};
const auto& overlapped_result =
io_state_->listener_socket->read_info()->result();
@ -265,7 +266,7 @@ absl::StatusOr<WindowsEventEngineListener::SinglePortSocketListener::
WindowsEventEngineListener::SinglePortSocketListener::PrepareListenerSocket(
SOCKET sock, const EventEngine::ResolvedAddress& addr) {
auto fail = [&](absl::Status error) -> absl::Status {
GPR_ASSERT(!error.ok());
CHECK(!error.ok());
auto addr_uri = ResolvedAddressToURI(addr);
error = grpc_error_set_int(
grpc_error_set_str(
@ -374,7 +375,7 @@ absl::StatusOr<int> WindowsEventEngineListener::Bind(
}
absl::Status WindowsEventEngineListener::Start() {
GPR_ASSERT(!started_.exchange(true));
CHECK(!started_.exchange(true));
grpc_core::MutexLock lock(&port_listeners_mu_);
for (auto& port_listener : port_listeners_) {
GRPC_RETURN_IF_ERROR(port_listener->Start());

@ -899,6 +899,7 @@ CORE_SOURCE_FILES = [
'third_party/abseil-cpp/absl/hash/internal/hash.cc',
'third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc',
'third_party/abseil-cpp/absl/log/globals.cc',
'third_party/abseil-cpp/absl/log/internal/check_op.cc',
'third_party/abseil-cpp/absl/log/internal/conditions.cc',
'third_party/abseil-cpp/absl/log/internal/fnmatch.cc',
'third_party/abseil-cpp/absl/log/internal/globals.cc',

Loading…
Cancel
Save