Skip to content
Snippets Groups Projects
Commit b1f220de authored by Craig Tiller's avatar Craig Tiller
Browse files

Delay unregister of fd until freelisted

Prevents a race whereby we start deleting the freelist before it's used
parent 77f0461e
No related branches found
No related tags found
No related merge requests found
...@@ -74,6 +74,7 @@ static void freelist_fd(grpc_fd *fd) { ...@@ -74,6 +74,7 @@ static void freelist_fd(grpc_fd *fd) {
gpr_mu_lock(&fd_freelist_mu); gpr_mu_lock(&fd_freelist_mu);
fd->freelist_next = fd_freelist; fd->freelist_next = fd_freelist;
fd_freelist = fd; fd_freelist = fd;
grpc_iomgr_unregister_object(&fd->iomgr_object);
gpr_mu_unlock(&fd_freelist_mu); gpr_mu_unlock(&fd_freelist_mu);
} }
...@@ -139,7 +140,6 @@ static void unref_by(grpc_fd *fd, int n) { ...@@ -139,7 +140,6 @@ static void unref_by(grpc_fd *fd, int n) {
#endif #endif
old = gpr_atm_full_fetch_add(&fd->refst, -n); old = gpr_atm_full_fetch_add(&fd->refst, -n);
if (old == n) { if (old == n) {
grpc_iomgr_unregister_object(&fd->iomgr_object);
freelist_fd(fd); freelist_fd(fd);
} else { } else {
GPR_ASSERT(old > n); GPR_ASSERT(old > n);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment