Skip to content

Commit

Permalink
fixup: no read locks on Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneo committed Dec 10, 2024
1 parent 6512c35 commit d19f0fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/core/lib/event_engine/posix_engine/posix_system_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,15 @@ namespace {
class LocksState {
public:
void Lock(const SystemApi* system_api, int fd) {
#ifdef GPR_ABSEIL_SYNC
if (++counters_[system_api] == 1) {
system_api->ReaderLock();
}
LOG_EVERY_N(INFO, 10) << "Locks: " << counters_[system_api];
#endif
}

void Unlock(const SystemApi* system_api, int fd) {
#ifdef GPR_ABSEIL_SYNC
CHECK_GE(counters_[system_api], 0);
if (--counters_[system_api] == 0) {
system_api->ReaderUnlock();
}
#endif
}

private:
Expand Down
10 changes: 9 additions & 1 deletion src/core/lib/event_engine/posix_engine/posix_system_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,18 @@ class SystemApi {

absl::Status AdvanceGeneration();

void ReaderLock() const ABSL_NO_THREAD_SAFETY_ANALYSIS { mu_.ReaderLock(); }
void ReaderLock() const ABSL_NO_THREAD_SAFETY_ANALYSIS {
// Fork is not supported on Mac. This guard should be replaced accordingly.
#ifdef GPR_ABSEIL_SYNC
mu_.ReaderLock();
#endif
}

void ReaderUnlock() const ABSL_NO_THREAD_SAFETY_ANALYSIS {
// Fork is not supported on Mac. This guard should be replaced accordingly.
#ifdef GPR_ABSEIL_SYNC
mu_.ReaderUnlock();
#endif
}

absl::StatusOr<FileDescriptor> Accept(FileDescriptor sockfd,
Expand Down

0 comments on commit d19f0fa

Please sign in to comment.