aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-03-21 11:45:15 -0700
committerGravatar Jan Tattermusch <jtattermusch@users.noreply.github.com>2016-03-21 11:45:15 -0700
commitfb6e13b1b5ba135220c7be1edf3fb6f92e79872b (patch)
tree2f57667a3603855d23f423df9923ccf652e50860 /src
parentb08ee7a260d0f274554892cd3138215ab905ce77 (diff)
parentf4e25643665f139ad8abd05d066f313e4f16a743 (diff)
Merge pull request #5788 from vjpai/make_clang_great_again_v2
Update clang for the Dockerfile used in tsan tests, fix a newly exposed bug
Diffstat (limited to 'src')
-rw-r--r--src/core/iomgr/fd_posix.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 4ba7c5df94..3edafa0b07 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -72,6 +72,9 @@ static grpc_fd *fd_freelist = NULL;
static gpr_mu fd_freelist_mu;
static void freelist_fd(grpc_fd *fd) {
+ // Note that this function must be called after a release store (or
+ // full-barrier operation) on refst so that prior actions on the fd are
+ // ordered before the fd becomes visible to the freelist
gpr_mu_lock(&fd_freelist_mu);
fd->freelist_next = fd_freelist;
fd_freelist = fd;
@@ -92,7 +95,6 @@ static grpc_fd *alloc_fd(int fd) {
gpr_mu_init(&r->mu);
}
- gpr_atm_rel_store(&r->refst, 1);
r->shutdown = 0;
r->read_closure = CLOSURE_NOT_READY;
r->write_closure = CLOSURE_NOT_READY;
@@ -104,6 +106,11 @@ static grpc_fd *alloc_fd(int fd) {
r->on_done_closure = NULL;
r->closed = 0;
r->released = 0;
+ // The last operation on r before returning it should be a release-store
+ // so that all the above fields are globally visible before the value of
+ // r could escape to another thread. Our refcount itself needs a release-store
+ // so use this
+ gpr_atm_rel_store(&r->refst, 1);
return r;
}