diff options
author | Anoop C S <anoopcs@redhat.com> | 2017-07-13 15:20:15 +0530 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2018-05-02 14:23:34 +0200 |
commit | 64c848748077f31a95b5338d8d6e92050b43e0fc (patch) | |
tree | b13ef285e756acc45e465b88ff1e81116c869449 /src | |
parent | 548f4d062b06e2cff7fadb0d1ee7de34c1223a8a (diff) | |
download | socket_wrapper-64c848748077f31a95b5338d8d6e92050b43e0fc.tar.gz socket_wrapper-64c848748077f31a95b5338d8d6e92050b43e0fc.tar.xz socket_wrapper-64c848748077f31a95b5338d8d6e92050b43e0fc.zip |
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 <anoopcs@redhat.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/socket_wrapper.c | 11 |
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; } |