summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2021-02-17 12:14:06 +0100
committerAndreas Schneider <asn@samba.org>2021-03-15 08:04:58 +0100
commitd28fdbf203976290e6ba97577e1979df8f99bb61 (patch)
tree590908abf1303d58877978890272d34e30e19486
parent167009f6ac1186aeeabffc29368bd5b375d9861f (diff)
downloadsocket_wrapper-d28fdbf203976290e6ba97577e1979df8f99bb61.tar.gz
socket_wrapper-d28fdbf203976290e6ba97577e1979df8f99bb61.tar.xz
socket_wrapper-d28fdbf203976290e6ba97577e1979df8f99bb61.zip
swrap: remember the libc_close() errno in swrap_close()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14640 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
-rw-r--r--src/socket_wrapper.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 3bf60f1..61dce97 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -7421,6 +7421,7 @@ static int swrap_close(int fd)
{
struct socket_info *si = NULL;
int si_index;
+ int ret_errno = errno;
int ret;
swrap_mutex_lock(&socket_reset_mutex);
@@ -7440,6 +7441,9 @@ static int swrap_close(int fd)
SWRAP_LOCK_SI(si);
ret = libc_close(fd);
+ if (ret == -1) {
+ ret_errno = errno;
+ }
swrap_dec_refcount(si);
@@ -7474,6 +7478,7 @@ out:
swrap_mutex_unlock(&first_free_mutex);
swrap_mutex_unlock(&socket_reset_mutex);
+ errno = ret_errno;
return ret;
}