From ddba8cf2058d662d628fc62f5896b873754ba7c3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 25 Oct 2016 13:42:05 +0200 Subject: swrap: slightly cleanup logic in swrap_close This moves the libc_close() to one central point, thereby grouping the fd-related operations together and the the socket-info related operations after that. Signed-off-by: Michael Adam Reviewed-by: Andreas Schneider --- src/socket_wrapper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 8ac838b..1961549 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -5363,20 +5363,20 @@ static int swrap_close(int fd) SWRAP_DLIST_REMOVE(socket_fds, fi); free(fi); + ret = libc_close(fd); + si = &sockets[si_index]; si->refcount--; if (si->refcount > 0) { /* there are still references left */ - return libc_close(fd); + return ret; } if (si->myname.sa_socklen > 0 && si->peername.sa_socklen > 0) { swrap_pcap_dump_packet(si, NULL, SWRAP_CLOSE_SEND, NULL, 0); } - ret = libc_close(fd); - if (si->myname.sa_socklen > 0 && si->peername.sa_socklen > 0) { swrap_pcap_dump_packet(si, NULL, SWRAP_CLOSE_RECV, NULL, 0); swrap_pcap_dump_packet(si, NULL, SWRAP_CLOSE_ACK, NULL, 0); -- cgit