Use full_fetch_add for ref counting the backup poller.

There were spurious TSAN errors on PR #17823 because
TSAN doesn't really understand how `g_uncovered_notifications_pending`
works. It's odd in the sense that we destroy the backup
poller, when the ref count reaches 1 (instead of 0 which is commonly
used).

Prior to PR #17823, TSAN doesn't complain because we (unnecessarily)
always grab the pollset's lock, which TSAN understands.

This commit uses full_fetch_add to explain the synchronization
primitive to TSAN.
pull/17908/head
Soheil Hassas Yeganeh 6 years ago
parent 15bb25ae54
commit 3492539b32
  1. 2
      src/core/lib/iomgr/tcp_posix.cc

@ -195,7 +195,7 @@ static void run_poller(void* bp, grpc_error* error_ignored) {
static void drop_uncovered(grpc_tcp* tcp) {
backup_poller* p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller);
gpr_atm old_count =
gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1);
gpr_atm_full_fetch_add(&g_uncovered_notifications_pending, -1);
if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_INFO, "BACKUP_POLLER:%p uncover cnt %d->%d", p,
static_cast<int>(old_count), static_cast<int>(old_count) - 1);

Loading…
Cancel
Save