From da1fe44b27ce2dc66d795637c13bc13b2a657b79 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Wed, 31 Jan 2018 22:46:23 +0530 Subject: swrap: Update free-list only when refcount is zero Signed-off-by: Anoop C S Reviewed-by: Michael Adam Reviewed-by: Andreas Schneider --- src/socket_wrapper.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index ed42b2d..6c9ec51 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -2015,8 +2015,6 @@ static void swrap_remove_stale(int fd) SWRAP_DLIST_REMOVE(socket_fds, fi); - swrap_set_next_free(si, first_free); - first_free = si_index; swrap_dec_refcount(si); free(fi); @@ -2029,6 +2027,9 @@ static void swrap_remove_stale(int fd) unlink(si->un_addr.sun_path); } + swrap_set_next_free(si, first_free); + first_free = si_index; + out: SWRAP_UNLOCK_SI(si); SWRAP_UNLOCK(first_free); @@ -5887,9 +5888,6 @@ static int swrap_close(int fd) ret = libc_close(fd); - swrap_set_next_free(si, first_free); - first_free = si_index; - swrap_dec_refcount(si); free(fi); @@ -5912,6 +5910,9 @@ static int swrap_close(int fd) unlink(si->un_addr.sun_path); } + swrap_set_next_free(si, first_free); + first_free = si_index; + out: SWRAP_UNLOCK_SI(si); SWRAP_UNLOCK(first_free); -- cgit