aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2016-08-16 11:04:43 +0200
committerAndreas Schneider <asn@samba.org>2016-10-20 10:50:37 +0200
commit1e7528c2b1a027538b54bd3576eba1206265ae8c (patch)
treed0924688af80101aa3e368190c6f169335adb935 /src
parentd3d09e631aa7f9b5ffe88a786ad21e7e51aee909 (diff)
downloadsocket_wrapper-1e7528c2b1a027538b54bd3576eba1206265ae8c.tar.gz
socket_wrapper-1e7528c2b1a027538b54bd3576eba1206265ae8c.tar.xz
socket_wrapper-1e7528c2b1a027538b54bd3576eba1206265ae8c.zip
swrap: Improve vfcntl to add the dup'd fd after the source fd
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 730e346..b7de67c 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -5263,17 +5263,17 @@ int dup2(int fd, int newfd)
static int swrap_vfcntl(int fd, int cmd, va_list va)
{
- struct socket_info_fd *fi;
+ struct socket_info_fd *src_fi, *fi;
struct socket_info *si;
int rc;
- si = find_socket_info(fd);
- if (si == NULL) {
- rc = libc_vfcntl(fd, cmd, va);
-
- return rc;
+ src_fi = find_socket_info_fd(fd);
+ if (src_fi == NULL) {
+ return libc_vfcntl(fd, cmd, va);
}
+ si = src_fi->si;
+
switch (cmd) {
case F_DUPFD:
fi = (struct socket_info_fd *)calloc(1, sizeof(struct socket_info_fd));
@@ -5296,7 +5296,7 @@ static int swrap_vfcntl(int fd, int cmd, va_list va)
/* Make sure we don't have an entry for the fd */
swrap_remove_stale(fi->fd);
- SWRAP_DLIST_ADD(socket_fds, fi);
+ SWRAP_DLIST_ADD_AFTER(socket_fds, fi, src_fi);
rc = fi->fd;
break;