diff options
| author | Andreas Schneider <asn@samba.org> | 2014-01-28 13:15:34 +0100 |
|---|---|---|
| committer | Andreas Schneider <asn@samba.org> | 2014-01-28 13:25:14 +0100 |
| commit | ea45102993c0800a8a62137da09dbb2787834ed4 (patch) | |
| tree | 454fa4701d27613e2f6f76971bda1d7650f750a8 /src | |
| parent | 0627527da3abbafdb6f171dbdbc3b719a96a2b62 (diff) | |
| download | socket_wrapper-ea45102993c0800a8a62137da09dbb2787834ed4.tar.gz socket_wrapper-ea45102993c0800a8a62137da09dbb2787834ed4.tar.xz socket_wrapper-ea45102993c0800a8a62137da09dbb2787834ed4.zip | |
src: Add pipe() to handle stale fds.
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'src')
| -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 d352291..fad9475 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -297,6 +297,7 @@ struct swrap_libc_fns { int (*libc_ioctl)(int d, unsigned long int request, ...); int (*libc_listen)(int sockfd, int backlog); int (*libc_open)(const char *pathname, int flags, mode_t mode); + int (*libc_pipe)(int pipefd[2]); int (*libc_read)(int fd, void *buf, size_t count); ssize_t (*libc_readv)(int fd, const struct iovec *iov, int iovcnt); int (*libc_recv)(int sockfd, void *buf, size_t len, int flags); @@ -571,6 +572,13 @@ static int libc_open(const char *pathname, int flags, mode_t mode) return swrap.fns.libc_open(pathname, flags, mode); } +static int libc_pipe(int pipefd[2]) +{ + swrap_load_lib_function(SWRAP_LIBSOCKET, pipe); + + return swrap.fns.libc_pipe(pipefd); +} + static int libc_read(int fd, void *buf, size_t count) { swrap_load_lib_function(SWRAP_LIBC, read); @@ -2068,6 +2076,28 @@ int socket(int family, int type, int protocol) } /**************************************************************************** + * PIPE + ***************************************************************************/ + +static int swrap_pipe(int pipefd[2]) +{ + int rc; + + rc = libc_pipe(pipefd); + if (rc != -1) { + swrap_remove_stale(pipefd[0]); + swrap_remove_stale(pipefd[1]); + } + + return rc; +} + +int pipe(int pipefd[2]) +{ + return swrap_pipe(pipefd); +} + +/**************************************************************************** * ACCEPT ***************************************************************************/ |
