From 44ffb793acac94eb7764b65b9d462b0f6eff1b42 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 11 Feb 2013 11:32:47 +0100 Subject: Add recv() 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 b0d9b67..b9461b9 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -300,6 +300,17 @@ static int real_listen(int sockfd, int backlog) return libc_listen(sockfd, backlog); } +static int (*libc_recv)(int sockfd, void *buf, size_t len, int flags); + +static int real_recv(int sockfd, void *buf, size_t len, int flags) +{ + if (libc_recv == NULL) { + *(void **)(&libc_recv) = libc_dlsym("recv"); + } + + return libc_recv(sockfd, buf, len, flags); +} + static int (*libc_recvfrom)(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); @@ -2467,8 +2478,7 @@ ssize_t sendto(int s, const void *buf, size_t len, int flags, return ret; } -#if 0 -_PUBLIC_ ssize_t swrap_recv(int s, void *buf, size_t len, int flags) +ssize_t recv(int s, void *buf, size_t len, int flags) { int ret; struct socket_info *si = find_socket_info(s); @@ -2496,6 +2506,7 @@ _PUBLIC_ ssize_t swrap_recv(int s, void *buf, size_t len, int flags) return ret; } +#if 0 _PUBLIC_ ssize_t swrap_read(int s, void *buf, size_t len) { int ret; -- cgit