From 6045fb8e371ce22de2cd529b0aed9f7ab68e0f61 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 11 Feb 2013 12:08:07 +0100 Subject: Add close() wrapper. --- src/socket_wrapper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index c1827f2..303069f 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -208,6 +208,17 @@ static int real_bind(int sockfd, return libc_bind(sockfd, addr, addrlen); } +static int (*libc_close)(int fd); + +static int real_close(int fd) +{ + if (libc_close == NULL) { + *(void **)(&libc_close) = libc_dlsym("close"); + } + + return libc_close(fd); +} + static int (*libc_connect)(int sockfd, const struct sockaddr *addr, socklen_t addrlen); @@ -2830,8 +2841,7 @@ ssize_t writev(int s, const struct iovec *vector, int count) return ret; } -#if 0 -_PUBLIC_ int swrap_close(int fd) +int close(int fd) { struct socket_info *si = find_socket_info(fd); struct socket_info_fd *fi; @@ -2878,6 +2888,7 @@ _PUBLIC_ int swrap_close(int fd) return ret; } +#if 0 _PUBLIC_ int swrap_dup(int fd) { struct socket_info *si; -- cgit