From 64c848748077f31a95b5338d8d6e92050b43e0fc Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 13 Jul 2017 15:20:15 +0530 Subject: swrap: Rearrange swrap_close In preparation to implement thread safety, re-ordering lines of code to properly align to locking calls. 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 ad83111..f1f0036 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -5692,15 +5692,19 @@ static int swrap_close(int fd) } si_index = fi->si_index; + si = swrap_get_socket_info(si_index); SWRAP_DLIST_REMOVE(socket_fds, fi); - free(fi); ret = libc_close(fd); - si = swrap_get_socket_info(si_index); + swrap_set_next_free(si, first_free); + first_free = si_index; + swrap_dec_refcount(si); + free(fi); + if (swrap_get_refcount(si) > 0) { /* there are still references left */ return ret; @@ -5719,9 +5723,6 @@ static int swrap_close(int fd) unlink(si->un_addr.sun_path); } - swrap_set_next_free(si, first_free); - first_free = si_index; - return ret; } -- cgit