Correct calculation of max_fd after fd_del().
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 9 Jan 2005 21:28:49 +0000 (21:28 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 9 Jan 2005 21:28:49 +0000 (21:28 +0000)
fd/fd.c

diff --git a/fd/fd.c b/fd/fd.c
index ad4a8cabb37a4fa254e8cb59a3c581dfda1a348f..e658c1d0498566282ca45d7a2d5adb4e683f64ea 100644 (file)
--- a/fd/fd.c
+++ b/fd/fd.c
@@ -79,10 +79,14 @@ bool fd_del(struct fd *fd) {
        FD_CLR(fd->fd, &writeset);
        FD_CLR(fd->fd, &errorset);
        
-       if(fd->fd >= max_fd)
-               max_fd = ((struct fd *)fds->tail)->fd;
+       avl_del(fds, fd);
 
-       return avl_del(fds, fd);
+       if(fds->tail)
+               max_fd = ((struct fd *)fds->tail->data)->fd;
+       else
+               max_fd = 0;
+
+       return true;
 };
 
 bool fd_mod(struct fd *fd) {