aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/iomgr
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-02-17 15:46:13 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-02-17 15:46:13 -0800
commit23139ae24e94b2d51505836f7746e8f122c96f45 (patch)
treeafa3f2a6617899ba92ca9460eeac7fc94dc0611e /src/core/iomgr
parent44f77a3eb34e8d8f0802e87bf86bf62a29aeaf18 (diff)
Add checking on fd_posix refcounts
Diffstat (limited to 'src/core/iomgr')
-rw-r--r--src/core/iomgr/fd_posix.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 737ee016aa..cc57830551 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -104,14 +104,17 @@ static void destroy(grpc_fd *fd) {
}
static void ref_by(grpc_fd *fd, int n) {
- gpr_atm_no_barrier_fetch_add(&fd->refst, n);
+ GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&fd->refst, n) > 0);
}
static void unref_by(grpc_fd *fd, int n) {
- if (gpr_atm_full_fetch_add(&fd->refst, -n) == n) {
+ gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n);
+ if (old == n) {
grpc_iomgr_add_callback(fd->on_done, fd->on_done_user_data);
freelist_fd(fd);
grpc_iomgr_unref();
+ } else {
+ GPR_ASSERT(old > n);
}
}