In preparation to implement thread safety, re-ordering lines
of code to properly align to locking calls.
Signed-off-by: Anoop C S <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
}
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;
unlink(si->un_addr.sun_path);
}
- swrap_set_next_free(si, first_free);
- first_free = si_index;
-
return ret;
}