From: Guus Sliepen Date: Sun, 9 Jan 2005 21:28:49 +0000 (+0000) Subject: Correct calculation of max_fd after fd_del(). X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=fcb521743ea839814fcf4b271f71426b9c44ed8d;p=tinc Correct calculation of max_fd after fd_del(). --- diff --git a/fd/fd.c b/fd/fd.c index ad4a8cab..e658c1d0 100644 --- 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) {