From 01f96b1dbfd9991ccb9034dd55d4ebea338b1599 Mon Sep 17 00:00:00 2001 From: Eugene Ostroukhov Date: Tue, 17 Dec 2024 11:26:44 -0800 Subject: [PATCH] fixup: bug in FileDescriptors --- src/core/lib/event_engine/posix_engine/file_descriptors.cc | 6 +++--- test/core/event_engine/posix/file_descriptors_test.cc | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/lib/event_engine/posix_engine/file_descriptors.cc b/src/core/lib/event_engine/posix_engine/file_descriptors.cc index 9acc1489fd03d..9a0bb4ce90200 100644 --- a/src/core/lib/event_engine/posix_engine/file_descriptors.cc +++ b/src/core/lib/event_engine/posix_engine/file_descriptors.cc @@ -44,13 +44,13 @@ class ThreadLocalCounter { } void FdLocked(const FileDescriptors* descriptors) { - if (descriptors != nullptr && !IsThreadAlive()) { + if (descriptors != nullptr && IsThreadAlive()) { ++thread_locks_count_[descriptors]; } } void FdUnlocked(const FileDescriptors* descriptors) { - if (descriptors != nullptr && !IsThreadAlive()) { + if (descriptors != nullptr && IsThreadAlive()) { --thread_locks_count_[descriptors]; CHECK_GE(thread_locks_count_[descriptors], 0); } @@ -78,7 +78,7 @@ class ThreadLocalCounter { static int GetTid() { return gettid(); } #elif - static bool IsThreadAlive() { return true; } + static bool IsThreadAlive() { return false; } static int GetTid() { return -1; } #endif // GPR_HAS_PTHREAD_H diff --git a/test/core/event_engine/posix/file_descriptors_test.cc b/test/core/event_engine/posix/file_descriptors_test.cc index 6b30d3a456aa5..4d95592f3503e 100644 --- a/test/core/event_engine/posix/file_descriptors_test.cc +++ b/test/core/event_engine/posix/file_descriptors_test.cc @@ -21,6 +21,7 @@ #include #include "absl/cleanup/cleanup.h" +#include "absl/log/log.h" namespace grpc_event_engine { namespace experimental { @@ -68,8 +69,11 @@ TEST(FileDescriptorsTest, DetectsIfThreadHasIOLock) { FileDescriptors fds; FileDescriptor fd = fds.Add(1); auto locked = fds.Lock(fd); + LOG(INFO) << "before"; absl::Status status = fds.Stop(); + LOG(INFO) << 5; EXPECT_EQ(status.code(), absl::StatusCode::kFailedPrecondition) << status; + LOG(INFO) << 6; } } // namespace experimental