summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2023-05-25 12:39:20 +1000
committerKinseyMoore <48726349+KinseyMoore@users.noreply.github.com>2023-05-25 07:40:24 -0500
commiteea8248532a76e86048bccf6442ae098e93c3372 (patch)
tree1365ace3c6207454ebec0a19be15f1a71985a62e
parentbsd/ntp: Copy all fds in an fd_set (diff)
downloadrtems-net-services-eea8248532a76e86048bccf6442ae098e93c3372.tar.bz2
bsd/ntp: Fix the handling of max active fd when removing the max fd
This is a fix to a bug fix to catch removing the last fd in a set when it is the max active fd.
-rw-r--r--bsd/freebsd/contrib/ntp/ntpd/ntp_io.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c b/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c
index 737314c..231cefe 100644
--- a/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c
+++ b/bsd/freebsd/contrib/ntp/ntpd/ntp_io.c
@@ -444,13 +444,18 @@ maintain_activefds(
FD_CLR(fd, &activefds);
if (maxactivefd && fd == maxactivefd) {
#ifdef __rtems__
- maxactivefd = 0;
+ int curr_maxactivefd = maxactivefd;
#endif /* __rtems__ */
for (i = maxactivefd - 1; i >= 0; i--)
if (FD_ISSET(i, &activefds)) {
maxactivefd = i;
break;
}
+#ifdef __rtems__
+ if (curr_maxactivefd == maxactivefd) {
+ maxactivefd = 0;
+ }
+#endif /* __rtems__ */
INSIST(fd != maxactivefd);
}
}