From 501b5f3e6444117dab213f8a3dfdda0a860ecde9 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Thu, 13 Jul 2017 15:13:07 +0530 Subject: swrap: Rearrange swrap_remove_stale In preparation to implement thread safety, re-ordering lines of code to properly align to lockign calls Signed-off-by: Anoop C S Reviewed-by: Michael Adam Reviewed-by: Andreas Schneider --- src/socket_wrapper.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index f1f0036..9c16e1a 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -1928,15 +1928,20 @@ static void swrap_remove_stale(int fd) return; } + SWRAP_LOG(SWRAP_LOG_TRACE, "remove stale wrapper for %d", fd); + si_index = fi->si_index; - SWRAP_LOG(SWRAP_LOG_TRACE, "remove stale wrapper for %d", fd); + si = swrap_get_socket_info(si_index); + SWRAP_DLIST_REMOVE(socket_fds, fi); - free(fi); - 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) { return; } @@ -1944,9 +1949,6 @@ static void swrap_remove_stale(int fd) if (si->un_addr.sun_path[0] != '\0') { unlink(si->un_addr.sun_path); } - - swrap_set_next_free(si, first_free); - first_free = si_index; } static int sockaddr_convert_to_un(struct socket_info *si, -- cgit