diff options
| author | Michael Adam <obnox@samba.org> | 2016-08-16 11:03:27 +0200 |
|---|---|---|
| committer | Andreas Schneider <asn@samba.org> | 2016-10-20 10:50:29 +0200 |
| commit | ebe5f15854866c225febe73c952356873b958305 (patch) | |
| tree | aa26eebe51bde11ea5c2e70dff1cc467f3b81844 /src | |
| parent | 97d23728cfc392fe5f2c33831f4c85aa31d083fc (diff) | |
| download | socket_wrapper-ebe5f15854866c225febe73c952356873b958305.tar.gz socket_wrapper-ebe5f15854866c225febe73c952356873b958305.tar.xz socket_wrapper-ebe5f15854866c225febe73c952356873b958305.zip | |
swrap: Improve dup 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.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 2a88dff..110d999 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -5158,14 +5158,15 @@ int close(int fd) static int swrap_dup(int fd) { struct socket_info *si; - struct socket_info_fd *fi; - - si = find_socket_info(fd); + struct socket_info_fd *src_fi, *fi; - if (!si) { + src_fi = find_socket_info_fd(fd); + if (src_fi == NULL) { return libc_dup(fd); } + si = src_fi->si; + fi = (struct socket_info_fd *)calloc(1, sizeof(struct socket_info_fd)); if (fi == NULL) { errno = ENOMEM; @@ -5186,7 +5187,7 @@ static int swrap_dup(int fd) /* 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); return fi->fd; } |
