aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c11
1 files changed, 6 insertions, 5 deletions
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;
}