src: Handle stale fds in dup() and dup2().
authorAndreas Schneider <asn@samba.org>
Tue, 28 Jan 2014 13:10:53 +0000 (14:10 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 28 Jan 2014 13:11:51 +0000 (14:11 +0100)
Reviewed-by: Stefan Metzmacher <metze@samba.org>
src/socket_wrapper.c

index 0d74321f03a40f56f45bf254ad91bcae280ef3ec..353a9a5bd2d943a7ffe18a51d268295d5e6dfd65 100644 (file)
@@ -3934,6 +3934,9 @@ static int swrap_dup(int fd)
                return -1;
        }
 
+       /* Make sure we don't have an entry for the fd */
+       swrap_remove_stale(fi->fd);
+
        SWRAP_DLIST_ADD(si->fds, fi);
        return fi->fd;
 }
@@ -3978,6 +3981,9 @@ static int swrap_dup2(int fd, int newfd)
                return -1;
        }
 
+       /* Make sure we don't have an entry for the fd */
+       swrap_remove_stale(fi->fd);
+
        SWRAP_DLIST_ADD(si->fds, fi);
        return fi->fd;
 }