diff options
| -rw-r--r-- | src/socket_wrapper.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index fad9475..41b9923 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -322,6 +322,7 @@ struct swrap_libc_fns { const void *optval, socklen_t optlen); int (*libc_socket)(int domain, int type, int protocol); + int (*libc_socketpair)(int domain, int type, int protocol, int sv[2]); ssize_t (*libc_writev)(int fd, const struct iovec *iov, int iovcnt); }; @@ -663,6 +664,13 @@ static int libc_socket(int domain, int type, int protocol) return swrap.fns.libc_socket(domain, type, protocol); } +static int libc_socketpair(int domain, int type, int protocol, int sv[2]) +{ + swrap_load_lib_function(SWRAP_LIBSOCKET, socketpair); + + return swrap.fns.libc_socketpair(domain, type, protocol, sv); +} + static ssize_t libc_writev(int fd, const struct iovec *iov, int iovcnt) { swrap_load_lib_function(SWRAP_LIBSOCKET, writev); @@ -2076,6 +2084,28 @@ int socket(int family, int type, int protocol) } /**************************************************************************** + * SOCKETPAIR + ***************************************************************************/ + +static int swrap_socketpair(int family, int type, int protocol, int sv[2]) +{ + int rc; + + rc = libc_socketpair(family, type, protocol, sv); + if (rc != -1) { + swrap_remove_stale(sv[0]); + swrap_remove_stale(sv[1]); + } + + return rc; +} + +int socketpair(int family, int type, int protocol, int sv[2]) +{ + return swrap_socketpair(family, type, protocol, sv); +} + +/**************************************************************************** * PIPE ***************************************************************************/ |
