diff options
author | Craig Tiller <ctiller@google.com> | 2016-07-06 22:48:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-06 22:48:17 -0700 |
commit | 2cbe7542853a99931c5bd8d8576bd527c1ad023a (patch) | |
tree | cfdda97a076c0bfb468da6669e8696e5a4aabc00 /src | |
parent | 183574787744f42491398cb0dafba6209c355cae (diff) | |
parent | b76471d53b93f9f472c0e50b7058e8b2e0738d69 (diff) |
Merge pull request #7204 from ctiller/tsan-server-fix
Fix TSAN failure in tcp_server (shown via qps_openloop_test)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lib/iomgr/tcp_server_posix.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/lib/iomgr/tcp_server_posix.c b/src/core/lib/iomgr/tcp_server_posix.c index a1a463550a..d3803c3bd0 100644 --- a/src/core/lib/iomgr/tcp_server_posix.c +++ b/src/core/lib/iomgr/tcp_server_posix.c @@ -134,7 +134,7 @@ struct grpc_tcp_server { size_t pollset_count; /* next pollset to assign a channel to */ - size_t next_pollset_to_assign; + gpr_atm next_pollset_to_assign; }; static gpr_once check_init = GPR_ONCE_INIT; @@ -181,7 +181,7 @@ grpc_error *grpc_tcp_server_create(grpc_closure *shutdown_complete, s->head = NULL; s->tail = NULL; s->nports = 0; - s->next_pollset_to_assign = 0; + gpr_atm_no_barrier_store(&s->next_pollset_to_assign, 0); *server = s; return GRPC_ERROR_NONE; } @@ -369,7 +369,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *err) { } read_notifier_pollset = - sp->server->pollsets[(sp->server->next_pollset_to_assign++) % + sp->server->pollsets[(size_t)gpr_atm_no_barrier_fetch_add( + &sp->server->next_pollset_to_assign, 1) % sp->server->pollset_count]; /* loop until accept4 returns EAGAIN, and then re-arm notification */ |